ekmett / ersatz

A monad for interfacing with external SAT solvers
Other
62 stars 15 forks source link

fusing `And` nodes prevents propagation in the solver? #88

Open jwaldmann opened 4 months ago

jwaldmann commented 4 months ago

The example is from #87. I am not quite sure whether to following analysis is correct.

Ersatz will fuse And [And [x,y], z] into And [x,y,z]. This reduces the number of Tseitin variables (and of clauses). But - if a fused sub-expression was shared, then this information is lost - while it might have been helpful for inference (in the solver).

Example: Bits xs + Bits ys <? 2: we get the following graph (with black and red edges)

bits

if the root is asserted, then I think we can't propagate much. But - after we apply the following equivalence transformation: remove red edges, add blue edge, we can:

Comment: perhaps And [And [x,y], z] is fine. It's a larger CNF, but everything that can be inferred, can be inferred by unit propagation, and the SAT solver is good at this.

I will patch a version of Ersatz without And fusion, and compare.