In the mathematical field of combinatorics, given a collection 𝒮 of subsets of a set X, an exact cover is a subcollection 𝒮∗ of 𝒮 such that each element in X is contained in exactly one subset in 𝒮∗. One says that each element in X is covered by exactly one subset in 𝒮∗. An exact cover is a kind of cover. In other words, 𝒮∗ is a partition of X consisting of subsets contained in 𝒮. The exact cover problem to find an exact cover is a kind of constraint satisfaction problem. The elements of 𝒮 represent choices and the elements of X represent constraints. It is NP-hard and has a variety of applications, ranging from the optimization of airline flight schedules, cloud computing, and electronic circuit design. An exact cover problem involves the relation contains between subsets and elements. But an exact cover problem can be represented by any heterogeneous relation between a set of choices and a set of constraints. For example, an exact cover problem is equivalent to an exact hitting set problem, an incidence matrix, or a bipartite graph. In computer science, the exact cover problem is a decision problem to determine if an exact cover exists. The exact cover problem is NP-complete and is one of Karp's 21 NP-complete problems. It is NP-complete even when each subset in S contains exactly three elements; this restricted problem is known as exact cover by 3-sets, often abbreviated X3C. Knuth's Algorithm X is an algorithm that finds all solutions to an exact cover problem. DLX is the name given to Algorithm X when it is implemented efficiently using Donald Knuth's Dancing Links technique on a computer. The exact cover problem can be generalized slightly to involve not only exactly-once constraints but also at-most-once constraints. Finding Pentomino tilings and solving Sudoku are noteworthy examples of exact cover problems. The n queens problem is a generalized exact cover problem.
Formal definition Given a collection 𝒮 of subsets of a set X, an exact cover of X is a subcollection 𝒮∗ of 𝒮 that satisfies two conditions:
The intersection of any two distinct subsets in 𝒮∗ is empty, i.e., the subsets in 𝒮∗ are pairwise disjoint. In other words, each element in X is contained in at most one subset in 𝒮∗. The union of the subsets in 𝒮∗ is X, i.e., the subsets in 𝒮∗ cover X. In other words, each element in X is contained in at least one subset in 𝒮∗. In short, an exact cover is exact in the sense that each element in X is contained in exactly one subset in 𝒮∗. Equivalently, an exact cover of X is a subcollection 𝒮∗ of 𝒮 that partitions X. For an exact cover of X to exist, it is necessary that:
The union of the subsets in 𝒮 is X. In other words, each element in X is contained in at least one subset in 𝒮. If the empty set ∅︀ is contained in 𝒮, then it makes no difference whether or not it is in any exact cover. Thus it is typical to assume that:
The empty set is not in 𝒮∗. In other words, each subset in 𝒮∗ contains at least one element.
Basic examples Let 𝒮={N,O,P,E} be a collection of subsets of a set X={1,2,3,4} such that:
N={}, O={1,3}, P={1,2,3}, and E={2,4}. The subcollection {O,E} is an exact cover of X, since the subsets O={1,3} and E={2,4} are disjoint and their union is X={1,2,3,4}. The subcollection {N,O,E} is also an exact cover of X. Including the empty set N={} makes no difference, as it is disjoint with all subsets and does not change the union. The subcollection {E,P} is not an exact cover of X. Even though the union of the subsets E and P is {1,2,3,4}=X, the intersection of the subsets E and P, {2}, is not empty. Therefore the subsets E and P do not meet the disjoint requirement of an exact cover. The subcollection {N,P} is also not an exact cover of X. Even though N and P are disjoint, their union is not X, so they fail the cover requirement. On the other hand, there is no exact cover—indeed, not even a cover—of Y={1,2,3,4,5} because ⋃𝒮={1,2,3,4} is a proper subset of Y: None of the subsets in 𝒮 contains the element 5.
Detailed example
Let S = {A, B, C, D, E, F} be a collection of subsets of a set X = {1, 2, 3, 4, 5, 6, 7} such that:
A = {1, 4, 7}; B = {1, 4}; C = {4, 5, 7}; D = {3, 5, 6}; E = {2, 3, 6, 7}; and F = {2, 7}. The subcollection S* = {B, D, F} is an exact cover, since each element is covered by (contained in) exactly one selected subset, as the highlighting makes clear. Moreover, {B, D, F} is the only exact cover, as the following argument demonstrates: Because A and B are the only subsets containing the element 1, an exact cover must contain A or B, but not both. If an exact cover contains A, then it doesn't contain B, C, E, or F, as each of these subsets has the element 1, 4, or 7 in common with A. Then D is the only remaining subset, but the subcollection {A, D} doesn't cover the element 2. In conclusion, there is no exact cover containing A. On the other hand, if an exact cover contains B, then it doesn't contain A or C, as each of these subsets has the element 1 or 4 in common with B. Because D is the only remaining subset containing the element 5, D must be part of the exact cover. If an exact cover contains D, then it doesn't contain E, as E has the elements 3 and 6 in common with D. Then F is the only remaining subset, and the subcollection {B, D, F} is indeed an exact cover. See the example in the article on Knuth's Algorithm X for a matrix-based version of this argument.
Representations An exact cover problem is defined by the heterogeneous relation contains between a collection S of subsets and a set X of elements. But there is nothing fundamental about subsets and elements. A representation of an exact cover problem arises whenever there is a heterogeneous relation R ⊆ S × X between a set S of choices and a set X of constraints and the goal is to select a subset S* of S such that each element in X is RT-related to exactly one element in S*. Here RT is the converse of R. In general, RT restricted to X × S* is a function from X to S*, which maps each element in X to the unique element in S* that is R-related to that element in X. This function is onto, unless S* contains an element (akin to the empty set) that isn't R-related to any element in X. Representations of an exact cover problem include an exact hitting set problem, an incidence matrix, and a bipartite graph.
… excerpt ends here. Continue reading the full article.


