SAT-UNSAT
Lax564036.SatUnsat · concepts/Lax564036/SatUnsat.lean · lax-564036
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
An instance is a pair of CNF formulas on one universe: a structure with two copies of the vocabulary of CNF instances, one for each formula. It is a yes-instance of SAT-UNSAT when the first formula is satisfiable and the second is not. SAT-UNSAT is the decision problem of the structures isomorphic to such an instance.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.ModelTheory.Semantics |
| 2 | import Lax904597.Problems |
| 3 | import Lax485149.Problems |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: SAT-UNSAT |
| 8 | type: definition |
| 9 | --- |
| 10 | An instance is a pair of CNF formulas on one universe: a structure with two |
| 11 | copies of the vocabulary of CNF instances, one for each formula. It is a |
| 12 | yes-instance of SAT-UNSAT when the first formula is satisfiable and the |
| 13 | second is not. SAT-UNSAT is the decision problem of the structures |
| 14 | isomorphic to such an instance. |
| 15 | -/ |
| 16 | |
| 17 | namespace Lax564036.SatUnsat |
| 18 | |
| 19 | open Lax904597.Problems Lax485149.Problems |
| 20 | |
| 21 | open FirstOrder |
| 22 | |
| 23 | open FirstOrder.Language |
| 24 | |
| 25 | /-- Relation symbols of the language of *pairs* of CNF instances: two copies of |
| 26 | the symbols of CNF instances, one per side. -/ |
| 27 | inductive satPairRel : ℕ → Type |
| 28 | /-- `isClause₁ c`: `c` is a clause of the first formula. -/ |
| 29 | | isClause₁ : satPairRel 1 |
| 30 | /-- `posIn₁ c x`: `x` occurs positively in the first formula's clause `c`. -/ |
| 31 | | posIn₁ : satPairRel 2 |
| 32 | /-- `negIn₁ c x`: `x` occurs negatively in the first formula's clause `c`. -/ |
| 33 | | negIn₁ : satPairRel 2 |
| 34 | /-- `isClause₂ c`: `c` is a clause of the second formula. -/ |
| 35 | | isClause₂ : satPairRel 1 |
| 36 | /-- `posIn₂ c x`: `x` occurs positively in the second formula's clause `c`. -/ |
| 37 | | posIn₂ : satPairRel 2 |
| 38 | /-- `negIn₂ c x`: `x` occurs negatively in the second formula's clause `c`. -/ |
| 39 | | negIn₂ : satPairRel 2 |
| 40 | deriving DecidableEq |
| 41 | |
| 42 | /-- The relational vocabulary of pairs of CNF instances. -/ |
| 43 | def satPair : Language := |
| 44 | ⟨fun _ => Empty, satPairRel⟩ |
| 45 | |
| 46 | instance instIsRelationalSatPair : IsRelational satPair := fun _ => |
| 47 | (inferInstance : IsEmpty Empty) |
| 48 | |
| 49 | /-- “Is a clause of the first formula”. -/ |
| 50 | abbrev spIsCl₁ : satPair.Relations 1 := .isClause₁ |
| 51 | |
| 52 | /-- “Occurs positively in”, first formula. -/ |
| 53 | abbrev spPos₁ : satPair.Relations 2 := .posIn₁ |
| 54 | |
| 55 | /-- “Occurs negatively in”, first formula. -/ |
| 56 | abbrev spNeg₁ : satPair.Relations 2 := .negIn₁ |
| 57 | |
| 58 | /-- “Is a clause of the second formula”. -/ |
| 59 | abbrev spIsCl₂ : satPair.Relations 1 := .isClause₂ |
| 60 | |
| 61 | /-- “Occurs positively in”, second formula. -/ |
| 62 | abbrev spPos₂ : satPair.Relations 2 := .posIn₂ |
| 63 | |
| 64 | /-- “Occurs negatively in”, second formula. -/ |
| 65 | abbrev spNeg₂ : satPair.Relations 2 := .negIn₂ |
| 66 | |
| 67 | open FirstOrder |
| 68 | |
| 69 | open Language Structure |
| 70 | |
| 71 | section Defs |
| 72 | |
| 73 | variable (A : Type) [satPair.Structure A] |
| 74 | |
| 75 | /-- Satisfiability of the side of the instance read by the given triple of |
| 76 | symbols: some assignment of truth values makes every clause of that side |
| 77 | contain a true literal. Both sides of SAT-UNSAT are instances of this. -/ |
| 78 | def SatWith (isCl : satPair.Relations 1) |
| 79 | (pos neg : satPair.Relations 2) : Prop := |
| 80 | ∃ ν : A → Prop, ∀ c : A, RelMap isCl ![c] → |
| 81 | ∃ x : A, (RelMap pos ![c, x] ∧ ν x) ∨ (RelMap neg ![c, x] ∧ ¬ν x) |
| 82 | |
| 83 | end Defs |
| 84 | |
| 85 | /-- SAT-UNSAT: the first formula of the pair is satisfiable and the second is |
| 86 | not. -/ |
| 87 | def SATUNSAT : DecisionProblem satPair := |
| 88 | DecisionProblem.ofPred fun A _ => |
| 89 | SatWith A spIsCl₁ spPos₁ spNeg₁ ∧ ¬SatWith A spIsCl₂ spPos₂ spNeg₂ |
| 90 | |
| 91 | end Lax564036.SatUnsat |
| 92 |
Builds on
Used by
Lax564036.AlternatingMachineCompleteLax564036.AlternatingMachineInvarianceLax564036.CoNPClosureLax564036.DPClosureLax564036.DPInclusionsLax564036.HierarchyDualityLax564036.HierarchyInclusionsLax564036.PolynomialTimeInHierarchyLax564036.QbfCompleteLax564036.QuantifiedBooleanFormulasInvarianceLax564036.SatUnsatDPCompleteLax564036.SatUnsatInvarianceLax564036.TautCoNPCompleteLax564036.TautologyInvarianceLax564036.ThreeDnfTautCoNPCompleteLax564036.ThreeDnfTautologyInvariance
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments