3SAT
Lax799700.ThreeSat · concepts/Lax799700/ThreeSat.lean · lax-799700
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Theorem
3SAT on the vocabulary of SAT: a CNF structure is a yes-instance when every clause has at most three literal occurrences (WidthAtMostThree) and the CNF is satisfiable (ThreeSatisfiable). The width bound is part of the yes-instances rather than of the vocabulary, which is what makes 3SAT a decision problem on arbitrary CNF structures; it is expressed without counting, as “among any four literal occurrences of a clause, two coincide”.
Membership in NP is by the identity-like first-order reduction to SAT; hardness is the classical clause splitting, an ordered first-order reduction from SAT in which the chain of fresh variables of a clause follows the order on its occurrences.
Concept map
Evidence
Lean source view on GitHub
| 1 | import Mathlib.Data.Set.Finite.Lemmas |
| 2 | import Mathlib.Tactic.FinCases |
| 3 | import Mathlib.Order.PiLex |
| 4 | import Mathlib.Data.Prod.Lex |
| 5 | import Mathlib.Data.Fintype.EquivFin |
| 6 | import Mathlib.ModelTheory.Order |
| 7 | import Mathlib.ModelTheory.Semantics |
| 8 | import Mathlib.ModelTheory.Complexity |
| 9 | import Mathlib.Logic.Equiv.Fin.Basic |
| 10 | import Mathlib.Data.Finite.Sigma |
| 11 | import Mathlib.Data.Fintype.Lattice |
| 12 | import Mathlib.ModelTheory.Syntax |
| 13 | import Lax799700.Common |
| 14 | import Lax904597.Sat |
| 15 | import Lax904597.Classes |
| 16 | import Lax799700.Problems |
| 17 | |
| 18 | /-! |
| 19 | --- |
| 20 | title: 3SAT |
| 21 | type: theorem |
| 22 | --- |
| 23 | 3SAT on the vocabulary of SAT: a CNF structure is a yes-instance when |
| 24 | every clause has at most three literal occurrences (WidthAtMostThree) and |
| 25 | the CNF is satisfiable (ThreeSatisfiable). The width bound is part of the |
| 26 | yes-instances rather than of the vocabulary, which is what makes 3SAT a |
| 27 | decision problem on arbitrary CNF structures; it is expressed without |
| 28 | counting, as “among any four literal occurrences of a clause, two |
| 29 | coincide”. |
| 30 | |
| 31 | Membership in NP is by the identity-like first-order reduction to SAT; |
| 32 | hardness is the classical clause splitting, an ordered first-order |
| 33 | reduction from SAT in which the chain of fresh variables of a clause |
| 34 | follows the order on its occurrences. |
| 35 | |
| 36 | -/ |
| 37 | |
| 38 | namespace Lax799700.ThreeSat |
| 39 | |
| 40 | open Lax799700.Common Lax904597.Sat |
| 41 | |
| 42 | open FirstOrder |
| 43 | |
| 44 | open Language Structure |
| 45 | |
| 46 | section ThreeSat |
| 47 | |
| 48 | variable (A : Type) [sat.Structure A] |
| 49 | |
| 50 | /-- Every clause of a `Language.sat`-structure has at most three literal |
| 51 | occurrences: among any four occurrences of a clause, two coincide (as signed |
| 52 | occurrences). -/ |
| 53 | def WidthAtMostThree : Prop := |
| 54 | ∀ (c : A) (x : Fin 4 → A) (s : Fin 4 → Bool), |
| 55 | (∀ i, SatOcc.OccIn c (x i) (s i)) → ∃ i j, i ≠ j ∧ x i = x j ∧ s i = s j |
| 56 | |
| 57 | /-- A `Language.sat`-structure is a yes-instance of 3SAT if every clause has |
| 58 | at most three literal occurrences and the CNF is satisfiable. -/ |
| 59 | def ThreeSatisfiable : Prop := |
| 60 | WidthAtMostThree A ∧ Satisfiable A |
| 61 | |
| 62 | end ThreeSat |
| 63 | |
| 64 | open Lax904597.Problems Lax904597.Classes Lax799700.Problems |
| 65 | |
| 66 | /-- The property `ThreeSatisfiable` is isomorphism-invariant. -/ |
| 67 | axiom threeSatisfiable_iso : ∀ {A B : Type} [Lax904597.Sat.sat.Structure A] [Lax904597.Sat.sat.Structure B], |
| 68 | (A ≃[Lax904597.Sat.sat] B) → (ThreeSatisfiable A ↔ ThreeSatisfiable B) |
| 69 | |
| 70 | /-- The problem ThreeSAT: does the structure satisfy `ThreeSatisfiable`? -/ |
| 71 | def ThreeSAT : DecisionProblem Lax904597.Sat.sat := |
| 72 | DecisionProblem.ofPred ThreeSatisfiable |
| 73 | |
| 74 | /-- The yes-instances of ThreeSAT are exactly the structures satisfying |
| 75 | `ThreeSatisfiable`. -/ |
| 76 | axiom threeSat_iff : ∀ (A : Type) [Lax904597.Sat.sat.Structure A], ThreeSAT A ↔ ThreeSatisfiable A |
| 77 | |
| 78 | /-- ThreeSAT is NP-complete. -/ |
| 79 | axiom threeSat_NP_complete : NP.Complete ThreeSAT |
| 80 | |
| 81 | end Lax799700.ThreeSat |
| 82 |
Used by
From Mathlib
Mathlib.Data.Finite.SigmaMathlib.Data.Fintype.EquivFinMathlib.Data.Fintype.LatticeMathlib.Data.Prod.LexMathlib.Data.Set.Finite.LemmasMathlib.Logic.Equiv.Fin.BasicMathlib.ModelTheory.ComplexityMathlib.ModelTheory.OrderMathlib.ModelTheory.SemanticsMathlib.ModelTheory.SyntaxMathlib.Order.PiLexMathlib.Tactic.FinCases
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments