0

I am new to Z3 (and SMT solvers in general), and I've been going through the Z3 tutorial. In the section on quantifiers, it has me run the following code:

(declare-fun f (Int) Int)
(declare-fun g (Int) Int)
(declare-const a Int)
(declare-const b Int)
(declare-const c Int)

(assert (forall ((x Int))
                (! (= (f (g x)) x))))
(assert (= (g a) c))
(assert (= (g b) c))
(assert (not (= a b)))
(check-sat)

And running this returns UNSAT. But this seems satisfiable: just take a = 1, b = 2, c = 1, f(x) = 1 - x, and g(x) = 0 if x = 0, otherwise 1. Then a != b, g(a) = g(b) = 1, and we have no fixed points, since f(g(x)) maps everything to 0 except for 0 itself, which gets mapped to 1.

Where am I going wrong here?

1 Answers1

0

Well, your assignment doesn't satisfy the quantified axiom, which says:

f (g 0) == 0

when instantiated at 0. By your definition, this would imply 1 == 0, which isn't true.

I suspect you're confusing what ! means. It's not negation. (That would be not.) The exclamation mark is for giving annotations in SMTLib. See Section 3.6.5 of http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf

alias
  • 28,120
  • 2
  • 23
  • 40
  • The SMT-Lib reference states that `!` is used to annotate terms with attributes, which have no logical meaning and are used to add "meta-logical information". What does that mean exactly, and when might someone use these annotations? – Ekanshdeep Gupta Jan 24 '23 at 17:07
  • One use case is writing patterns for quantifier instantiation. See https://microsoft.github.io/z3guide/docs/logic/Quantifiers/#patterns – alias Jan 24 '23 at 17:19