2

Basically, I want to ask Z3 to give me an arbitrary integer whose value is greater than 10. So I write the following statements:

(declare-const x (Int))
(assert (forall ((i Int)) (> i 10)))
(check-sat)
(get-value(x))

How can I apply this quantifier to my model? I know you can write (assert (> x 10)) to achieve this, but I mean I want a quantifier in my model so every time I declare an integer constant whose value is guaranteed to be over 10, so that I don't have to insert statement (assert (> x 10)) for every integer constant that I declared. If I have to use macros to prevent repeating code, what is the actual use of quantifiers?

karel
  • 5,489
  • 46
  • 45
  • 50
Mahsa
  • 31
  • 2

1 Answers1

1

You will need to constrain each int you declare individually. x > 10 is the right way to do that.

You can use macros or any other codegen technique. In the SMT solver all of that expands to regular constraints. It has no runtime impact.

forall ((i Int)) (> i 10)) means "Are all ints bigger than 10?" which is false.

Quantifiers do not quantify over all variables that you have declared. They quantify only over the bound variables, here i.

usr
  • 168,620
  • 35
  • 240
  • 369