Documentation

CslibFrontier.Computability.Complexity.Problems.SetCover

Set Cover #

Finite set systems (Cslib.Complexity.SetSystem) and weighted set systems (Cslib.Complexity.WeightedSetSystem) over natural-number elements, encoded with binary element labels and frame delimiters (encSetSystem, encWeightedSetSystem).

An unweighted instance (S, k) belongs to Cslib.Complexity.SetCover when at most k sets from S.sets (selected by index Fin S.sets.length) cover every element of S.ground. A weighted instance (W, k) belongs to Cslib.Complexity.WeightedSetCover when a covering selection of sets has total weight at most k. Both problems lie in NP (SetCover_mem_NP, WeightedSetCover_mem_NP) via subset witnesses (Cslib.Complexity.mem_NP_of_subsetWitness), and connect directly to the library's greedy algorithm (Cslib.Algorithms.Lean.SetCover.greedy).

This set-system encoding is designed to be shared with related problems (HittingSet and Karp's set-system problems).

Main definitions #

Main results #

Unweighted set systems #

A finite set system over natural-number elements: a ground list ground together with a list of candidate subsets sets. Duplicates in ground or a candidate set are harmless, while distinct indices in S.sets are kept distinct.

  • ground : List ℕ

    Elements of the ground set that must be covered.

  • sets : List (List ℕ)

    Candidate subsets available for covering ground.

Instances For
    @[reducible, inline]

    Framed binary encoding of a list of natural-number subsets.

    theorem Cslib.Complexity.encSetSystem_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List ℕ} {T0 S0 : γ → ℕ} {x1 : γ → List (List ℕ)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encNatSetList T1 S1) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { ground := x0 x, sets := x1 x }) encIn encSetSystem (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
    theorem Cslib.Complexity.encSetSystem_ground_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SetSystem} :
    @[reducible, inline]

    The tuple of the fields of encSetSystem.

    theorem Cslib.Complexity.encSetSystem_sets_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → SetSystem} :
    theorem Cslib.Complexity.encSetSystem_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List ℕ} {x1 : γ → List (List ℕ)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encNatSetList budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { ground := x0 x, sets := x1 x }) encIn encSetSystem budget
    theorem Cslib.Complexity.encSetSystem_sets_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SetSystem} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encSetSystem S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).sets) encIn✝ encNatSetList S✝

    Framed encoding of a SetSystem with binary element labels.

    @[reducible, inline]

    Framed pair of a SetSystem and a binary target bound k.

    A selection of indices C covers S when every element of S.ground belongs to S.sets[i] for some i ∈ C.

    A set system is coverable when some finite index selection covers its ground set.

    Boolean test for whether every element of S.ground appears in at least one candidate set.

    Boolean check that a list I of natural-number indices specifies a valid cover of S.

    theorem Cslib.Complexity.SetSystem.isCoverList_eq_true_iff (S : SetSystem) (I : List ℕ) :
    S.isCoverList I = true ↔ (∀ i ∈ I, i < S.sets.length) ∧ ∀ u ∈ S.ground, ∃ i ∈ I, ∃ (hi : i < S.sets.length), u ∈ S.sets[i]

    The minimum number of sets needed to cover S when S.Coverable holds (and 0 otherwise).

    Indices chosen by Cslib.Algorithms.Lean.SetCover.greedy on S with unit weights.

    Unweighted Set Cover: pairs (S, k) such that at most k candidate sets in S cover S.ground.

    Unweighted Set Cover is in NP via subset witnesses over List.range S.sets.length.

    Weighted set systems #

    A candidate subset together with its nonnegative integer weight.

    • elements : List ℕ

      Elements contained in this candidate subset.

    • weight : ℕ

      Weight incurred when selecting this subset.

    Instances For

      Framed encoding of a WeightedSet with binary elements and binary weight.

      theorem Cslib.Complexity.encWeightedSet_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List ℕ} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
      Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { elements := x0 x, weight := x1 x }) encIn encWeightedSet budget
      theorem Cslib.Complexity.encWeightedSet_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List ℕ} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { elements := x0 x, weight := x1 x }) encIn encWeightedSet (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
      theorem Cslib.Complexity.encWeightedSet_elements_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedSet} :
      theorem Cslib.Complexity.encWeightedSet_weight_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedSet} :
      @[reducible, inline]

      The tuple of the fields of encWeightedSet.

      A finite weighted set system over natural-number elements.

      • ground : List ℕ

        Elements of the ground set that must be covered.

      • Weighted candidate subsets available for covering ground.

      Instances For
        theorem Cslib.Complexity.encWeightedSetSystem_sets_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedSetSystem} :
        theorem Cslib.Complexity.encWeightedSetSystem_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List ℕ} {T0 S0 : γ → ℕ} {x1 : γ → List WeightedSet} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList encWeightedSet) T1 S1) :
        Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { ground := x0 x, sets := x1 x }) encIn encWeightedSetSystem (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
        @[reducible, inline]

        Framed pair of a WeightedSetSystem and a binary target weight bound k.

        A selection of indices C covers W when every element of W.ground belongs to W.sets[i].elements for some i ∈ C.

        A weighted set system is coverable when some finite index selection covers its ground set.

        Total weight of a selection C of sets in W.

        Boolean test for whether W is coverable.

        Minimum weight of a cover of W when W.Coverable holds (and 0 otherwise).

        Weighted Set Cover: pairs (W, k) admitting a cover of W.ground of total weight at most k.

        Weighted Set Cover is in NP via subset witnesses over List.range W.sets.length.