Closed x-moe-x closed 7 years ago
Has to be fixed in the parser, the translation does not handle precedences
The assumption is wrong that the second formula is satisfiable. 'or' and '&' both have priority 40. Hence, TRUE or FALSE & FALSE is equivalent to (TRUE or FALSE) & FALSE which is obviously unsatisfiable.
Wikipedia says it might have the same priority in some compilers. For convenience I suggest giving &
a higher priority even if it's not striclty necessary.
Operator priorities differ in different formal languages. The B reference manual (page 187 and following) says that both operators have the same priority. In order to be compatible with other tools for the B language we can't change these priorities. I personally prefer the way TLA+ handles priorities by reporting a "Precedence conflict between operators" while evaluating the formula "TRUE or FALSE & FALSE".
I think we could add a warning in this case as well?
Yes, we can add a warning as we have a concrete syntax tree as well.
Given two formulas
TRUE or (FALSE & FALSE)
TRUE or FALSE & FALSE
which should be obviously satisfiable,
FormulaToZ3Translator::translatePredicate(...)
builds the following:(or true (and false false))
(and (or true false) false)
This evaluates to
SAT
for 1. andUNSAT
for 2.