English 中文(简体)
Are Int and Real somehow compatible in SMT-LIB?
原标题:

The equality operator in SMT-LIB generally requires, unsurprisingly, that its operands be of the same type. For example, this is an error:

(set-logic QF_LIRA)
(declare-fun a () Bool)
(declare-fun b () Real)
(assert (= a b))
(check-sat)

However, I expected this to be likewise an error:

(set-logic QF_LIRA)
(declare-fun a () Int)
(declare-fun b () Real)
(assert (= a b))
(check-sat)

But Yices and Z3 both accept it without complaint.

What am I missing?

问题回答

Strictly speaking, such mixing-and-matching is not allowed by SMTLib. (See page 37 of https://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2021-05-12.pdf, where it clearly states = must take two arguments of the same sort.)

However, most solvers are "lenient" in their processing; i.e., they introduce coercions when they think it "makes sense." I personally find that problematic: Coercions are hardly ever useful (especially in a language that s meant to be generated by tools in general), and sometimes they can hide bugs where the user wanted to say one thing but said the wrong thing, and the system somehow assigned a meaning to it. (You can compare this to mixing and matching of arithmetic with different types in many programming languages. But I digress.)

Having said that, cvc5 does better, if you ask it to:

$ cvc5 --strict-parsing a.smt2
(error "Parse Error: a.smt2:4.15: Subexpressions must have the same type:
Equation: (= a b)
Type 1: Int
Type 2: Real
")

Note that I explicitly had to pass --strict-parsing argument, as it also inserts the coercion without that flag.

My personal opinion is that they should all do this sort of strict parsing; but the state of the affairs is that most solvers introduce these coercions leading to confusion at best, and hiding bugs at worst.





相关问题
Are Int and Real somehow compatible in SMT-LIB?

The equality operator in SMT-LIB generally requires, unsurprisingly, that its operands be of the same type. For example, this is an error: (set-logic QF_LIRA) (declare-fun a () Bool) (declare-fun b () ...

Z3: Extracting existential model-values

I m playing around with Z3 s QBVF solver, and wondering if it s possible to extract values from an existential assertion. To wit, let s say I have the following: (assert (exists ((x (_ BitVec 16))) (...

Can Z3 be used to reason about substrings?

I am trying to use Z3 to reason about substrings, and have come across some non-intuitive behavior. Z3 returns sat when asked to determine if xy appears within xy , but it returns unknown when ...

Labeling Z3 scopes and popping back to a specific one

Is it possible to label Z3 scopes (SMTLib2 syntax) and to then pop back to a specific one? For example: (push foo) ; ... (push) ; ... (pop foo) ; pops two scopes I know that I can pop two scopes ...

Has anyone tried proving Z3 with Z3 itself?

Has anyone tried proving Z3 with Z3 itself? Is it even possible, to prove that Z3 is correct, using Z3? More theoretical, is it possible to prove that tool X is correct, using X itself?

Which statistics indicate an efficient run of Z3?

The SMTLib2 directive (get-info all-statistics) displays several numbers, e.g. num. conflicts: 4 num. propagations: 0 (binary: 0) num. qa. inst: 23 In order to test different ...

Mismatched DLL versions?

I am trying to use the Z3 SMT solver for my projects. However it seems there is a mismatch of the Visual Studio versions, which caused my troubles. My Visual Studio 2008 reports that The ...

热门标签