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

Satisfiability of Bounded Occurrence

Lax117284.BoundedSat · concepts/Lax117284/BoundedSat.lean · lax-117284

proven

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

    A [2,3]-bounded 3-SAT formula is a conjunction of clauses of two and of three literals in which every literal occurs at most twice — so every variable occurs at most twice positively and at most twice negatively, and hence in at most four clauses. Deciding whether such a formula is satisfiable is NP-hard.

    Concept map
    7 concepts; 1 descendant hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    Lean source view on GitHub

    1import Lax117284.Problems
    2
    3/-!
    4---
    5title: Satisfiability of Bounded Occurrence
    6type: definition
    7---
    8A *[2,3]-bounded 3-SAT formula* is a conjunction of clauses of two and of three literals in
    9which every literal occurs at most twice — so every variable occurs at most twice
    10positively and at most twice negatively, and hence in at most four clauses. Deciding
    11whether such a formula is satisfiable is NP-hard.
    12
    13# Formalization Notes
    14
    15The two widths are separate families of clauses rather than one family with a width
    16condition, because the construction that consumes such a formula treats the two widths
    17differently: the clauses of three literals receive a gadget of their own.
    18
    19The language contains only formulas with at most as many variables as positions. A formula
    20in which every variable occurs is of this kind, so nothing is excluded that a formula of the
    21paper is; but the number of variables is written in binary, so a word may name exponentially
    22many variables without mentioning any, and a reduction that writes a client for each of them
    23could not run in polynomial time.
    24
    25The occurrence bound is a condition on the formula and not extra data: an *occurrence* is a
    26position inside a clause, and every literal is required to occupy at most two of them. A
    27reduction that needs to distinguish the two occurrences of a literal obtains a numbering of
    28them from this bound.
    29-/
    30
    31namespace Lax117284.BoundedSat
    32
    33open Lax434930.PolynomialTime Lax434930.NondeterministicPolynomialTime
    34
    35/-- A **[2,3]-bounded 3-SAT formula** over `vars` variables: `twoClauses` clauses of two
    36literals and `threeClauses` clauses of three literals, in which every literal — a variable
    37together with a sign — occupies at most two of the positions of the formula. -/
    38structure Formula where
    39 /-- The number of variables. -/
    40 vars : ℕ
    41 /-- The number of clauses of two literals. -/
    42 twoClauses : ℕ
    43 /-- The number of clauses of three literals. -/
    44 threeClauses : ℕ
    45 /-- The literals of the clauses of two literals. -/
    46 aLit : Fin twoClauses → Fin 2 → Fin vars × Bool
    47 /-- The literals of the clauses of three literals. -/
    48 bLit : Fin threeClauses → Fin 3 → Fin vars × Bool
    49 /-- Every literal occurs at most twice in the formula. -/
    50 occ_le_two : ∀ l : Fin vars × Bool,
    51 (Finset.univ.filter fun o : (Fin twoClauses × Fin 2) ⊕ (Fin threeClauses × Fin 3) =>
    52 Sum.elim (fun q => aLit q.1 q.2) (fun q => bLit q.1 q.2) o = l).card ≤ 2
    53
    54namespace Formula
    55
    56variable (φ : Formula)
    57
    58/-- A **position** of the formula: a literal slot in one of the clauses. -/
    59abbrev Occ := (Fin φ.twoClauses × Fin 2) ⊕ (Fin φ.threeClauses × Fin 3)
    60
    61/-- The literal occupying a position. -/
    62def litAt (o : φ.Occ) : Fin φ.vars × Bool :=
    63 Sum.elim (fun q => φ.aLit q.1 q.2) (fun q => φ.bLit q.1 q.2) o
    64
    65/-- An assignment of a truth value to every variable. -/
    66abbrev Assignment := Fin φ.vars → Bool
    67
    68/-- The assignment `a` satisfies `φ`: every clause, of either width, has a literal that
    69holds. -/
    70def Satisfies (a : φ.Assignment) : Prop :=
    71 (∀ c, ∃ α, a (φ.aLit c α).1 = (φ.aLit c α).2) ∧
    72 (∀ c, ∃ α, a (φ.bLit c α).1 = (φ.bLit c α).2)
    73
    74/-- **The question of [2,3]-bounded 3-SAT**: is there a satisfying assignment? -/
    75def Satisfiable : Prop := ∃ a : φ.Assignment, φ.Satisfies a
    76
    77end Formula
    78
    79/-- The literal occupying the occurrence slot `o`, read off unnumbered indices: the two
    80slots of every clause of two literals come first, then the three slots of every clause of
    81three literals. Outside the formula the value is the positive literal of the variable `0`.
    82It is in this form that a construction reads a formula. -/
    83def litOfSlot (φ : Formula) (o : ℕ) : ℕ × Bool :=
    84 if o < 2 * φ.twoClauses then
    85 if hj : o / 2 < φ.twoClauses then
    86 ((φ.aLit ⟨o / 2, hj⟩ ⟨o % 2, by omega⟩).1, (φ.aLit ⟨o / 2, hj⟩ ⟨o % 2, by omega⟩).2)
    87 else (0, true)
    88 else
    89 if hj : (o - 2 * φ.twoClauses) / 3 < φ.threeClauses then
    90 ((φ.bLit ⟨(o - 2 * φ.twoClauses) / 3, hj⟩ ⟨(o - 2 * φ.twoClauses) % 3, by omega⟩).1,
    91 (φ.bLit ⟨(o - 2 * φ.twoClauses) / 3, hj⟩ ⟨(o - 2 * φ.twoClauses) % 3, by omega⟩).2)
    92 else (0, true)
    93
    94/-- Which of the occurrences of its own literal the slot `o` is: the number of earlier
    95slots carrying the same literal. Under the occurrence bound this is `0` or `1`. -/
    96def slotRank (φ : Formula) (o : ℕ) : ℕ :=
    97 (List.range o).countP fun o' => litOfSlot φ o' == litOfSlot φ o
    98
    99/-- The number of occurrence slots of the formula. -/
    100def slots (φ : Formula) : ℕ := 2 * φ.twoClauses + 3 * φ.threeClauses
    101
    102/-- A [2,3]-bounded 3-SAT formula as a binary word: the number of variables, the two
    103numbers of clauses, and then the variable and the sign of every literal of every clause,
    104the clauses of two literals first. -/
    105def encodeFormula (φ : Formula) : Word :=
    106 Problems.encodeNat φ.vars ++ Problems.encodeNat φ.twoClauses ++
    107 Problems.encodeNat φ.threeClauses ++
    108 ((List.finRange φ.twoClauses).flatMap fun c =>
    109 (List.finRange 2).flatMap fun α =>
    110 Problems.encodeNat (φ.aLit c α).1 ++ [(φ.aLit c α).2]) ++
    111 (List.finRange φ.threeClauses).flatMap fun c =>
    112 (List.finRange 3).flatMap fun α =>
    113 Problems.encodeNat (φ.bLit c α).1 ++ [(φ.bLit c α).2]
    114
    115/-- **[2,3]-bounded 3-SAT**, as a language: the satisfiable formulas that have no more
    116variables than positions, which every formula in which each variable occurs does. -/
    117def BoundedSat : Language :=
    118 {w | ∃ φ : Formula, encodeFormula φ = w ∧ φ.vars ≤ slots φ ∧ φ.Satisfiable}
    119
    120/-- **[2,3]-bounded 3-SAT is NP-hard.** -/
    121axiom boundedSat_npHard : Problems.NPHard BoundedSat
    122
    123end Lax117284.BoundedSat
    124
    Show Proof
    Formalization Notes

    The two widths are separate families of clauses rather than one family with a width condition, because the construction that consumes such a formula treats the two widths differently: the clauses of three literals receive a gadget of their own.

    The language contains only formulas with at most as many variables as positions. A formula in which every variable occurs is of this kind, so nothing is excluded that a formula of the paper is; but the number of variables is written in binary, so a word may name exponentially many variables without mentioning any, and a reduction that writes a client for each of them could not run in polynomial time.

    The occurrence bound is a condition on the formula and not extra data: an occurrence is a position inside a clause, and every literal is required to occupy at most two of them. A reduction that needs to distinguish the two occurrences of a literal obtains a numbering of them from this bound.

    Builds on
    Used by
    From Mathlib

    none

    Discussion

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

    Loading discussion…