Documentation

CslibFrontier.Computability.Complexity.Problems.HittingSet

Hitting Set #

HittingSet is problem SP8 of Garey and Johnson. Its instances (Cslib.Complexity.HittingSetInstance, encoded by Cslib.Complexity.encHittingSet) pair a set system (Cslib.Complexity.SetSystem: a ground list and a list of subsets) with a number k. An instance is in the problem when at most k distinct ground elements meet every listed subset.

Garey and Johnson ask, for a collection C of subsets of a finite set S and a positive integer K ≤ |S|, for a set S' ⊆ S with |S'| ≤ K that contains an element of every member of C. This formalization differs in three ways:

For 1 ≤ k ≤ |S| and subsets of the ground list, this is the problem of Garey and Johnson.

NP membership uses subsetVerifier: the certificate selects distinct ground elements, and HittingSet.verifier checks their number and HittingSet.isHitting.

The reduction from vertex cover #

Garey and Johnson credit the transformation from VERTEX COVER to [Kar72]. VertexCover.toHittingSet keeps the declared vertices as the ground list and k, and turns every edge between two distinct declared vertices (VertexCover.properEdges) into the subset [u, v]. A set of declared vertices meets every such subset exactly when it is a vertex cover. Every subset has at most two elements, the case that Garey and Johnson note remains NP-complete. VertexCover asks for exactly k vertices and rejects every k above the number n of distinct declared vertices (mem_VertexCover_iff_exists_card_le), while HittingSet asks for at most k. For k > n the reduction therefore produces a fixed instance with only the empty subset, which no set meets.

Main definitions #

Main results #

References #

An instance (system, k) of Hitting Set.

  • system : SetSystem

    The ground elements that may be chosen, and the subsets to hit.

  • k : ℕ

    The largest number of ground elements allowed in a hitting set.

Instances For
    theorem Cslib.Complexity.HittingSetInstance.ext {x y : HittingSetInstance} (system : x.system = y.system) (k : x.k = y.k) :
    x = y
    theorem Cslib.Complexity.encHittingSet_k_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → HittingSetInstance} :
    theorem Cslib.Complexity.encHittingSet_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → SetSystem} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encSetSystem T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { system := x0 x, k := x1 x }) encIn encHittingSet (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
    theorem Cslib.Complexity.encHittingSet_system_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → HittingSetInstance} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encHittingSet S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).system) encIn✝ encSetSystem S✝

    Framed encSetSystem followed by binary encNat, encoding HittingSetInstance. The ground list and the subsets are framed lists of binary labels.

    theorem Cslib.Complexity.encHittingSet_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → SetSystem} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encSetSystem budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { system := x0 x, k := x1 x }) encIn encHittingSet budget
    @[reducible, inline]

    The tuple of the fields of encHittingSet.

    The instances with a hitting set of at most k ground elements Garey and Johnson, Problem SP8: at most k distinct ground elements such that every listed subset contains one of them.

    theorem Cslib.Complexity.mem_HittingSet_iff (x : HittingSetInstance) :
    x ∈ HittingSet ↔ ∃ (H : Finset ℕ), (∀ u ∈ H, u ∈ x.system.ground) ∧ H.card ≤ x.k ∧ ∀ S ∈ x.system.sets, ∃ u ∈ H, u ∈ S

    Membership in HittingSet as a finite set of at most k ground elements that meets every listed subset.

    Whether every set in sets contains an element of selected. For example, isHitting [[1, 2], [2, 3], [3, 4]] [2, 3] = true.

    theorem Cslib.Complexity.HittingSet.isHitting_eq_true_iff (sets : List (List ℕ)) (selected : List ℕ) :
    isHitting sets selected = true ↔ ∀ S ∈ sets, ∃ u ∈ selected, u ∈ S

    isHitting sets selected holds exactly when every set in sets contains an element of selected.

    Membership in NP #

    Verify a Hitting Set certificate: select distinct ground elements by the certificate mask, then check that there are at most k of them and that they meet every listed subset.

    HittingSet belongs to NP: the certificate selects ground elements, and the verifier checks their number and isHitting.

    Reduction from vertex covers #

    Karp's reduction from VertexCover: keep the declared vertices as the ground list and the target, and make every edge (u, v) between two distinct declared vertices the subset [u, v], or produce a fixed instance with only the empty subset, which no set meets, when the target exceeds the number of distinct declared vertices.

    The reduction toHittingSet is polynomial-time: the binary target is compared with the number of distinct declared vertices, computed in unary.