Conjunctive normal form
Lax429075.CNF · concepts/Lax429075/CNF.lean · lax-429075
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A literal names a natural-number variable and its sign. A CNF formula is a list of clauses, each a list of literals. Empty clauses are false and the empty conjunction is true. Satisfiability quantifies over Boolean assignments.
Concept map
In the paper
- page 1 of this submission's paper
Lean source view on GitHub
| 1 | import Lax434930.PolynomialTime |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Conjunctive normal form |
| 6 | type: definition |
| 7 | --- |
| 8 | A literal names a natural-number variable and its sign. A CNF formula is a |
| 9 | list of clauses, each a list of literals. Empty clauses are false and the |
| 10 | empty conjunction is true. Satisfiability quantifies over Boolean assignments. |
| 11 | -/ |
| 12 | |
| 13 | namespace Lax429075.CNF |
| 14 | |
| 15 | structure Literal where |
| 16 | index : ℕ |
| 17 | positive : Bool |
| 18 | deriving DecidableEq |
| 19 | |
| 20 | abbrev Clause := List Literal |
| 21 | abbrev Formula := List Clause |
| 22 | abbrev Assignment := ℕ → Bool |
| 23 | |
| 24 | def Literal.eval (l : Literal) (ρ : Assignment) : Bool := |
| 25 | if l.positive then ρ l.index else !(ρ l.index) |
| 26 | |
| 27 | def eval (F : Formula) (ρ : Assignment) : Bool := |
| 28 | F.all fun C => C.any fun l => l.eval ρ |
| 29 | |
| 30 | def Satisfiable (F : Formula) : Prop := ∃ ρ, eval F ρ = true |
| 31 | |
| 32 | end Lax429075.CNF |
| 33 |
Builds on
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments