This directory contains example input and output files demonstrating the unit propagation algorithm.
.infiles: Input clauses in CNF format (one clause per line, literals separated by spaces).outfiles: Expected output showing discovered unit clauses in lexicographical order
Basic example showing cascading unit propagation.
Input:
a b
-a c
-c d
a
Explanation:
- Initial unit clause:
a - Propagating
aremoves clauses 1 and 4, and removes-afrom clause 2, creating unit clausec - Propagating
cremoves clause 2 and removes-cfrom clause 3, creating unit claused
Output: a c d
Example that produces an empty clause (unsatisfiable).
Input:
a b
-b
b -a
Explanation:
- Initial unit clause:
-b - Propagating
-bremovesbfrom clauses, eventually producing an empty clause
Output: - (indicates contradiction)
Multiple initial unit clauses that don't interact.
Input:
x
y z
-y
Explanation:
- Initial unit clauses:
xand-y - Propagating
-yremoves it from clause 2, creating unit clausez
Output: x y z
Demonstrates a chain reaction of unit propagations.
Input:
a b c
-a d e
-d f
b
Explanation:
bis a unit clause- Propagating
bremoves clause 1 - Propagating
-afrom clause 2 producesdandeas units - Propagating
dremoves clause 2 and producesffrom clause 3
Output: b d e f
Verifies that output is sorted lexicographically.
Input:
p q
-p r
q
-r s
Explanation:
- Unit clauses discovered:
q,r,s - Must be output in alphabetical order
Output: q r s
Example with both positive and negated literals.
Input:
a -b
c
-a d
Explanation:
- Initial unit clause:
c - Propagating
-aproducesdas a unit clause
Output: c d
cd LogicDirPolynomial
make
./dpll-polynomial < ../examples/simple_propagation.incd LogicDirLinear
make
./dpll-linear < ../examples/simple_propagation.in# From project root
for test in examples/*.in; do
echo "Testing: $test"
cd LogicDirPolynomial
./dpll-polynomial < ../$test
cd ..
done- Normal output: Space-separated list of unit clauses in lexicographical order
- Contradiction: Single dash
-indicates an empty clause was produced - No output: No unit clauses were found (shouldn't happen with these examples)
- Create a
.infile with your CNF clauses (one per line) - Run it through either implementation
- Verify the output matches your expectations
- Create a corresponding
.outfile with the expected result
Remember:
- Each clause is a disjunction (OR) of literals
- The entire formula is a conjunction (AND) of clauses
- Literals starting with
-are negated - Unit clauses have only one literal