Skip to content
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

coprocessor produces empty CNF #13

Open
max-waters opened this issue Aug 6, 2018 · 6 comments
Open

coprocessor produces empty CNF #13

max-waters opened this issue Aug 6, 2018 · 6 comments

Comments

@max-waters
Copy link

max-waters commented Aug 6, 2018

Sometimes the simplified CNF produced by coprocessor is empty. I don't know how to interpret this result.

For example, here's a very simple CNF:

p cnf 3 3
1 -2 -3 0
-1 2 -3 0
-1 -2 3 0

Run the command:

./coprocessor -dimacs=preprocessed -enabled_cp3 -ppOnly -rate input

The contents of the file preprocessed is simply:

p cnf 3 0

Is it an error? Or does it imply that input cannot be simplified?

@conp-solutions
Copy link

Hi,

a produced empty formula means that Coprocessor was able to show that the formula was satisfiable. With the help of the undo information (see e.g. the scripts/cp.sh script), a model can be constructed.

Best,
Norbert

PS: I moved the source here: https://github.com/conp-solutions/riss and will likely remove this repository soonish.

@max-waters
Copy link
Author

I see, thanks -- the empty CNF has a single empty model, which is translated back into a model of the original input.

So this means that the undo process is not just a matter of variable substitution. In order to translate a preprocessed model, coprocessor must solve another CNF, right?

@conp-solutions
Copy link

conp-solutions commented Aug 8, 2018

An empty CNF might have multiple solutions (depending on the "p cnf" line). The undo information is used to transform the model for the simplified formula back into a model for the original formula. This process is polynomial, basically equivalent to

  1. rename the variables back to their original
  2. Apply the truth assignment that has been found for the original formula during simplification
  3. Satisfy the clauses in the undo.info file, basically by checking whether the clause for being satisfied already, or satisfying the very first literal in the clause

As this stack is constructed such that the above algorithm results in a model of the simplified formula, this procedure is polynomial. Note, two different models for the simplified formula might result in the same for the original one. That heavily depends on the simplification techniques that have been applied. While all techniques preserve satisfiability, some of them do not preserve equivalence (ignoring renaming for simplicity), so the number of models for the simplified and original formula might differ a lot.

@max-waters
Copy link
Author

That's interesting. When I run minisat over an empty CNF, it always returns an empty answer v 0. But of course it makes more sense that the empty CNF, say, p cnf 3 0 is actually satisfied by any of the 2^3 combinations of the three literals.

@conp-solutions
Copy link

Yeah, that's a problem with MiniSat handling input formulas. It only treats variables it spots in the formula during parsing. I just fixed my MiniSat fork wrt this behaviour:

https://github.com/conp-solutions/minisat

@conp-solutions
Copy link

Variables are dropped from the mapping, if they do not occur in the formula any more (except the variables of the whileList file).

A variable is also dropped in case Coprocessor was able to find a unique mapping for a variable (resolved it as unit clause). To keep those variables, another flag has to be set. The following combination worked for me during experiments with a small example formula:

-dense -cp3_keep_set

To be honest, the implementation details of most CNF simplifications are not really documented. There are papers about the technique, but that's about it (sorry for that. Running with the -*-debug options with coprocessor should help a lot).

BTW: please make sure you use the more recent variant of Coprocessor. I fix bugs only in the other repository.

Best,
Norbert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants