Motivation
HITTING SET (P135) from Garey & Johnson, A3 SP8. A classical NP-complete problem useful for reductions. It is the dual of SET COVER: while Set Cover asks which sets to pick to cover all universe elements, Hitting Set asks which universe elements to pick to "hit" all sets. Every instance of VERTEX COVER reduces to HITTING SET by encoding each edge as a 2-element subset.
Although MinimumSetCovering already exists in the codebase (the LP dual), MinimumHittingSet has genuinely different variable semantics: variables represent universe elements (which to select) rather than sets (which to pick). This means dims(), evaluate(), and the schema are structurally different — analogous to how MinimumVertexCover and MinimumSetCovering coexist despite VC being a special case of SC. Having both models enables natural reduction chains (e.g., MinimumVertexCover → MinimumHittingSet) and captures the element-selection perspective that downstream reductions to database problems (#460, #462, #467) require.
Definition
Name: MinimumHittingSet
Canonical name: Minimum Hitting Set (also: Minimum Transversal)
Reference: Garey & Johnson, Computers and Intractability, A3 SP8
Mathematical definition:
INSTANCE: Collection C of subsets of a finite set S.
OBJECTIVE: Find a subset S' ⊆ S of minimum cardinality such that S' contains at least one element from each subset in C.
The original GJ formulation is a decision problem with budget K; here we use the optimization variant (minimize |S'|) per project conventions.
Variables
- Count: |S| (one binary variable per universe element)
- Per-variable domain: binary {0, 1} — whether element s ∈ S is included in the hitting set S'
- Meaning: variable x_i = 1 if element i is selected into the hitting set; the configuration (x_0, ..., x_{|S|-1}) encodes a candidate subset S' ⊆ S. The assignment is valid if for every subset c ∈ C, at least one element of c has x_i = 1. The objective is to minimize |S'| = ∑ x_i.
Schema (data type)
Type name: MinimumHittingSet
Variants: none (no graph or weight type parameter needed; the collection is stored directly)
| Field |
Type |
Description |
universe_size |
usize |
Number of elements in S (elements are indexed 0..universe_size) |
sets |
Vec<Vec<usize>> |
The collection C; each inner Vec is a subset of element indices |
Complexity
- Decision complexity: NP-complete (Karp, 1972; transformation from VERTEX COVER).
- Best known exact algorithm: Brute-force enumeration of all 2^|S| subsets of S in O(2^|S| · |C|) time. No better general exact algorithm is known since Hitting Set is W[2]-hard parameterized by solution size.
declare_variants! complexity string: "2^universe_size"
- Parameterized: W[2]-complete parameterized by solution size k, meaning no FPT algorithm parameterized by k is expected under standard complexity assumptions. FPT algorithms exist for d-bounded instances (each subset has size ≤ d): for 3-Hitting Set, the best known bound is O*(2.0409^k) (Tsur, 2025), improving earlier results of O*(2.270^k) (Niedermeier & Rossmanith, 2003).
- References:
- [Karp, 1972] R. M. Karp, "Reducibility Among Combinatorial Problems", Complexity of Computer Computations, pp. 85–103. Original NP-completeness proof.
- [Niedermeier & Rossmanith, 2003] R. Niedermeier, P. Rossmanith, "An efficient fixed-parameter algorithm for 3-Hitting Set", Journal of Discrete Algorithms 1(1), pp. 89–102. https://doi.org/10.1016/S1570-8667(03)00009-1
- [Tsur, 2025] D. Tsur, "Faster parameterized algorithm for 3-Hitting Set", arXiv:2501.06452. Current best FPT bound for 3-Hitting Set.
Specialization
- This is a generalization of: VERTEX COVER (special case where every subset has exactly 2 elements, corresponding to edges)
- Known special cases: VERTEX COVER (|c| = 2 for all c ∈ C), 3-Hitting Set (|c| ≤ 3 for all c ∈ C)
- Restriction: VERTEX COVER is obtained by restricting C to 2-element subsets (edges of a graph)
Extra Remark
Full book text:
INSTANCE: Collection C of subsets of a finite set S, positive integer K ≤ |S|.
QUESTION: Is there a subset S' ⊆ S with |S'| ≤ K such that S' contains at least one element from each subset in C?
Reference: [Karp, 1972]. Transformation from VERTEX COVER.
Comment: Remains NP-complete even if |c| ≤ 2 for all c ∈ C.
How to solve
Example Instance
Universe S = {0, 1, 2, 3, 4, 5} (6 elements)
Collection C (7 subsets):
- c_0 = {0, 1, 2}
- c_1 = {0, 3, 4}
- c_2 = {1, 3, 5}
- c_3 = {2, 4, 5}
- c_4 = {0, 1, 5}
- c_5 = {2, 3}
- c_6 = {1, 4}
Brute-force complexity: 2^6 = 64 candidate subsets to enumerate.
Greedy trap: Greedily picking the element appearing most often might pick element 1 (appears in c_0, c_2, c_4, c_6 — 4 subsets), but this alone leaves c_1, c_3, c_5 uncovered and we still need 2 more elements. A better choice requires looking at coverage interaction.
Optimal hitting set: S' = {1, 3, 4} (size 3):
- c_0 = {0,1,2}: 1 ∈ S' ✓
- c_1 = {0,3,4}: 3,4 ∈ S' ✓
- c_2 = {1,3,5}: 1,3 ∈ S' ✓
- c_3 = {2,4,5}: 4 ∈ S' ✓
- c_4 = {0,1,5}: 1 ∈ S' ✓
- c_5 = {2,3}: 3 ∈ S' ✓
- c_6 = {1,4}: 1,4 ∈ S' ✓
All 7 subsets are hit by S' = {1, 3, 4} with |S'| = 3 (optimal). No hitting set of size 2 exists (can be verified: no pair of elements covers all 7 subsets).
Suboptimal example: S'' = {0, 3, 4} (size 3) also hits all subsets but is not unique; S''' = {0, 1, 3, 5} (size 4) hits all subsets but is suboptimal.
Motivation
HITTING SET (P135) from Garey & Johnson, A3 SP8. A classical NP-complete problem useful for reductions. It is the dual of SET COVER: while Set Cover asks which sets to pick to cover all universe elements, Hitting Set asks which universe elements to pick to "hit" all sets. Every instance of VERTEX COVER reduces to HITTING SET by encoding each edge as a 2-element subset.
Although MinimumSetCovering already exists in the codebase (the LP dual), MinimumHittingSet has genuinely different variable semantics: variables represent universe elements (which to select) rather than sets (which to pick). This means
dims(),evaluate(), and the schema are structurally different — analogous to how MinimumVertexCover and MinimumSetCovering coexist despite VC being a special case of SC. Having both models enables natural reduction chains (e.g., MinimumVertexCover → MinimumHittingSet) and captures the element-selection perspective that downstream reductions to database problems (#460, #462, #467) require.Definition
Name:
MinimumHittingSetCanonical name: Minimum Hitting Set (also: Minimum Transversal)
Reference: Garey & Johnson, Computers and Intractability, A3 SP8
Mathematical definition:
INSTANCE: Collection C of subsets of a finite set S.
OBJECTIVE: Find a subset S' ⊆ S of minimum cardinality such that S' contains at least one element from each subset in C.
The original GJ formulation is a decision problem with budget K; here we use the optimization variant (minimize |S'|) per project conventions.
Variables
Schema (data type)
Type name:
MinimumHittingSetVariants: none (no graph or weight type parameter needed; the collection is stored directly)
universe_sizeusizesetsVec<Vec<usize>>Complexity
declare_variants!complexity string:"2^universe_size"Specialization
Extra Remark
Full book text:
INSTANCE: Collection C of subsets of a finite set S, positive integer K ≤ |S|.
QUESTION: Is there a subset S' ⊆ S with |S'| ≤ K such that S' contains at least one element from each subset in C?
Reference: [Karp, 1972]. Transformation from VERTEX COVER.
Comment: Remains NP-complete even if |c| ≤ 2 for all c ∈ C.
How to solve
Example Instance
Universe S = {0, 1, 2, 3, 4, 5} (6 elements)
Collection C (7 subsets):
Brute-force complexity: 2^6 = 64 candidate subsets to enumerate.
Greedy trap: Greedily picking the element appearing most often might pick element 1 (appears in c_0, c_2, c_4, c_6 — 4 subsets), but this alone leaves c_1, c_3, c_5 uncovered and we still need 2 more elements. A better choice requires looking at coverage interaction.
Optimal hitting set: S' = {1, 3, 4} (size 3):
All 7 subsets are hit by S' = {1, 3, 4} with |S'| = 3 (optimal). No hitting set of size 2 exists (can be verified: no pair of elements covers all 7 subsets).
Suboptimal example: S'' = {0, 3, 4} (size 3) also hits all subsets but is not unique; S''' = {0, 1, 3, 5} (size 4) hits all subsets but is suboptimal.