-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaying a goal as DIMACS does not effectively require calling the tseitin-cnf tactic, although it should #6577
Comments
so far a couple of bugs fixes based on your post. Regarding general behavior: it is allowed to create CNF of non-propositional formulas. To make this work I append a comment section with definitions. The definitions are for diagnostic purposes: they list the function symbol and nothing more. |
thanks for the quick fix! |
I have another question (or maybe bug): In the latest version 4.12.1, calling
In version 4.11.2, this worked fine. Is this intended? I am now using |
- enforce elim-and in bool-rewriter when invoking hoisting. - make cnf tactic more resilient to non-normalized input. - enable eliminate predicates on ground formulas
You should use
This produces better CNF than default. I fixed some of the fragility issues so you don't have to use simplification. |
Hi, please consider the following SMTlib file:
throws for both goal_1 and goal_2:
Can you tell me what I am doing wrong? The file only uses and, or, and not. We are out of ideas over at paulgazz/kmax/issues/226. |
Hi,
thanks for creating such a high-quality SMT solver! However, I believe I found a bug related to CNF representations (I reproduced it in z3 4.11.2 and 4.12.1).
I am using Z3 to transform Boolean formulas into CNF using its
tseitin-cnf
tactic. The simplest Python code I found to do that is this:This works reliably.
However, when the second-to-last line is omitted (e.g., forgotten), things get weird.
This sample input:
is (correctly) transformed into the following when the Tseitin tactic is applied:
(that is, the formula is an obvious contradiction), but it is (wrongly) transformed into the following when the Tseitin tactic is not applied:
which is satisfiable, although it should not be (the inner
and
expression that violates CNF is not represented correctly).For larger formulas (e.g., the feature dependencies in the Linux kernel 2.6.12), this creates the impression that Z3 creates a correct CNF, although it doesn't (satisfiability is not generally preserved, as shown above).
It can be argued that this is simply the wrong way to call the Z3 library. However, the fact that the user has to apply the Tseitin tactic explicitly is not very well-documented, and one would expect a helpful error message instead of returning an incorrect DIMACS file.
In fact, it seems that raising an error is also the intended behavior, as there is a check for CNF before printing a goal as DIMACS: https://github.com/Z3Prover/z3/blob/master/src/api/api_goal.cpp#L200
So, my guess is that
goal::is_cnf
contains a bug, which only detects a violation of CNF in some, but not all cases (e.g., it does not detect that(assert (and (or (not X)) (or (and X (not X)))
is not in CNF, but it does for(assert (and (or (and X (not X)))
).As a casual user of the library, it is easy to mistake the
c 2 and
variable above for a proper Tseitin skolem variable (k!0
in Z3) and believe that the CNF tactic was applied correctly. (Case in point is kmax, which does not apply the CNF tactic at all and therefore runs into this exact problem.)Maybe this can be improved so future users don't stumble like I did. Thanks!
The text was updated successfully, but these errors were encountered: