While this submission is a draft, it cannot be used by other submissions.

#2SAT, #HORN-SAT, and #Monotone-2SAT

Lax859101.CountingRestrictedSat · concepts/Lax859101/CountingRestrictedSat.lean · lax-859101

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    The restricted versions of #SAT count the models of a CNF instance in a class of formulas, and are 00 on the other instances: #2SAT on the formulas with at most two literals per clause, #HORN-SAT on the formulas with at most one positive literal per clause, and #Monotone-2SAT on the formulas with at most two literals per clause and no negative literal.

    Concept map
    11 concepts; 13 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Tactic.FinCases
    2import Mathlib.Order.PiLex
    3import Mathlib.Data.Prod.Lex
    4import Mathlib.Data.Fintype.EquivFin
    5import Mathlib.ModelTheory.Order
    6import Mathlib.ModelTheory.Semantics
    7import Mathlib.ModelTheory.Complexity
    8import Mathlib.Logic.Equiv.Fin.Basic
    9import Mathlib.Data.Finite.Sigma
    10import Mathlib.Data.Fintype.Lattice
    11import Mathlib.ModelTheory.Syntax
    12import Mathlib.Data.Set.Finite.Lemmas
    13import Mathlib.ModelTheory.Graph
    14import Mathlib.SetTheory.Cardinal.Finite
    15import Mathlib.Order.Lattice.Nat
    16import Mathlib.Data.Set.Card
    17import Mathlib.Data.Fintype.Pigeonhole
    18import Mathlib.Dynamics.FixedPoints.Basic
    19import Mathlib.Algebra.Order.BigOperators.Group.Finset
    20import Mathlib.Data.Fintype.Card
    21import Mathlib.Algebra.BigOperators.Ring.Finset
    22import Mathlib.Data.Fintype.BigOperators
    23import Mathlib.Algebra.Group.Action.Defs
    24import Mathlib.Tactic.Ring
    25import Mathlib.Logic.Equiv.Prod
    26import Mathlib.Data.Fintype.Sort
    27import Mathlib.Order.Hom.Set
    28import Lax799700.Common
    29import Lax904597.Sat
    30import Lax366625.CountingProblems
    31import Lax366625.CountingSat
    32
    33/-!
    34---
    35title: #2SAT, #HORN-SAT, and #Monotone-2SAT
    36type: definition
    37---
    38The restricted versions of #SAT count the models of a CNF instance in a
    39class of formulas, and are 00 on the other instances: #2SAT on the formulas
    40with at most two literals per clause, #HORN-SAT on the formulas with at most
    41one positive literal per clause, and #Monotone-2SAT on the formulas with at
    42most two literals per clause and no negative literal.
    43-/
    44
    45namespace Lax859101.CountingRestrictedSat
    46
    47open Lax799700.Common Lax904597.Sat
    48
    49open FirstOrder
    50
    51open Language Structure
    52
    53section HornSat
    54
    55variable (A : Type) [sat.Structure A]
    56
    57/-- Every clause of a `Language.sat`-structure has at most one positive
    58literal: any two variables occurring positively in the same clause coincide. -/
    59def AtMostOnePositive : Prop :=
    60 ∀ c x y : A, RelMap satIsClause ![c] → RelMap satPosIn ![c, x] →
    61 RelMap satPosIn ![c, y] → x = y
    62
    63end HornSat
    64
    65open FirstOrder
    66
    67open Language Structure
    68
    69section TwoSat
    70
    71variable (A : Type) [sat.Structure A]
    72
    73/-- Every clause of a `Language.sat`-structure has at most two literal
    74occurrences: among any three occurrences of a clause, two coincide (as signed
    75occurrences). -/
    76def WidthAtMostTwo : Prop :=
    77 ∀ (c : A) (x : Fin 3 → A) (s : Fin 3 → Bool),
    78 (∀ i, SatOcc.OccIn c (x i) (s i)) → ∃ i j, i ≠ j ∧ x i = x j ∧ s i = s j
    79
    80end TwoSat
    81
    82open FirstOrder
    83
    84open Language Structure
    85
    86section Sentences
    87
    88variable {α : Type}
    89
    90variable {A : Type} [sat.Structure A]
    91
    92/-- No clause has a negative literal. -/
    93def NoNegative (A : Type) [sat.Structure A] : Prop :=
    94 ∀ c x : A, RelMap satIsClause ![c] → ¬RelMap satNegIn ![c, x]
    95
    96end Sentences
    97
    98open Lax366625.CountingProblems Lax366625.CountingSat
    99
    100/-- **#2SAT**, as a counting problem. -/
    101noncomputable def SharpTwoSAT : CountingProblem Lax904597.Sat.sat :=
    102 CountingProblem.ofFun fun A _ =>
    103 Nat.card {ν : A → Prop // WidthAtMostTwo A ∧ SatModel A ν}
    104
    105/-- **#HORN-SAT**, as a counting problem. -/
    106noncomputable def SharpHornSAT : CountingProblem Lax904597.Sat.sat :=
    107 CountingProblem.ofFun fun A _ =>
    108 Nat.card {ν : A → Prop // AtMostOnePositive A ∧ SatModel A ν}
    109
    110/-- **#Monotone-2SAT**, as a counting problem. -/
    111noncomputable def SharpMonotoneTwoSAT : CountingProblem Lax904597.Sat.sat :=
    112 CountingProblem.ofFun fun A _ =>
    113 Nat.card {ν : A → Prop // (WidthAtMostTwo A ∧ NoNegative A) ∧ SatModel A ν}
    114
    115end Lax859101.CountingRestrictedSat
    116

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…