ThreeSATToClique.ThreeSAT_to_Clique_completeness
theoremverifiedimported Lean
Completeness of the 3-SAT to clique reduction. Let $f$ be a 3-CNF formula consisting of $m$ clauses, and let its conflict graph be the simple graph on the vertices $\langle c, \ell\rangle$ (clause index $c$, literal position $\ell$) in which two vertices are adjacent exactly when they belong to different clauses and their literals do not conflict. If $f$ is satisfiable, then this conflict graph has an $m$-clique.
Statement
set_option relaxedAutoImplicit false in set_option autoImplicit false in theorem ThreeSATToClique.ThreeSAT_to_Clique_completeness {V : Type} (f : Formula3 V) : is3Satisfiable f → hasClique (toCliqueGraph f) f.length
- Source
- TCSlib, `ThreeSATToClique.ThreeSAT_to_Clique_completeness`
- Lean proof
- By Yangshuo Zou, from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Copyright (c) 2026 Yangshuo Zou. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.ThreeSATToClique.ThreeSAT_to_Clique_completeness← ThreeSATToClique.ThreeSAT_to_Clique_completeness (TCSlib/Complexity/NPReductions/ThreeSATToClique.lean:240): verbatim
- Verified
- 07 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 13
- ThreeSATToClique.no_conflict_of_trueTrue literals never conflict. Let $\alpha$ be a truth assignment on a set $V$ of variables, and let $\ell_1,\ell_2$ be literals over $V$,…
- ThreeSATToClique.getLitAtGiven a 3-CNF formula $f$ and a vertex $v : \mathtt{CliqueVertex}\,f.\mathtt{length}$, returns the literal at position $v.l\_idx$ within…
- ThreeSATToClique.Formula3A 3-CNF formula over $V$ is a list of 3-clauses, representing their conjunction.
- ThreeSATToClique.hasCliqueA graph $G$ on vertex type $V$ has a $k$-clique if there exists a finite set $s \subseteq V$ of $k$ vertices that are pairwise…
- ThreeSATToClique.CliqueVertexA vertex of the conflict graph for a formula with $m$ clauses is a pair $\langle c\_idx, l\_idx \rangle$ where $c\_idx : \mathrm{Fin}\,m$…
- ThreeSATToClique.is3SatisfiableA 3-CNF formula $f$ is satisfiable if there exists an assignment $\alpha$ such that $\alpha$ satisfies $f$.
- ThreeSATToClique.evalLiteralGiven a truth assignment $\alpha : V \to \mathrm{Prop}$, the evaluation of a literal $\ell$ under $\alpha$ is $\alpha(v)$ when…
- ThreeSATToClique.toCliqueGraphThe conflict graph of a 3-CNF formula $f$ is the simple graph on vertex set $\mathtt{CliqueVertex}\,f.\mathtt{length}$ in which two…
- ThreeSATToClique.literalsConflictTwo literals $l_1$ and $l_2$ conflict if one is the positive and the other the negative occurrence of the same variable, i.e.\…
- ThreeSATToClique.clause3SatisfiedA 3-clause $c$ is satisfied by $\alpha$ if at least one of its three literals $c.l_1$, $c.l_2$, $c.l_3$ evaluates to true under $\alpha$.
- ThreeSATToClique.Clause3A 3-clause over $V$ is a structure with exactly three literals $l_1, l_2, l_3 : \mathtt{Literal}\,V$, representing a disjunction of…
- ThreeSATToClique.formula3SatisfiedA 3-CNF formula $f$ is satisfied by $\alpha$ if every 3-clause $c \in f$ is satisfied by $\alpha$.
- ThreeSATToClique.AssignmentA truth valuation maps each variable to a proposition.
- Used by 1
- ThreeSATToClique.ThreeSAT_to_Clique_equivalenceCorrectness of the 3-SAT to Clique reduction. Let $f$ be a 3-CNF formula with $m$ clauses. Then $f$ is satisfiable if and only if its…
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option relaxedAutoImplicit false inset_option autoImplicit false in/-- **Completeness**: every satisfiable 3-CNF formula with `m` clauses has an `m`-clique in its conflict graph. *Proof*: from the satisfying assignment `α`, pick one true literal per clause (position `choice i` in clause `i`). The resulting `m` vertices are pairwise adjacent because they come from distinct clauses and no two true literals conflict (`no_conflict_of_true`). -/theorem ThreeSATToClique.ThreeSAT_to_Clique_completeness {V : Type} (f : Formula3 V) : is3Satisfiable f → hasClique (toCliqueGraph f) f.length := by rintro ⟨α, hsat⟩ -- For each clause i, choose a position j such that the j-th literal is true. have h_choice : ∀ (i : Fin f.length), ∃ (j : Fin 3), evalLiteral α (getLitAt f (CliqueVertex.mk i j)) := by intro i have hclause := hsat (f.get i) (List.get_mem f i) rcases hclause with (h1 | h2 | h3) · exact ⟨0, h1⟩ · exact ⟨1, h2⟩ · exact ⟨2, h3⟩ let choice (i : Fin f.length) : Fin 3 := (h_choice i).choose have hchoice_spec : ∀ i, evalLiteral α (getLitAt f ⟨i, choice i⟩) := fun i => (h_choice i).choose_spec -- The clique: one vertex per clause, at the chosen position. let vertices : Finset (CliqueVertex f.length) := Finset.univ.image (fun (i : Fin f.length) => CliqueVertex.mk i (choice i)) -- The map i ↦ ⟨i, choice i⟩ is injective, so |vertices| = m. have hcard : vertices.card = f.length := by have hinj : Function.Injective (fun (i : Fin f.length) => CliqueVertex.mk i (choice i)) := by intro i j h; injection h rw [Finset.card_image_of_injective _ hinj, Finset.card_fin f.length] -- Any two distinct vertices are adjacent: different clauses, no conflict. have hclique : (toCliqueGraph f).IsClique vertices := by intro u hu v hv hne simp only [Finset.mem_coe, vertices] at hu hv rcases Finset.mem_image.mp hu with ⟨i, -, rfl⟩ rcases Finset.mem_image.mp hv with ⟨j, -, rfl⟩ have hci_ne : i ≠ j := fun heq => hne (by simp [heq]) exact ⟨by simpa using hci_ne, no_conflict_of_true α _ _ (hchoice_spec i) (hchoice_spec j)⟩ exact ⟨vertices, hcard, hclique⟩