Weighted Satisfiability of CNF Formulas

Lax496464.WH_C3_WeightedSat · concepts/Lax496464/WH_C3_WeightedSat.lean · lax-496464

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

    An assignment to the variables of a propositional formula α\alpha has weight kk if it sets exactly kk of them to true, and α\alpha is kk-satisfiable if some assignment of weight kk satisfies it [FG06, Section 4.1].

    pp-WSat(Γ\Gamma) for a class Γ\Gamma of formulas. Instance: α∈Γ\alpha \in \Gamma and k∈Nk \in \mathbb N. Parameter: kk. Question: is α\alpha kk-satisfiable?

    The classes used are the CNF formulas with clauses of at most dd literals, dd-CNF (Γ1,d\Gamma_{1,d} in [FG06]), and the monotone CNF formulas, all of whose literals are positive (Γ2,1+\Gamma^+_{2,1}).

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

    Lean source view on GitHub

    1import Lax888481.ParameterizedComplexity
    2import Lax429075.CNF
    3
    4/-!
    5---
    6title: Weighted Satisfiability of CNF Formulas
    7type: definition
    8---
    9An assignment to the variables of a propositional formula α\alpha has *weight* kk if it sets
    10exactly kk of them to true, and α\alpha is *kk-satisfiable* if some assignment of weight kk
    11satisfies it [FG06, Section 4.1].
    12
    13**pp-WSat(Γ\Gamma)** for a class Γ\Gamma of formulas. *Instance:* α∈Γ\alpha \in \Gamma and
    14k∈Nk \in \mathbb N. *Parameter:* kk. *Question:* is α\alpha kk-satisfiable?
    15
    16The classes used are the CNF formulas with clauses of at most dd literals, **dd-CNF**
    17(Γ1,d\Gamma_{1,d} in [FG06]), and the **monotone** CNF formulas, all of whose literals are positive
    18(Γ2,1+\Gamma^+_{2,1}).
    19
    20# Formalization Notes
    21
    22A CNF formula is the archive's `Lax429075.CNF.Formula`, a list of clauses, each a list of literals
    23with a variable index and a sign. The variables of α\alpha are the indices occurring in it, and an
    24assignment of weight kk is a set of kk of them, the variables set to true.
    25
    26The word of an instance lists the number of clauses, then each clause as its length followed by its
    27literals — XiX_i written 2i2i and ¬Xi\neg X_i written 2i+12i+1 — and finally kk. The class Γ\Gamma
    28restricts the instances only.
    29-/
    30
    31namespace Lax496464.WH_C3_WeightedSat
    32
    33open Lax429075.CNF
    34open Lax888481.ParameterizedComplexity (Problem)
    35
    36/-- The variables that occur in a formula. -/
    37def vars (α : Formula) : Finset ℕ := (α.flatMap fun C => C.map Literal.index).toFinset
    38
    39/-- `α` is **`k`-satisfiable**: setting some `k` of its variables to true, and the others to false,
    40satisfies it. -/
    41def WeightSat (α : Formula) (k : ℕ) : Prop :=
    42 ∃ S : Finset ℕ, S ⊆ vars α ∧ S.card = k ∧ eval α (fun i => decide (i ∈ S)) = true
    43
    44/-- `α ∈ d-CNF`: every clause has at most `d` literals. -/
    45def IsDCNF (d : ℕ) (α : Formula) : Prop := ∀ C ∈ α, C.length ≤ d
    46
    47/-- `α` is monotone: every literal is positive. -/
    48def IsMonotone (α : Formula) : Prop := ∀ C ∈ α, ∀ l ∈ C, l.positive = true
    49
    50/-- The number standing for a literal: `2i` for `X_i`, `2i + 1` for `¬X_i`. -/
    51def litCode (l : Literal) : ℕ := 2 * l.index + if l.positive then 0 else 1
    52
    53/-- The word of a formula: the number of clauses, then each clause as its length and its literals. -/
    54def encode (α : Formula) : List ℕ := α.length :: α.flatMap fun C => C.length :: C.map litCode
    55
    56/-- **`p-WSat(Γ)`**, weighted satisfiability for the class `Γ` of CNF formulas. -/
    57def pWSat (Γ : Set Formula) : Problem where
    58 Domain := {x | ∃ α ∈ Γ, ∃ k, x = encode α ++ [k]}
    59 Yes x := ∃ α k, x = encode α ++ [k] ∧ WeightSat α k
    60 param x := x.getLast?.getD 0
    61
    62end Lax496464.WH_C3_WeightedSat
    63
    Formalization Notes

    A CNF formula is the archive's Lax429075.CNF.FormulaLax429075.CNF.Formula, a list of clauses, each a list of literals with a variable index and a sign. The variables of α\alpha are the indices occurring in it, and an assignment of weight kk is a set of kk of them, the variables set to true.

    The word of an instance lists the number of clauses, then each clause as its length followed by its literals — XiX_i written 2i2i and ¬Xi\neg X_i written 2i+12i+1 — and finally kk. The class Γ\Gamma restricts the instances only.

    Discussion

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

    Loading discussion…