simon1505475
simon1505475

Reputation: 675

Defining custom quantifiers

I'm trying to get Z3 to verify some formal proofs that uses an iterated maximum in the notation. For example, for f a function (↑i:  0 ≤ i < N:  f(i)) designates the highest value of f when it is applied to a value between 0 and N. It can be nicely axiomatized with:

(↑i: p(i): f(i))  ≤  x    <=>    (∀i:  p(i):  f(i) ≤ x)

with p a predicate over the type of i. Is there a way to define such a quantifier in Z3?

It is quite convenient for formulating my proofs so I'd like to keep it as close to this definition as possible.

Thanks!

Upvotes: 2

Views: 227

Answers (1)

Nikolaj Bjorner
Nikolaj Bjorner

Reputation: 111

There is no direct way to define such binders in Z3. Z3 is based on classical simply sorted first-order logic where the only binders are universal and exitential quantification. In particular, Z3 does not let you write lambda expressions directly. One approach for proving theorems using Z3 that include nested binders is to apply lambda-lifting first and then attempt to prove the resulting first-order formulation.

In your example, you want to define a constant max_p_f. With the following properties:

forall i: p(i) => max_p_f >= f(i)
(exists i: p(i) & max_p_f = f(i)) or (forall i . not p(i))

say (assuming the supremum is defined on the domain, etc.) You would have to create constants for each p,f combination where you want to apply the max function.

Defining such functions is standard in proof assistants for higher-order logic. The Isabelle theorem prover applies transformations similar to the above when mapping proof obligations to first-order backends (E, Vampire, Z3, etc).

Upvotes: 3

Related Questions