https://github.com/j-christl/dpllsatsolver
Simple Java implementation of the Davis–Putnam–Logemann–Loveland (DPLL) algorithm
https://github.com/j-christl/dpllsatsolver
algorithm algorithms discrete-mathematics dpll dpll-algorithm java math mathematics sat-solver
Last synced: 3 days ago
JSON representation
Simple Java implementation of the Davis–Putnam–Logemann–Loveland (DPLL) algorithm
- Host: GitHub
- URL: https://github.com/j-christl/dpllsatsolver
- Owner: j-christl
- Created: 2018-02-18T23:58:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-19T17:29:06.000Z (over 7 years ago)
- Last Synced: 2025-04-09T17:14:27.286Z (2 months ago)
- Topics: algorithm, algorithms, discrete-mathematics, dpll, dpll-algorithm, java, math, mathematics, sat-solver
- Language: Java
- Size: 10.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DpllSatSolver
Simple Java implementation of the Davis–Putnam–Logemann–Loveland (DPLL) algorithm ( https://en.wikipedia.org/wiki/DPLL_algorithm ) including OLR (one-literal-rule) and PLR (pure-literal-rule)## Example
```
f := (¬p ∨ q ∨ ¬r ∨ s) ∧ (¬q ∨ ¬r ∨ s) ∧ (r) ∧ (¬p ∨ ¬s) ∧ (¬p ∨ r)
```
Checking if the formula f is satisfiable can be done by using
```java
String[][] formula = {{"-p", "q", "-r", "s"}, {"-q", "-r", "s"}, {"r"}, {"-p", "-s"}, {"-p", "r"}};
DpllResult result = Dpll.solve(new Formula(formula));if(result != null) {
System.out.println("Satisfiable! Took " + result.getTimeTaken() + "ms.");
System.out.println(result);
} else {
System.out.println("Not satisfiable!");
}```
Disabling the output can be done by using
```java
Dpll.disableLog()
```## Output
Executing the above code results in the following output```
Formula CNF: (¬p ∨ q ∨ ¬r ∨ s) ∧ (¬q ∨ ¬r ∨ s) ∧ (r) ∧ (¬p ∨ ¬s) ∧ (¬p ∨ r)
Solving formula with 5 clauses and 4 literals:
As set of clauses: { {¬p, q, ¬r, s}, {¬q, ¬r, s}, {r}, {¬p, ¬s}, {¬p, r} }
OLR: r => true
[L] r:= true ( )
Solving formula with 3 clauses and 3 literals:
As set of clauses: { {¬p, q, s}, {¬q, s}, {¬p, ¬s} }
PLR: p => false
[R] p:= false ( r=true )
Solving formula with 1 clauses and 2 literals:
As set of clauses: { {¬q, s} }
PLR: q => false
[R] q:= false ( p=false r=true )
Solving formula with 0 clauses and 0 literals:
As set of clauses: { }
Satisfiable! Took 6ms.
p -> 0, q -> 0, r -> 1
```## Note
'-' is used instead of '¬'