Counting the models of 3-CNF and 1-in-CNF formulas
Lax280166.CountingSatVariants · concepts/Lax280166/CountingSatVariants.lean · lax-280166
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
The instances are the CNF instances of the NP core. #3SAT counts the models of an instance whose clauses have at most three literals each, and is on the others. #1-in-SAT counts the 1-in-models: the sets of variables such that every clause contains exactly one true literal.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Tactic.FinCases |
| 2 | import Mathlib.Order.PiLex |
| 3 | import Mathlib.Data.Prod.Lex |
| 4 | import Mathlib.Data.Fintype.EquivFin |
| 5 | import Mathlib.ModelTheory.Order |
| 6 | import Mathlib.ModelTheory.Semantics |
| 7 | import Mathlib.ModelTheory.Complexity |
| 8 | import Mathlib.Logic.Equiv.Fin.Basic |
| 9 | import Mathlib.Data.Fintype.Lattice |
| 10 | import Mathlib.Data.Finite.Sigma |
| 11 | import Mathlib.Order.Lattice.Nat |
| 12 | import Mathlib.Data.Set.Card |
| 13 | import Mathlib.Data.Fintype.Pigeonhole |
| 14 | import Mathlib.Dynamics.FixedPoints.Basic |
| 15 | import Mathlib.ModelTheory.Syntax |
| 16 | import Mathlib.Algebra.Order.BigOperators.Group.Finset |
| 17 | import Mathlib.Data.Fintype.Card |
| 18 | import Mathlib.SetTheory.Cardinal.Finite |
| 19 | import Mathlib.Data.Set.Finite.Lemmas |
| 20 | import Lax366625.CountingSat |
| 21 | import Lax799700.OneInSat |
| 22 | import Lax904597.Sat |
| 23 | import Mathlib.SetTheory.Cardinal.Finite |
| 24 | import Lax366625.CountingProblems |
| 25 | import Lax366625.CountingSat |
| 26 | import Lax799700.ThreeSat |
| 27 | |
| 28 | /-! |
| 29 | --- |
| 30 | title: Counting the models of 3-CNF and 1-in-CNF formulas |
| 31 | type: definition |
| 32 | --- |
| 33 | The instances are the CNF instances of the NP core. #3SAT counts the models |
| 34 | of an instance whose clauses have at most three literals each, and is on |
| 35 | the others. #1-in-SAT counts the 1-in-models: the sets of variables such |
| 36 | that every clause contains exactly one true literal. |
| 37 | -/ |
| 38 | |
| 39 | namespace Lax280166.CountingSatVariants |
| 40 | |
| 41 | open Lax366625.CountingSat Lax799700.OneInSat Lax904597.Sat |
| 42 | |
| 43 | open FirstOrder |
| 44 | |
| 45 | open Language Structure |
| 46 | |
| 47 | /-- The set `ν` of true variables is an exactly-one model of the CNF formula: |
| 48 | every clause has exactly one true literal, and `ν` consists of variables of |
| 49 | the formula. -/ |
| 50 | def OneInModel (A : Type) [sat.Structure A] (ν : A → Prop) : Prop := |
| 51 | OneInProper ν ∧ ∀ x : A, ν x → SatOccurs A x |
| 52 | |
| 53 | open Lax366625.CountingProblems Lax366625.CountingSat Lax799700.ThreeSat |
| 54 | |
| 55 | /-- **#3SAT**, as a counting problem. -/ |
| 56 | noncomputable def SharpThreeSAT : CountingProblem Lax904597.Sat.sat := |
| 57 | CountingProblem.ofFun fun A _ => |
| 58 | Nat.card {ν : A → Prop // WidthAtMostThree A ∧ SatModel A ν} |
| 59 | |
| 60 | /-- **#1-in-SAT**, as a counting problem. -/ |
| 61 | noncomputable def SharpOneInSAT : CountingProblem Lax904597.Sat.sat := |
| 62 | CountingProblem.ofFun fun A _ => |
| 63 | Nat.card {ν : A → Prop // OneInModel A ν} |
| 64 | |
| 65 | end Lax280166.CountingSatVariants |
| 66 |
Builds on
Used by
Lax280166.CliqueCompleteLax280166.CliquesValuesLax280166.DirHamCircuitCompleteLax280166.DominatingSetCompleteLax280166.DominatingSetsValuesLax280166.ExactCoverCompleteLax280166.FeedbackArcSetCompleteLax280166.FeedbackSetsValuesLax280166.FeedbackVertexSetCompleteLax280166.HamCircuitCompleteLax280166.HamiltonCircuitsValuesLax280166.HittingSetCompleteLax280166.IndependentSetCompleteLax280166.KnapsackCompleteLax280166.KnapsacksValuesLax280166.OneInSATCompleteLax280166.SatVariantsValuesLax280166.SetCoverCompleteLax280166.SetFamiliesValuesLax280166.SetPackingCompleteLax280166.SteinerTreeCompleteLax280166.SteinerTreesValuesLax280166.ThreeSATCompleteLax280166.VertexCoverCompleteLax280166.ZeroOneIPComplete
From Mathlib
Mathlib.Algebra.Order.BigOperators.Group.FinsetMathlib.Data.Finite.SigmaMathlib.Data.Fintype.CardMathlib.Data.Fintype.EquivFinMathlib.Data.Fintype.LatticeMathlib.Data.Fintype.PigeonholeMathlib.Data.Prod.LexMathlib.Data.Set.CardMathlib.Data.Set.Finite.LemmasMathlib.Dynamics.FixedPoints.BasicMathlib.Logic.Equiv.Fin.BasicMathlib.ModelTheory.ComplexityMathlib.ModelTheory.OrderMathlib.ModelTheory.SemanticsMathlib.ModelTheory.SyntaxMathlib.Order.Lattice.NatMathlib.Order.PiLexMathlib.SetTheory.Cardinal.FiniteMathlib.Tactic.FinCases
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments