K
K
Kalombyr2019-07-23 13:38:01
Algorithms
Kalombyr, 2019-07-23 13:38:01

Is there a ready-made library or algorithm for turning an if statement into a CNF formula?

Good day!
The SAT solver needs formulas in CNF format, i.e.:

(a | b | c) &
(a | !d ) &
(a | !c )

those. we can use only "and" "or" "not", and in each line there are OR variables, and each line is combined as AND, well, only a variable can be negated.
How can I convert these conditions:
if ( (a && b && c) || (c && d && f) || )
You need either an algorithm, or ideally a ready-made library, please tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lorc, 2019-07-23
@Kalombyr

Well actually algorithm directly in Wikipedia is described.
If there are not very many terms, you can try to apply the Quine-McCluskey method . Thus, you will kill two birds with one stone - you will get not just CNF, but the minimum CNF.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question