Correctness of the Algorithm
Lax117284.TwoSatCorrectness · concepts/Lax117284/TwoSatCorrectness.lean · lax-117284
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Theorem
The algorithm accepts a formula exactly when it is in 2-CNF and satisfiable.
Concept map
Lean source view on GitHub
| 1 | import Lax117284.TwoSatAlgorithm |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Correctness of the Algorithm |
| 6 | type: theorem |
| 7 | --- |
| 8 | The algorithm accepts a formula exactly when it is in 2-CNF and satisfiable. |
| 9 | |
| 10 | # Formalization Notes |
| 11 | |
| 12 | The width check accepts exactly the 2-CNF formulas without an empty clause, and the search, by |
| 13 | the criterion, rejects exactly the formulas with a contradictory variable. Two points connect |
| 14 | the search to the criterion. The set the search computes is the set of literals reachable within |
| 15 | the nodes, and reachability in the whole graph from a literal that occurs stays within the |
| 16 | nodes, since every edge joins two literals of one clause. And it suffices to test the variables |
| 17 | that occur, since a variable that does not occur has no edges at either of its literals and so is |
| 18 | never contradictory. |
| 19 | -/ |
| 20 | |
| 21 | namespace Lax117284.TwoSatCorrectness |
| 22 | |
| 23 | open Lax429075.CNF Lax117284.TwoSatCNF Lax117284.TwoSatAlgorithm |
| 24 | |
| 25 | /-- **The algorithm is correct.** -/ |
| 26 | axiom decide_iff (F : Formula) : decide F = true ↔ IsTwoCNF F ∧ Satisfiable F |
| 27 | |
| 28 | end Lax117284.TwoSatCorrectness |
| 29 |
Formalization Notes
The width check accepts exactly the 2-CNF formulas without an empty clause, and the search, by the criterion, rejects exactly the formulas with a contradictory variable. Two points connect the search to the criterion. The set the search computes is the set of literals reachable within the nodes, and reachability in the whole graph from a literal that occurs stays within the nodes, since every edge joins two literals of one clause. And it suffices to test the variables that occur, since a variable that does not occur has no edges at either of its literals and so is never contradictory.
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments