satisfiability

ANTLR - Boolean satisfiabilty

时光总嘲笑我的痴心妄想 提交于 2019-12-12 22:43:02
问题 I have a ANTLR expression parser which can evaluate expressions of the form ( A & ( B | C ) ) using the generated visitor. A , B and C can take any of the 2 values true or false . However I am faced with a challenge of finding all combinations of A,B and C for which the expression is true. I tried to solve this by the following method. Evaluate the expression for the 3 variables taking true and false each This comes to 8 combinations since 2 ^ 3 is 8 I evaluate giving values like 000, 001,

Converter from SAT to 3-SAT

十年热恋 提交于 2019-12-11 09:39:25
问题 Does anyone know of a good program to convert CNF files with any number of variables per clause to CNF files with exactly 3 variables per clause (3-CNF)? I've seen this algorithm in computer science books but can't find an implementation anywhere and would hate to waste time implementing it myself if others have already done it. Thanks! 回答1: I didn't know any program to do that either, but the algorithm is really simple so just I wrote the following python script (download) that reads a

Verify Combinatorial CNF SAT Encodings?

大城市里の小女人 提交于 2019-12-11 08:14:16
问题 I am trying to solve a combinatorial problem by using a SAT Solver. This involves the following steps: Encode the problem as set of boolean expressions. Translate a conjunction of the expressions into CNF/DIMACS (using home grown tools, bc2cnf, bool2cnf or Limboole) Solve the CNF (using SAT Solvers like Cryptominisat, Plingeling, Clasp or Z3) Translate the solution (assuming a "SAT" result) back into the problem domain This works in my case for small samples. But for more challenging ones,

Convert Boolean FlatZinc to CNF DIMACS

假如想象 提交于 2019-12-03 14:24:27
To solve a set of Boolean equations , I am experimenting with the Constraint-Programming Solver MiniZinc using the following input: % Solve system of Brent's equations modulo 2 % Matrix dimensions int: aRows = 3; int: aCols = 3; int: bCols = 3; int: noOfProducts = 23; % Dependent parameters int: bRows = aCols; int: cRows = aRows; int: cCols = bCols; set of int: products = 1..noOfProducts; % Corefficients are stored in arrays array[1..aRows, 1..aCols, products] of var bool: A; array[1..bRows, 1..bCols, products] of var bool: B; array[1..cRows, 1..cCols, products] of var bool: C; constraint

SAT solving with haskell SBV library: how to generate a predicate from a parsed string?

自作多情 提交于 2019-11-27 14:08:28
问题 I want to parse a String that depicts a propositional formula and then find all models of the propositional formula with a SAT solver. Now I can parse a propositional formula with the hatt package; see the testParse function below. I can also run a SAT solver call with the SBV library; see the testParse function below. Question: How do I, at runtime, generate a value of type Predicate like myPredicate within the SBV library that represents the propositional formula I just parsed from a String