Conjunctive normal form
AbbreviationCNF clause#✓fully proved
A CNF clause is a finite list of literals, each a pair \((x, b)\) of a variable index \(x \in \mathbb{N}\) and a polarity \(b \in \{\mathrm{true}, \mathrm{false}\}\).
Used by 289
TM2 SAT verifier · Clause token length bound for the SAT verifier (moved alias) · 3SAT is in NP · Processing one clause in the 3-COLOR construction · The SAT-to-3-COLOR graph construction · Correctness of the reduction from SAT to 3-coloring · The construction's edges lie below its vertex count · The 3-COLOR emitter processes one clause · The emitter on a list of clauses · Correctness and step bound of the 3-COLOR emitter · Literal occurrences of a CNF formula · Karp's CLIQUE instance of a CNF formula · Karp's reduction from SAT to CLIQUE is correct · Membership in the literal occurrences of a CNF formula · Pair bits of a leading clause · Walked items of a formula · Occurrences of a formula with a first clause · Row bits of a formula for the CLIQUE emitter · The CLIQUE emitter's row bits are Karp's pair bits · Clique emitter: one clause · Emitter run over a formula's clauses · The CLIQUE emitter computes Karp's instance in cubic time · CLIQUE is NP-hard · Normal clause detours · Arcs of a variable diamond · Sipser's HAMPATH instance of a CNF formula · Hamiltonian paths of Sipser's graph have normal detours · Classification of the arcs of Sipser's graph · Out-neighbours of a clause vertex in Sipser's graph · Out-neighbours of a row vertex in Sipser's graph · Consecutive vertices of a Hamiltonian path of Sipser's graph form arcs · In-neighbours of a clause vertex in Sipser's graph · In-neighbours of a row vertex in Sipser's graph · A clause detour returns to its own pair (Sipser's separator argument) · A Hamiltonian path of Sipser's graph does not cross a diamond through one row end · A separator is next to each of its row neighbours on a Hamiltonian path · Arcs of the Hamiltonian path construction · The HAMPATH instance as unary blocks and arc bits · Clause detours in a diamond · Splitting off the middle clause of a concatenation · HAMPATH emitter, phase A: one clause · HAMPATH emitter, phase A: the clauses of a formula · One clause of the detour walk · The emitter state before the diamonds · The detour walk of a diamond in the HAMPATH emitter · Phase A of the HAMPATH emitter · End of a diamond · The detours of a diamond · One diamond · The diamonds · Correctness and running time of the HAMPATH emitter · In-neighbours of a row vertex outside the clause vertices · Consecutive vertices of the contracted path are joined by arcs · Deleting the clause vertices from a path · Satisfiable formulas give Hamiltonian paths (SAT ≤ HAMPATH, forward direction) · Arcs from a row into a clause vertex · Out-neighbours of a row vertex outside the clause vertices · Out-neighbours of a top · Contracting a clause detour · A satisfying choice gives a Hamiltonian path · The frame arcs of a diamond · The detour arcs of a negative occurrence · Positive detour arcs of a diamond · Row arcs of a diamond · Backward direction of SAT ≤ HAMPATH for paths with normal detours · Every vertex of the contracted path except its end has a successor · The construction has a Hamiltonian path iff the formula is satisfiable · Every top but the last is followed by an end of its row · Entering a row and leaving it at once is impossible · A row entered at one end is run to the other end · SAT ≤ HAMPATH preserves membership · The 1-in-3-SAT decision problem · Feasible 1-in-3-SAT instances · Well-formed 1-in-3-SAT instances · 3-SAT with bounded occurrences as a decision problem · Well-formed bounded-occurrence 3-SAT instances · The chain of clauses replacing one clause · Completeness of the chain of one clause · Soundness of the chain of one clause · The tail of a clause chain · Completeness of the tail of a chain · Soundness of the tail of a chain · A clause with more than three literals makes the capped 3SAT filter fail · The 3SAT filter walks one clause within the cap · The 3SAT emitter processes one clause · A long clause makes the capped 3SAT filter fail on a list of clauses · The 3SAT filter walks a list of clauses within the cap · CNF encodings are nonempty · The 3SAT emitter processes a whole formula · Values of the fresh variables in the 3SAT translation · Three-literal clause test · The SAT-to-3SAT translation yields clauses of length at most three · Chain clauses have at most three literals · Chain-tail clauses have at most three literals · Clauses of the auxiliary 3SAT translation have at most three literals · Output clause of one literal · One literal of the emitter · The literals of a clause in the emitter · The SAT-to-3SAT emitter writes the encoded translation in quadratic time · Correctness of the clause-length filter · Correctness of the SAT-to-3SAT reduction on bit strings · Clause-by-clause translation with a fresh-number counter · Completeness of the auxiliary 3SAT translation · Soundness of the auxiliary 3SAT translation · Fresh variables reserved for a clause · Output clauses of a walked list of literals · Walking a whole clause gives its chain · MAXIMUM 2-SATISFIABILITY as a decision problem · Feasible MAX-2SAT instances · Well-formed MAX-2SAT instances · MAXIMUM SATISFIABILITY as a decision problem · Feasible MAX-SAT instances · Well-formed MAX-SAT instances · The MINIMUM 2-SATISFIABILITY decision problem · Feasible MINIMUM 2-SATISFIABILITY instances · Well-formed MINIMUM 2-SATISFIABILITY instances · The MINIMUM ONES 3-SAT decision problem · Well-formed MINIMUM ONES 3-SAT instances · MONOTONE 3-SAT as a decision problem · Well-formed monotone 3-SAT instances · NOT-ALL-EQUAL 3-SAT as a decision problem · Not-all-equal satisfiability of an instance · Well-formed NOT-ALL-EQUAL 3-SAT instances · Value of a MAX-3SAT assignment · The MAX-3SAT objective · 2-SAT as a decision problem · SAT with a unary variable count as a decision problem · UniqueSAT with a unary variable count as a decision problemAbbreviationCNF formula#✓fully proved
A CNF formula is a finite list of CNF clauses, read as the conjunction of its clauses.
abbrev CNF := List CNFClause
abbrev CNFClause := List (Nat × Bool)
CSLibExt/Logics/Propositional/CNF/Basic.lean:30
Uses 1 · Used by 329
TM2 SAT verifier · Answer of the SAT host with the three-literal filter · 3SAT is in NP · Token length bound for the SAT verifier (moved alias) · The SAT-to-3-COLOR graph construction · The SAT to 3-COLOR reduction map on bit strings · The 3-COLOR instance of a CNF formula · Correctness of the reduction from SAT to 3-coloring · The construction's edges lie below its vertex count · Correctness of the SAT to 3-COLOR map on bit strings · The emitter on a list of clauses · Correctness and step bound of the 3-COLOR emitter · The 3-COLOR emitter · The SAT-to-3-COLOR reduction is polynomial-time · Adjacency bits of Karp's clique graph · Literal occurrences of a CNF formula · Karp's SAT-to-CLIQUE map on bit strings · Karp's CLIQUE instance of a CNF formula · Karp's reduction from SAT to CLIQUE is correct · Membership in the literal occurrences of a CNF formula · SAT decision on undecodable input (moved alias) · Adjacency in Karp's clique graph · Pair bits of a leading clause · Walked items of a formula · Occurrences of a formula with a first clause · Row bits of a formula for the CLIQUE emitter · The CLIQUE emitter's row bits are Karp's pair bits · Clique emitter: one clause · Emitter run over a formula's clauses · The CLIQUE emitter computes Karp's instance in cubic time · The CLIQUE emitter · SAT ≤ CLIQUE is polynomial-time · CLIQUE is NP-hard · Normal clause detours · Arcs of a variable diamond · Arcs of the HAMPATH construction · Distinct variables of a formula · The SAT-to-HAMPATH reduction map · Sipser's HAMPATH instance of a CNF formula · Hamiltonian paths of Sipser's graph have normal detours · Classification of the arcs of Sipser's graph · Out-neighbours of a clause vertex in Sipser's graph · Out-neighbours of a row vertex in Sipser's graph · Consecutive vertices of a Hamiltonian path of Sipser's graph form arcs · In-neighbours of a clause vertex in Sipser's graph · In-neighbours of a row vertex in Sipser's graph · A clause detour returns to its own pair (Sipser's separator argument) · A Hamiltonian path of Sipser's graph does not cross a diamond through one row end · A separator is next to each of its row neighbours on a Hamiltonian path · Arcs of the Hamiltonian path construction · The HAMPATH instance as unary blocks and arc bits · Splitting off the middle clause of a concatenation · HAMPATH emitter, phase A: the clauses of a formula · The emitter state before the diamonds · The detour walk of a diamond in the HAMPATH emitter · Initial state of the HAMPATH emitter · Phase A of the HAMPATH emitter · End of a diamond · The detours of a diamond · One diamond · The diamonds · Correctness and running time of the HAMPATH emitter · In-neighbours of a row vertex outside the clause vertices · Consecutive vertices of the contracted path are joined by arcs · Deleting the clause vertices from a path · Satisfiable formulas give Hamiltonian paths (SAT ≤ HAMPATH, forward direction) · Arcs from a row into a clause vertex · Out-neighbours of a row vertex outside the clause vertices · Out-neighbours of a top · Contracting a clause detour · A satisfying choice gives a Hamiltonian path · The frame arcs of a diamond · The detour arcs of a negative occurrence · Positive detour arcs of a diamond · Row arcs of a diamond · Diamond arcs are arcs of the construction · Backward direction of SAT ≤ HAMPATH for paths with normal detours · Every vertex of the contracted path except its end has a successor · The construction has a Hamiltonian path iff the formula is satisfiable · Every top but the last is followed by an end of its row · Positions in the list of distinct variables · Entering a row and leaving it at once is impossible · A row entered at one end is run to the other end · SAT ≤ HAMPATH preserves membership · The HAMPATH emitter · SAT ≤ HAMPATH is polynomial-time · The 1-in-3-SAT decision problem · Feasible 1-in-3-SAT instances · 1-in-3-SAT instances · Well-formed 1-in-3-SAT instances · 3-SAT with bounded occurrences as a decision problem · Satisfiable bounded-occurrence 3-SAT instances · Bounded-occurrence 3-SAT instances · Well-formed bounded-occurrence 3-SAT instances · The chain of clauses replacing one clause · Completeness of the chain of one clause · Soundness of the chain of one clause · The tail of a clause chain · Completeness of the tail of a chain · Soundness of the tail of a chain · The 3SAT emitter processes one clause · The SAT-to-3SAT translation preserves satisfiability · The SAT-to-3SAT emitter · Emitter · CNF encodings are nonempty · The 3SAT emitter processes a whole formula · Values of the fresh variables in the 3SAT translation · The SAT-to-3SAT reduction is polynomial-time · Three-literal clause test · The SAT-to-3SAT translation yields clauses of length at most three · Chain clauses have at most three literals · Chain-tail clauses have at most three literals · Clauses of the auxiliary 3SAT translation have at most three literals · Lifting an assignment to the 3SAT translation · The lifted assignment on fresh variables · The lifted assignment on renamed variables · The literals of a clause in the emitter · Output of an emitter on a bit string · The SAT-to-3SAT reduction on bit strings · The SAT-to-3SAT emitter writes the encoded translation in quadratic time · Correctness of the clause-length filter · Tokenize, then emit · Correctness of the SAT-to-3SAT reduction on bit strings · The 3SAT decision problem · The SAT-to-3SAT translation · Clause-by-clause translation with a fresh-number counter · Completeness of the auxiliary 3SAT translation · Soundness of the auxiliary 3SAT translation · Output clauses of a walked list of literals · Walking a whole clause gives its chain · MAXIMUM 2-SATISFIABILITY as a decision problem · Feasible MAX-2SAT instances · MAX-2SAT instances · Well-formed MAX-2SAT instances · MAXIMUM SATISFIABILITY as a decision problem · Feasible MAX-SAT instances · MAX-SAT instances · Well-formed MAX-SAT instances · The MINIMUM 2-SATISFIABILITY decision problem · Feasible MINIMUM 2-SATISFIABILITY instances · MINIMUM 2-SATISFIABILITY instances · Well-formed MINIMUM 2-SATISFIABILITY instances · The MINIMUM ONES 3-SAT decision problem · Feasible MINIMUM ONES 3-SAT instances · MINIMUM ONES 3-SAT instances · Well-formed MINIMUM ONES 3-SAT instances · MONOTONE 3-SAT as a decision problem · Satisfiable monotone 3-SAT instances · Monotone 3-SAT instances · Well-formed monotone 3-SAT instances · NOT-ALL-EQUAL 3-SAT as a decision problem · Not-all-equal satisfiability of an instance · NOT-ALL-EQUAL 3-SAT instances · Well-formed NOT-ALL-EQUAL 3-SAT instances · Value of a MAX-3SAT assignment · The MAX-3SAT objective · 2-SAT as a decision problem · SAT with a unary variable count as a decision problem · UniqueSAT with a unary variable count as a decision problemDefinitionSatisfiability of a CNF formula#✓fully proved
A CNF formula \(\varphi\) is satisfiable when there is an assignment \(v : \mathbb{N} \to \{\mathrm{true}, \mathrm{false}\}\) such that every clause \(C\) of \(\varphi\) contains a literal \((x, b)\) with \(v(x) = b\).
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 2 · Used by 41
DefinitionSatisfaction of a literal#✓fully proved
An assignment \(v : \mathbb{N} \to \{\mathrm{true}, \mathrm{false}\}\) satisfies a literal \((x, b)\), with variable \(x \in \mathbb{N}\) and polarity \(b \in \{\mathrm{true}, \mathrm{false}\}\), when \(v(x) = b\).
def Satisfies (assignment : Nat → Bool) (literal : Nat × Bool) : Prop :=
assignment literal.1 = literal.2
Used by 31
DefinitionSatisfaction of a clause#✓fully proved
An assignment \(v : \mathbb{N} \to \{\mathrm{true}, \mathrm{false}\}\) satisfies a CNF clause \(C\) when at least one literal of \(C\) is satisfied by \(v\), that is, \(C\) contains a literal \((x, b)\) with \(v(x) = b\).
def Satisfies (assignment : Nat → Bool) (clause : CNFClause) : Prop :=
∃ literal ∈ clause, CNFLiteral.Satisfies assignment literal
abbrev CNFClause := List (Nat × Bool)
CSLibExt/Logics/Propositional/CNF/Basic.lean:30
def Satisfies (assignment : Nat → Bool) (literal : Nat × Bool) : Prop :=
assignment literal.1 = literal.2
CSLibExt/Logics/Propositional/CNF/Semantics.lean:32
Uses 2 · Used by 49
DefinitionSatisfaction of a CNF formula#✓fully proved
An assignment \(v : \mathbb{N} \to \{\mathrm{true}, \mathrm{false}\}\) satisfies a CNF formula \(\varphi\) when \(v\) satisfies every clause of \(\varphi\).
def Satisfies (assignment : Nat → Bool) (formula : CNF) : Prop :=
∀ clause ∈ formula, CNFClause.Satisfies assignment clause
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def Satisfies (assignment : Nat → Bool) (clause : CNFClause) : Prop :=
∃ literal ∈ clause, CNFLiteral.Satisfies assignment literal
CSLibExt/Logics/Propositional/CNF/Semantics.lean:45
Uses 3 · Used by 56
TheoremSatisfiability means having a satisfying assignment#✓fully proved
A CNF formula \(\varphi\) is satisfiable if and only if there is an assignment \(v : \mathbb{N} \to \{\mathrm{true}, \mathrm{false}\}\) that satisfies \(\varphi\).
theorem cnfSat_iff_exists_satisfies {formula : CNF} :
CNFSat formula ↔ ∃ assignment, formula.Satisfies assignment
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
Uses 6 · Used by 15
DefinitionDisjunction of two CNFs#✓fully proved
For CNFs \(\varphi = C_1 \land \dots \land C_m\) and \(\psi = D_1 \land \dots \land D_n\), their disjunction is the CNF with one clause \(C_i \lor D_j\) (the literals of \(C_i\) followed by those of \(D_j\)) for each pair \((i, j)\), listed with \(i\) as the outer and \(j\) as the inner index. It expresses \((\bigwedge_i C_i) \lor (\bigwedge_j D_j)\) as \(\bigwedge_{i,j} (C_i \lor D_j)\).
def disj (φ ψ : CNF) : CNF := φ.flatMap fun C ↦ ψ.map fun D ↦ C ++ D
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 2 · Used by 3
DefinitionAccumulating CNF builder#✓fully proved
Let \(\iota\) number the atoms by natural numbers, read a literal \((n, p)\) as variable \(n\) with polarity \(p\), and write \(1\) and \(0\) for the polarities true and false. For a polarity \(p\), a proposition \(\varphi\) and a CNF \(S\), the CNF \(\mathcal{A}_p(\varphi, S)\) is defined by recursion on \(\varphi\), together with the disjoining builder \(\mathcal{O}_p\). For an atom \(a\), \(\mathcal{A}_p(a, S)\) is the unit clause \([(\iota(a), p)]\) followed by the clauses of \(S\). Conjunction-like nodes thread the accumulator: \(\mathcal{A}_1(A \land B, S) = \mathcal{A}_1(A, \mathcal{A}_1(B, S))\), \(\mathcal{A}_0(A \lor B, S) = \mathcal{A}_0(A, \mathcal{A}_0(B, S))\) and \(\mathcal{A}_0(A \to B, S) = \mathcal{A}_1(A, \mathcal{A}_0(B, S))\). Disjunction-like nodes go through \(\mathcal{O}\): writing \(X \mathbin{+\!\!+} S\) for the clauses of \(X\) followed by those of \(S\) and \([\,]\) for the empty CNF, \(\mathcal{A}_1(A \lor B, S) = \mathcal{O}_1(A, \mathcal{A}_1(B, [\,])) \mathbin{+\!\!+} S\), \(\mathcal{A}_1(A \to B, S) = \mathcal{O}_0(A, \mathcal{A}_1(B, [\,])) \mathbin{+\!\!+} S\) and \(\mathcal{A}_0(A \land B, S) = \mathcal{O}_0(A, \mathcal{A}_0(B, [\,])) \mathbin{+\!\!+} S\).
An assignment \(\sigma\) satisfies \(\mathcal{A}_p(\varphi, S)\) exactly when \(\varphi\) has truth value \(p\) under \(\sigma \circ \iota\) and \(\sigma\) satisfies \(S\).
def cnfAcc (ι : Atom → ℕ) : Bool → Proposition Atom → CNF → CNF
| pos, atom a, acc => [(ι a, pos)] :: acc
| true, and A B, acc => cnfAcc ι true A (cnfAcc ι true B acc)
| false, or A B, acc => cnfAcc ι false A (cnfAcc ι false B acc)
| false, imp A B, acc => cnfAcc ι true A (cnfAcc ι false B acc)
| true, or A B, acc => cnfOr ι true A (cnfAcc ι true B []) ++ acc
| true, imp A B, acc => cnfOr ι false A (cnfAcc ι true B []) ++ acc
| false, and A B, acc => cnfOr ι false A (cnfAcc ι false B []) ++ acc
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def cnfOr (ι : Atom → ℕ) : Bool → Proposition Atom → CNF → CNF
| true, or A B, S => cnfOr ι true A (cnfOr ι true B S)
| true, imp A B, S => cnfOr ι false A (cnfOr ι true B S)
| false, and A B, S => cnfOr ι false A (cnfOr ι false B S)
| pos, atom a, S => CNF.disj [[(ι a, pos)]] S
| true, and A B, S => CNF.disj (cnfAcc ι true A (cnfAcc ι true B [])) S
| false, or A B, S => CNF.disj (cnfAcc ι false A (cnfAcc ι false B [])) S
| false, imp A B, S => CNF.disj (cnfAcc ι true A (cnfAcc ι false B [])) S
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:115
Uses 3 · Used by 2
DefinitionDisjoining CNF builder#✓fully proved
Let \(\iota\) number the atoms by natural numbers, read a literal \((n, p)\) as variable \(n\) with polarity \(p\), and write \(1\) and \(0\) for the polarities true and false. For a polarity \(p\), a proposition \(\varphi\) and a CNF \(S\), the CNF \(\mathcal{O}_p(\varphi, S)\) is defined by recursion on \(\varphi\), together with the accumulating CNF builder \(\mathcal{A}_p\). Write \(X \otimes S\) for the disjunction of two CNFs \(X\) and \(S\) and \([\,]\) for the empty CNF. For an atom \(a\), \(\mathcal{O}_p(a, S) = U \otimes S\), where \(U\) is the CNF whose only clause is the unit clause \([(\iota(a), p)]\). Disjunction-like nodes are consumed from the left: \(\mathcal{O}_1(A \lor B, S) = \mathcal{O}_1(A, \mathcal{O}_1(B, S))\), \(\mathcal{O}_1(A \to B, S) = \mathcal{O}_0(A, \mathcal{O}_1(B, S))\) and \(\mathcal{O}_0(A \land B, S) = \mathcal{O}_0(A, \mathcal{O}_0(B, S))\). Conjunction-like nodes go through \(\mathcal{A}\): \(\mathcal{O}_1(A \land B, S) = \mathcal{A}_1(A, \mathcal{A}_1(B, [\,])) \otimes S\), \(\mathcal{O}_0(A \lor B, S) = \mathcal{A}_0(A, \mathcal{A}_0(B, [\,])) \otimes S\) and \(\mathcal{O}_0(A \to B, S) = \mathcal{A}_1(A, \mathcal{A}_0(B, [\,])) \otimes S\).
An assignment \(\sigma\) satisfies \(\mathcal{O}_p(\varphi, S)\) exactly when \(\varphi\) has truth value \(p\) under \(\sigma \circ \iota\) or \(\sigma\) satisfies \(S\).
def cnfOr (ι : Atom → ℕ) : Bool → Proposition Atom → CNF → CNF
| true, or A B, S => cnfOr ι true A (cnfOr ι true B S)
| true, imp A B, S => cnfOr ι false A (cnfOr ι true B S)
| false, and A B, S => cnfOr ι false A (cnfOr ι false B S)
| pos, atom a, S => CNF.disj [[(ι a, pos)]] S
| true, and A B, S => CNF.disj (cnfAcc ι true A (cnfAcc ι true B [])) S
| false, or A B, S => CNF.disj (cnfAcc ι false A (cnfAcc ι false B [])) S
| false, imp A B, S => CNF.disj (cnfAcc ι true A (cnfAcc ι false B [])) S
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def disj (φ ψ : CNF) : CNF := φ.flatMap fun C ↦ ψ.map fun D ↦ C ++ D
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:72
def cnfAcc (ι : Atom → ℕ) : Bool → Proposition Atom → CNF → CNF
| pos, atom a, acc => [(ι a, pos)] :: acc
| true, and A B, acc => cnfAcc ι true A (cnfAcc ι true B acc)
| false, or A B, acc => cnfAcc ι false A (cnfAcc ι false B acc)
| false, imp A B, acc => cnfAcc ι true A (cnfAcc ι false B acc)
| true, or A B, acc => cnfOr ι true A (cnfAcc ι true B []) ++ acc
| true, imp A B, acc => cnfOr ι false A (cnfAcc ι true B []) ++ acc
| false, and A B, acc => cnfOr ι false A (cnfAcc ι false B []) ++ acc
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:103
Uses 3 · Used by 1
DefinitionCNF of a proposition at a polarity#✓fully proved
Let \(\iota\) number the atoms by natural numbers. For a polarity \(p\) and a proposition \(\varphi\), the CNF of \(\varphi\) at polarity \(p\) is the result of the accumulating CNF builder at polarity \(p\) on \(\varphi\) with the empty CNF as accumulator; the atom \(a\) becomes the variable \(\iota(a)\).
An assignment \(\sigma\) satisfies it exactly when \(\varphi\) has truth value \(p\) under \(\sigma \circ \iota\), so it is a CNF of \(\varphi\) when \(p\) is true and of the Boolean complement of \(\varphi\) when \(p\) is false. Only the requested polarity is built: a proposition already in conjunctive normal form gets a CNF of linear size at polarity true, although the CNF of its complement can be exponentially larger.
def cnfOf (ι : Atom → ℕ) (pos : Bool) (A : Proposition Atom) : CNF := cnfAcc ι pos A []
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def cnfAcc (ι : Atom → ℕ) : Bool → Proposition Atom → CNF → CNF
| pos, atom a, acc => [(ι a, pos)] :: acc
| true, and A B, acc => cnfAcc ι true A (cnfAcc ι true B acc)
| false, or A B, acc => cnfAcc ι false A (cnfAcc ι false B acc)
| false, imp A B, acc => cnfAcc ι true A (cnfAcc ι false B acc)
| true, or A B, acc => cnfOr ι true A (cnfAcc ι true B []) ++ acc
| true, imp A B, acc => cnfOr ι false A (cnfAcc ι true B []) ++ acc
| false, and A B, acc => cnfOr ι false A (cnfAcc ι false B []) ++ acc
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:103
Uses 3 · Used by 3
DefinitionCNF of a proposition#✓fully proved
Let \(\iota\) number the atoms by natural numbers. The CNF of a proposition \(A\) is its CNF at polarity true, with the atom \(a\) as the variable \(\iota(a)\).
An assignment \(\sigma\) satisfies it exactly when \(A\) is true under \(\sigma \circ \iota\).
def toCNF (ι : Atom → ℕ) (A : Proposition Atom) : CNF := cnfOf ι true A
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def cnfOf (ι : Atom → ℕ) (pos : Bool) (A : Proposition Atom) : CNF := cnfAcc ι pos A []
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:129
Uses 2 · Used by 2
DefinitionCNF of the complement of a proposition#✓fully proved
Let \(\iota\) number the atoms by natural numbers. The complement CNF of a proposition \(A\) is its CNF at polarity false, with the atom \(a\) as the variable \(\iota(a)\).
An assignment \(\sigma\) satisfies it exactly when \(A\) is false under \(\sigma \circ \iota\). This is not the negation \(\lnot A\), which is \(A \to \bot\) with \(\bot\) an atom: that proposition can be true together with \(A\) when the atom \(\bot\) is true.
def toNegCNF (ι : Atom → ℕ) (A : Proposition Atom) : CNF := cnfOf ι false A
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def cnfOf (ι : Atom → ℕ) (pos : Bool) (A : Proposition Atom) : CNF := cnfAcc ι pos A []
CSLibExt/Logics/Propositional/CNF/NormalForm.lean:129
Uses 2
TheoremEquivalent CNF#✓fully proved
Let \(\iota\) number the atoms by natural numbers. For every proposition \(A\) and every assignment \(\sigma\) of Boolean values to the natural-number variables, the CNF of \(A\) built with atom \(a\) as variable \(\iota(a)\) is satisfied by \(\sigma\) if and only if \(A\) evaluates to true under the valuation \(\sigma \circ \iota\) of the atoms.
theorem satisfies_toCNF_iff (ι : Atom → ℕ) (A : Proposition Atom) (σ : Nat → Bool) :
(A.toCNF ι).Satisfies σ ↔ A.evalBool (σ ∘ ι) = true
Uses 11 · Used by 1
TheoremSatisfiability of a CNF with falsum false#✓fully proved
Let the atoms have a distinguished atom \(\bot\) and let \(\iota\) be an injective numbering of the atoms by natural numbers. For every proposition \(A\), the CNF consisting of the unit clause with the single negative literal on variable \(\iota(\bot)\) followed by the clauses of the CNF of \(A\) (atom \(a\) read as variable \(\iota(a)\)) is satisfiable if and only if some valuation \(v\) of the atoms with \(v(\bot)\) false makes \(A\) true.
theorem cnfSat_toCNF_bot_iff [Bot Atom] {ι : Atom → ℕ} (hι : Function.Injective ι)
(A : Proposition Atom) :
CNFSat ([(ι ⊥, false)] :: A.toCNF ι) ↔
∃ v : Atom → Bool, v ⊥ = false ∧ A.evalBool v = true
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
Uses 9
DefinitionVariables of a clause#✓fully proved
The variables of a CNF clause \(C\) form the finite set of natural numbers \(x\) such that \(C\) contains a literal \((x, b)\) for some polarity \(b\).
def vars (clause : CNFClause) : Finset Nat :=
(clause.map Prod.fst).toFinset
abbrev CNFClause := List (Nat × Bool)
CSLibExt/Logics/Propositional/CNF/Basic.lean:30
Uses 1 · Used by 20
DefinitionRestriction of a clause by a literal#✓fully proved
Given a literal \(\ell = (x, b)\), the restriction of a clause by \(\ell\) is the clause obtained by deleting every literal whose variable is \(x\), of either polarity, keeping the other literals in order.
def restrict (literal : Nat × Bool) (clause : CNFClause) : CNFClause :=
clause.filter fun candidate ↦ candidate.1 != literal.1
abbrev CNFClause := List (Nat × Bool)
CSLibExt/Logics/Propositional/CNF/Basic.lean:30
Uses 1 · Used by 7
TheoremSatisfaction of a restricted clause#✓fully proved
Let \(C\) be a clause, \(\ell = (x, b)\) a literal that does not occur in \(C\), and \(v\) an assignment of Booleans to variables with \(v(x) = b\). Then \(v\) satisfies the restriction of \(C\) by \(\ell\) if and only if \(v\) satisfies \(C\).
theorem satisfies_restrict_iff {assignment : Nat → Bool} {literal : Nat × Bool}
{clause : CNFClause} (hassignment : assignment literal.1 = literal.2)
(hnot_mem : literal ∉ clause) :
(clause.restrict literal).Satisfies assignment ↔ clause.Satisfies assignment
abbrev CNFClause := List (Nat × Bool)
CSLibExt/Logics/Propositional/CNF/Basic.lean:30
Uses 4 · Used by 1
DefinitionVariables of a CNF formula#✓fully proved
The variables of a CNF formula \(\varphi\) form the union of the sets of variables of its clauses, that is, the finite set of natural numbers \(x\) such that some clause of \(\varphi\) contains a literal \((x, b)\) for some polarity \(b\).
def vars : CNF → Finset Nat
| [] => ∅
| clause :: formula => clause.vars ∪ vars formula
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 3 · Used by 33
DefinitionRestriction of a CNF formula by a literal#✓fully proved
Given a literal \(\ell = (x, b)\), the restriction of a CNF formula \(\varphi\) by \(\ell\) is obtained by deleting every clause of \(\varphi\) that contains \(\ell\) and replacing every other clause by its restriction by \(\ell\), the clause obtained by deleting every literal whose variable is \(x\), of either polarity; the remaining clauses keep their order.
The deleted clauses are true under every assignment that gives \(x\) the value \(b\).
def restrict (literal : Nat × Bool) : CNF → CNF
| [] => []
| clause :: formula =>
if literal ∈ clause then
restrict literal formula
else
clause.restrict literal :: restrict literal formula
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 3 · Used by 13
TheoremRestriction does not add variables#✓fully proved
For every CNF formula \(\varphi\) and every literal \(\ell\), every variable of the restriction of \(\varphi\) by \(\ell\) is a variable of \(\varphi\).
theorem vars_restrict_subset (literal : Nat × Bool) (formula : CNF) :
(formula.restrict literal).vars ⊆ formula.vars
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 6 · Used by 1
TheoremThe restricted variable no longer occurs#✓fully proved
For every CNF formula \(F\) and every literal \(\ell = (x, b)\), the variable \(x\) does not occur in the restriction of \(F\) by \(\ell\).
@[simp]
theorem not_mem_vars_restrict (literal : Nat × Bool) (formula : CNF) :
literal.1 ∉ (formula.restrict literal).vars
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 6 · Used by 2
TheoremRestricting by an occurring variable shrinks the variable set#✓fully proved
Let \(\varphi\) be a CNF formula and \((x, b)\) a literal. If \(x\) is a variable of \(\varphi\), then the set of variables of the restriction of \(\varphi\) by \((x, b)\) is a proper subset of the set of variables of \(\varphi\).
theorem vars_restrict_ssubset {literal : Nat × Bool} {formula : CNF}
(hmem : literal.1 ∈ formula.vars) :
(formula.restrict literal).vars ⊂ formula.vars
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 5 · Used by 1
TheoremRestriction reduces the number of variables#✓fully proved
Let \(F\) be a CNF formula and let \(\ell = (x, b)\) be a literal whose variable \(x\) occurs in \(F\). Then the restriction of \(F\) by \(\ell\) has strictly fewer distinct variables than \(F\).
theorem card_vars_restrict_lt {literal : Nat × Bool} {formula : CNF}
(hmem : literal.1 ∈ formula.vars) :
(formula.restrict literal).vars.card < formula.vars.card
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 4 · Used by 2
TheoremSatisfaction of a restricted CNF formula#✓fully proved
Let \(\varphi\) be a CNF formula, \(\ell = (x, b)\) a literal, and \(v\) an assignment of Booleans to variables with \(v(x) = b\). Then \(v\) satisfies the restriction of \(\varphi\) by \(\ell\) if and only if \(v\) satisfies \(\varphi\).
theorem satisfies_restrict_iff {assignment : Nat → Bool} {literal : Nat × Bool}
{formula : CNF} (hassignment : assignment literal.1 = literal.2) :
(formula.restrict literal).Satisfies assignment ↔ formula.Satisfies assignment
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 8 · Used by 3
TheoremSatisfaction depends only on the occurring variables#✓fully proved
Let \(F\) be a CNF formula and let \(v_1, v_2\) be assignments of Booleans to variables with \(v_1(x) = v_2(x)\) for every variable \(x\) occurring in \(F\). If \(v_1\) satisfies \(F\), then \(v_2\) satisfies \(F\).
theorem satisfies_congr {formula : CNF} {assignment₁ assignment₂ : Nat → Bool}
(hagrees : ∀ x ∈ formula.vars, assignment₁ x = assignment₂ x)
(hsatisfies : formula.Satisfies assignment₁) :
formula.Satisfies assignment₂
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 7 · Used by 3
TheoremLifting a satisfying assignment from a restriction#✓fully proved
Let \(F\) be a CNF formula, \(\ell = (x, b)\) a literal and \(v\) an assignment of Booleans to variables. If \(v\) satisfies the restriction of \(F\) by \(\ell\), then the assignment that agrees with \(v\) except that it sends \(x\) to \(b\) satisfies \(F\).
theorem satisfies_of_satisfies_restrict {formula : CNF} {assignment : Nat → Bool}
{literal : Nat × Bool} (hsatisfies : (formula.restrict literal).Satisfies assignment) :
formula.Satisfies (Function.update assignment literal.1 literal.2)
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
TheoremSplitting on a variable#✓fully proved
For every CNF formula \(F\) and every variable \(x\), the formula \(F\) is satisfiable if and only if the restriction of \(F\) by the literal \((x, \mathrm{true})\) is satisfiable or the restriction of \(F\) by the literal \((x, \mathrm{false})\) is satisfiable.
theorem sat_iff_restrict_true_or_false (formula : CNF) (x : Nat) :
CNFSat formula ↔
CNFSat (formula.restrict (x, true)) ∨ CNFSat (formula.restrict (x, false))
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
Uses 7 · Used by 2
TheoremUnit propagation preserves satisfiability#✓fully proved
Let \(F\) be a CNF formula that contains the unit clause whose only literal is \(\ell\). Then \(F\) is satisfiable if and only if the restriction of \(F\) by \(\ell\) is satisfiable.
theorem sat_iff_restrict_of_unit {formula : CNF} {literal : Nat × Bool}
(hunit : [literal] ∈ formula) :
CNFSat formula ↔ CNFSat (formula.restrict literal)
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
Uses 9 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.