The Reduction from Satisfiability to Hitting Set

Lax496464.HittingSetFromSat · concepts/Lax496464/HittingSetFromSat.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

    A CNF formula FF on the variables x0,…,xV−1x_0, \dots, x_{V-1} becomes an instance of Hitting Set on the universe {0,…,2V−1}\{0, \dots, 2V - 1\}, in which 2i2i stands for the literal xix_i and 2i+12i + 1 for xˉi\bar x_i. The family has one set {2i,2i+1}\{2i, 2i+1\} for each variable and one set for each clause, holding the elements of its literals; the required size is VV.

    A hitting set of size VV meets each of the VV disjoint pairs in exactly one element, so it is a truth assignment, and it meets the set of a clause exactly when the assignment satisfies the clause. This is the composition of Karp's reductions from satisfiability to Clique and from Clique to Node Cover, read on the literals rather than on the occurrences.

    The reduction on words decodes a formula, builds the instance and encodes it; a word that encodes no formula is treated as the formula with one empty clause, whose instance has no hitting set.

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

    In the paper

    • page 8 of this submission's paper

    Lean source view on GitHub

    1import Lax496464.HittingSet
    2import Lax429075.Satisfiability
    3
    4/-!
    5---
    6title: The Reduction from Satisfiability to Hitting Set
    7type: definition
    8---
    9A CNF formula FF on the variables x0,…,xV−1x_0, \dots, x_{V-1} becomes an instance of Hitting Set
    10on the universe {0,…,2V−1}\{0, \dots, 2V - 1\}, in which 2i2i stands for the literal xix_i and
    112i+12i + 1 for xˉi\bar x_i. The family has one set {2i,2i+1}\{2i, 2i+1\} for each variable and one set
    12for each clause, holding the elements of its literals; the required size is VV.
    13
    14A hitting set of size VV meets each of the VV disjoint pairs in exactly one element, so
    15it is a truth assignment, and it meets the set of a clause exactly when the assignment
    16satisfies the clause. This is the composition of Karp's reductions from satisfiability to
    17Clique and from Clique to Node Cover, read on the literals rather than on the occurrences.
    18
    19The reduction on words decodes a formula, builds the instance and encodes it; a word that
    20encodes no formula is treated as the formula with one empty clause, whose instance has no
    21hitting set.
    22
    23# Formalization Notes
    24
    25Formulas, their binary encoding and satisfiability are those of the archive's Cook–Levin
    26theorem (`lax-429075`).
    27
    28The number of variables is one more than the largest index occurring, and at least two: the
    29hardness statements ask for a solution size of at least two, and a fresh pair costs nothing.
    30An empty clause gives an empty set, which no hitting set meets, as it should.
    31
    32The sets are written as lists of elements, and the family is the membership predicate of
    33those lists on `Fin (2V)`; an element of a clause lies below 2V2V by the choice of VV.
    34-/
    35
    36namespace Lax496464.HittingSetFromSat
    37
    38open Lax429075.CNF Lax429075.Encoding Lax434930.PolynomialTime Lax496464.HittingSet
    39
    40/-- One more than the largest variable index of the formula, and `1` for no literal. -/
    41def bound (F : Formula) : ℕ := (F.flatMap id).foldr (fun l n => max (l.index + 1) n) 1
    42
    43/-- The number of variables of the construction: the formula's, but at least two. -/
    44def vars (F : Formula) : ℕ := max (bound F) 2
    45
    46/-- The element standing for a literal: `2i` for `x_i`, `2i + 1` for `¬x_i`. -/
    47def elem (l : Literal) : ℕ := 2 * l.index + if l.positive then 0 else 1
    48
    49/-- The sets, as lists of elements: the pair of each variable, then the elements of each
    50clause. -/
    51def sets (F : Formula) : List (List ℕ) :=
    52 (List.range (vars F)).map (fun i => [2 * i, 2 * i + 1]) ++ F.map fun C => C.map elem
    53
    54/-- The instance of a formula: the universe `2·vars F`, one set per variable and one per
    55clause. -/
    56def inst (F : Formula) : Instance where
    57 n := 2 * vars F
    58 m := vars F + F.length
    59 F := fun j => Finset.univ.filter fun i : Fin (2 * vars F) => (i : ℕ) ∈ (sets F).getD j []
    60
    61/-- The instance with its solution size. -/
    62def transform (F : Formula) : Instance × ℕ := (inst F, vars F)
    63
    64/-- The formula a word encodes, and the formula with one empty clause if it encodes none. -/
    65def parseF (w : Word) : Formula := (decodeCNF w).getD [[]]
    66
    67/-- The reduction on words, to an instance with its solution size. -/
    68def reduce (w : Word) : Instance × ℕ := transform (parseF w)
    69
    70/-- The reduction on words, to the binary word of the instance. -/
    71def reduceWord (w : Word) : Word := encodeInstance (reduce w).1 (reduce w).2
    72
    73end Lax496464.HittingSetFromSat
    74
    Formalization Notes

    Formulas, their binary encoding and satisfiability are those of the archive's Cook–Levin theorem (lax−429075lax-429075).

    The number of variables is one more than the largest index occurring, and at least two: the hardness statements ask for a solution size of at least two, and a fresh pair costs nothing. An empty clause gives an empty set, which no hitting set meets, as it should.

    The sets are written as lists of elements, and the family is the membership predicate of those lists on Fin(2V)Fin (2V); an element of a clause lies below 2V2V by the choice of VV.

    Discussion

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

    Loading discussion…