Delta method: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
 
Undid revision 580910146 by 111.92.64.147 (talk)
Line 1: Line 1:
== aby móc obsługiwać swoje sprawy Longchamp Warszawa Torebki ==
In [[mathematics]], given a collection <math>\mathcal{S}</math> of [[subset]]s of a set ''X'', an '''exact cover''' is a subcollection <math>\mathcal{S}^*</math> of <math>\mathcal{S}</math> such that each element in ''X'' is contained in ''exactly one'' subset in <math>\mathcal{S}^*</math>.
One says that each element in ''X'' '''is covered by''' exactly one subset in <math>\mathcal{S}^*</math>.
An exact cover is a kind of [[cover (topology)|cover]].


Muzyka epoki wojny domowej był bogaty w teksty, które wywołują kolejną erę melodii, historii i. Fragmenty:. W rzeczywistości, kawa nie pozostają [http://www.oldtinstuff.com/modules/content.asp?longchamp=36 Longchamp Warszawa Torebki] świeże przez długi czas po ich palone. Więc nadal będziemy finansować cztery zespoły wojewódzkie, narodowej i [http://www.yourautobahn.com/mail/LDAP/client.asp?polo=42-Fred-Perry-Allegro Fred Perry Allegro] grę w rodzinie; to jak zwykle, ale będziemy musieli pożyczać na pokrycie się na następne sześć lat ..<br><br>Pięć minut wideo można korzystać z kilku gigabajtów miejsca na dysku twardym. To idzie z powrotem do mojego wcześniejszego punktu, że nie istnieje prawda synchronizacja folderów i reguł między HTTP z wykorzystaniem dwóch kont Gmail, choć będzie importować foldery. W drugiej części badania, 18 dzieci w wieku szkoły podstawowej były podobne podano mniejsze lub większe miski zbóż.<br><br>Przepis wymagający, aby określić ryzyko banki próbują zabezpieczenia jest w dużej mierze wynikiem London Whale odcinka, w którym podmioty gospodarcze w JPMorgan Chase próbuje zmniejszyć ekspozycję banku na niektórych strat hipotetycznych biorąc na ryzyko nadwymiarowego w innych kategoriach kosztów, które ostatecznie Bank miliardy dolarów straty, a jego reputacja jako dobrze zarządzanej instytucji.<br><br>W wyniku jego doświadczeń, on stać się ekspertem w jaki sposób obsługiwać 'majątki cyfrowych' i ślad online zmarłego. I zamknięcie za nami i komisji budżetowych tworzących, teraz mamy okazję do skupienia [http://www.pinnaclelifehealth.com/individual/frame.asp?y=108-Buty-Air-Force-Allegro Buty Air Force Allegro] się na rozsądny budżet, który jest odpowiedzialny, że jest sprawiedliwy, i że pomaga ciężko pracujących ludzi, na całym tym kraju, 'powiedział Obama ..<br><br>Chociaż, nie ma nic złego w sieci i dzielenie się myślami do większej społeczności w świecie wirtualnym, nie można przegapić nadużywania systemu, jak wielu studentów znajdują się uzależnieni od mediów społecznych .. Miałem do sądu w celu podjęcia działań nie osoba wyznaczona przez postępowań sądowych, aby móc obsługiwać swoje sprawy, nawet jeśli to był ich małżonek.<br><br>Kierownik: notorycznie brutalny gangster Miguel Angel Trevino Morales (pseudonim 'Z 40') jest uważana za nowy przywódca kartelu narkotykowego Zetas po pojedynku z Heriberto 'El Lazca' Lazcano. Starałem się pracować, jak daleko było do krawężnika, ale Odyn miał ją pod kontrolą i upewnić się, że zatrzymałem się na skrzyżowaniu i czekał, aż to było bezpieczne, aby iść do przodu ..<br><br>Objawy związane z pojemników znajdujących się w zapleczach pracowniczych zapytać pracowników do 'oddawania produktów spożywczych o tak współpracownicy w potrzebie mogą korzystać [http://www.blogbudowy.pl/logs/footer.php?rayban=8 Okulary Ray Ban Szczecin] Dziękczynienia.'. Po roku 1900, kapelusze damskie poszedł do eon architektury, która została przyjęta jako 'Edwardian'. tanie nowe kapelusze ery w tym eon poszedł z najnowszymi trendami mody w czasie, które obejmowały połączone spódnice, że udał się do podłogi.<ul>
In [[computer science]], the '''exact cover problem''' is a [[decision problem]] to find an exact cover or else determine none exists.
 
The exact cover problem is [[NP-complete]]<ref>
  <li>[http://www.ovnprod.com/spip.php?article24/ http://www.ovnprod.com/spip.php?article24/]</li>
{{cite book
 
| author = M.R. Garey
  <li>[http://bbs.itengyun.com/thread-299897-1-1.html http://bbs.itengyun.com/thread-299897-1-1.html]</li>
| authorlink = Michael Garey
 
| coauthors = [[David S. Johnson|D.S. Johnson]]
  <li>[http://www.kmaik.lt/index.php?option=com_kunena&func=view&catid=3&id=57905&Itemid=180&lang=en#57905 http://www.kmaik.lt/index.php?option=com_kunena&func=view&catid=3&id=57905&Itemid=180&lang=en#57905]</li>
| title = [[Computers and Intractability: A Guide to the Theory of NP-Completeness]]
 
| year = 1979
  <li>[http://www.dutchkarma.com/index.php?site=guestbook http://www.dutchkarma.com/index.php?site=guestbook]</li>
| publisher = W.H. Freeman
 
| location = New York
  <li>[http://annuncianimali.altervista.org/index.php?page=item&id=133804 http://annuncianimali.altervista.org/index.php?page=item&id=133804]</li>
| isbn = 0-7167-1045-5
 
}}  This book is a classic, developing the theory, then cataloguing ''many'' NP-Complete problems.
</ul>
</ref>
and is one of [[Karp's 21 NP-complete problems]].<ref>
{{cite conference
| author = Richard M. Karp
| authorlink = Richard Karp
| title = [http://www.cs.berkeley.edu/~luca/cs172/karp.pdf Reducibility among combinatorial problems]
| conference = Proc. of a Symp. on the Complexity of Computer Computations
| booktitle = Complexity of Computer Computations
| editor = R.E. Miller and J.W. Thatcher (editors)
| year = 1972
| publisher = Plenum
| location = New York
| isbn =0-3063-0707-3
| pages = 85–103}}
</ref>
The exact cover problem is a kind of [[constraint satisfaction problem]].
 
An exact cover problem can be represented by an [[incidence matrix]] or a [[bipartite graph]].
 
[[Knuth's Algorithm X]] is an [[algorithm]] that finds all solutions to an exact cover problem. [[Dancing Links]], commonly known as DLX, is the technique suggested by [[Donald Knuth]] to efficiently implement his Algorithm X on a computer.
 
The standard exact cover problem can be generalized slightly to involve not only "exactly one" constraints but also "at-most-one" constraints.
Finding [[Pentomino]] tilings and solving [[Sudoku]] are noteworthy examples of exact cover problems.
The [[N queens problem]] is a slightly generalized exact cover problem.
 
== Formal definition ==
 
Given a collection <math>\mathcal{S}</math> of [[subset]]s of a set ''X'', an exact cover of ''X'' is a subcollection <math>\mathcal{S}^*</math> of <math>\mathcal{S}</math> that satisfies two conditions:
* The [[intersection (set theory)|intersection]] of any two distinct subsets in <math>\mathcal{S}^*</math> is [[empty set|empty]], i.e., the subsets in <math>\mathcal{S}^*</math> are [[pairwise disjoint]]. In other words, each element in ''X'' is contained in ''at most one'' subset in <math>\mathcal{S}^*</math>.
* The [[union (set theory)|union]] of the subsets in <math>\mathcal{S}^*</math> is ''X'', i.e., the subsets in <math>\mathcal{S}^*</math> [[cover (topology)|cover]] ''X''. In other words, each element in ''X'' is contained in ''at least one'' subset in <math>\mathcal{S}^*</math>.
 
In short, an exact cover is "exact" in the sense that each element in ''X'' is contained in ''exactly one'' subset in <math>\mathcal{S}^*</math>.
 
Equivalently, an exact cover of ''X'' is a subcollection <math>\mathcal{S}^*</math> of <math>\mathcal{S}</math> that [[partition of a set|partitions]] ''X''.
 
For an exact cover of ''X'' to exist, it is necessary that:
* The union of the subsets in <math>\mathcal{S}</math> is ''X''. In other words, each element in ''X'' is contained in at least one subset in <math>\mathcal{S}</math>.
 
If the [[empty set]] ∅ is contained in <math>\mathcal{S}</math>, 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 <math>\mathcal{S}^*</math>. In other words, each subset in <math>\mathcal{S}^*</math> contains at least one element.
 
=== Basic examples ===
 
Let <math>\mathcal{S}</math> = {''N'', ''O'', ''E'', ''P''} be a collection of subsets of a set ''X'' = {1, 2, 3, 4} such that:
* ''N'' = { },
* ''O'' = {1, 3},
* ''E'' = {2, 4}, and
* ''P'' = {2, 3}.
 
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''.
The intersection of the subsets ''E'' and ''P'', {2}, is not empty:
The subsets ''E'' and ''P'' are not disjoint.
Moreover, the union of the subsets ''E'' and ''P'', {2, 3, 4}, is not ''X'' = {1, 2, 3, 4}:
Neither ''E'' nor ''P'' covers the element 1.
 
On the other hand, there is no exact cover—indeed, not even a cover—of ''Y'' = {1, 2, 3, 4, 5} because <math>\bigcup \mathcal{S}</math> = {1, 2, 3, 4} is a proper subset of ''Y'':
None of the subsets in <math>\mathcal{S}</math> contains the element 5.
 
=== Detailed example ===
 
Let <math>\mathcal{S}</math> = {''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}.
 
Then the subcollection <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} is an exact cover, since each element in ''X'' is contained in exactly one of the subsets:
* ''B'' = {1, 4};
* ''D'' = {3, 5, 6}; or
* ''F'' = {2, 7}.
 
Moreover, {''B'', ''D'', ''F''} is the only exact cover, as the following argument demonstrates:
Because ''A'' and ''B'' are the only subsets containing 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 an element in common with ''A''.
Then ''D'' is the only remaining subset, but the collection {''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 an element in common with ''B''.
Because ''D'' is the only remaining subset containing 5, ''D'' must be part of the exact cover.
If an exact cover contains ''D'', then it doesn't contain ''E'', as ''E'' has an element in common with ''D''.
Then ''F'' is the only remaining subset, and the collection {''B'', ''D'', ''F''} is indeed an exact cover.
See the [[Knuth's Algorithm X#Example|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 [[binary relation]] "contains" between subsets in <math>\mathcal{S}</math> and elements in ''X''.
There are different equivalent ways to represent this relation.
 
=== Standard representation ===
 
The standard way to represent the relation "contains" is to list the elements in each subset.
 
For example, the [[#Detailed example|detailed example]] above uses this standard representation:
* ''A'' = {1, 4, 7};
* <span style="font-weight:bold; color:red">''B''</span> = {<span style="font-weight:bold; color:red">1</span>, <span style="font-weight:bold; color:red">4</span>};
* ''C'' = {4, 5, 7};
* <span style="font-weight:bold; color:red">''D''</span> = {<span style="font-weight:bold; color:red">3</span>, <span style="font-weight:bold; color:red">5</span>, <span style="font-weight:bold; color:red">6</span>};
* ''E'' = {2, 3, 6, 7}; and
* <span style="font-weight:bold; color:red">''F''</span> = {<span style="font-weight:bold; color:red">2</span>, <span style="font-weight:bold; color:red">7</span>}.
 
Again, the subcollection <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} is an exact cover, since each element is contained in exactly one selected subset, as the highlighting makes clear.
 
=== Inverse representation ===
 
The relation "contains" between subsets and elements can be [[inverse relation|inverted]], listing the subsets each element is contained in.
 
For example, the relation "contains" in the [[#Detailed example|detailed example]] above can be represented by listing the subsets each element is contained in:
* 1 is contained in ''A'', <span style="font-weight:bold; color:red">''B''</span>;
* 2 is contained in ''E'', <span style="font-weight:bold; color:red">''F''</span>;
* 3 is contained in <span style="font-weight:bold; color:red">''D''</span>, ''E'';
* 4 is contained in ''A'', <span style="font-weight:bold; color:red">''B''</span>, ''C'';
* 5 is contained in ''C'', <span style="font-weight:bold; color:red">''D''</span>;
* 6 is contained in <span style="font-weight:bold; color:red">''D''</span>, ''E''; and
* 7 is contained in ''A'', ''C'', ''E'', <span style="font-weight:bold; color:red">''F''</span>.
 
Again, the subcollection <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} is an exact cover, since each element is contained in exactly one selected subset, as the highlighting makes clear.
 
When solving an exact cover problem, it is often useful to switch between the standard and inverse representations.
 
=== Matrix and hypergraph representations ===
 
The relation "contains" can be represented by an [[incidence matrix]]. 
 
The matrix includes one row for each subset in <math>\mathcal{S}</math> and one column for each element in ''X''.
The entry in a particular row and column is 1 if the corresponding subset contains the corresponding element, and is 0 otherwise.
As each row represents the elements contained in the corresponding subset and each column represents the subsets containing the corresponding element, an incidence matrix effectively provides both the standard and inverse representations.
 
In the matrix representation, an exact cover is a selection of rows such that each column contains a 1 in exactly one selected row.
 
For example, the relation "contains" in the [[#Detailed example|detailed example]] above can be represented by a 6×7 incidence matrix:<ref>[[Donald Knuth]] in his paper "Dancing Links" gives this example, as equation (3), only with the rows reordered.</ref>
 
:{| border="1" cellpadding="5" cellspacing="0"
! !! 1 !! 2 !! 3 !! 4 !! 5 !! 6 !! 7
|-
! ''A''
| 1 || 0 || 0 || 1 || 0 || 0 || 1
|-
! <span style="font-weight:bold; color:red">''B''</span>
| <span style="font-weight:bold; color:red">1</span> || 0 || 0 || <span style="font-weight:bold; color:red">1</span> || 0 || 0 || 0
|-
! ''C''
| 0 || 0 || 0 || 1 || 1 || 0 || 1
|-
! <span style="font-weight:bold; color:red">''D''</span>
| 0 || 0 || <span style="font-weight:bold; color:red">1</span> || 0 || <span style="font-weight:bold; color:red">1</span> || <span style="font-weight:bold; color:red">1</span> || 0
|-
! ''E''
| 0 || 1 || 1 || 0 || 0 || 1 || 1
|-
! <span style="font-weight:bold; color:red">''F''</span>
| 0 || <span style="font-weight:bold; color:red">1</span> || 0 || 0 || 0 || 0 || <span style="font-weight:bold; color:red">1</span>
|}
 
Again, the subcollection <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} is an exact cover, since each element is contained in exactly one selected subset, i.e., each column contains a 1 in exactly one selected row, as the highlighting makes clear.
 
See the [[Knuth's Algorithm X#Example|example]] in the article on [[Knuth's Algorithm X]] for a matrix-based solution to the [[#Detailed example|detailed example]] above.
 
In turn, the incidence matrix can be seen also as describing a [[hypergraph]].  The hypergraph includes one node for each element in ''X'' and one edge for each subset in <math>\mathcal{S}</math>; each node is included in exactly one of the edges forming the cover.
 
=== Graph representation ===
 
The relation "contains" can be represented by a [[bipartite graph]].
 
The vertices of the graph are divided into two disjoint sets, one representing the subsets in <math>\mathcal{S}</math> and another representing the elements in ''X''.
If a subset contains an element, an edge connects the corresponding vertices in the graph.
 
In the graph representation, an exact cover is a selection of vertices corresponding to subsets such that each vertex corresponding to an element is connected to exactly one selected vertex.
 
For example, the relation "contains" in the [[#Detailed example|detailed example]] above can be represented by a bipartite graph with 6+7 = 13 vertices:
 
[[File:Exact-cover-bigraph-highlighted.svg|none|300px]]
 
Again, the subcollection <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} is an exact cover, since each element is contained in exactly one selected subset, i.e., the vertex corresponding to each element in ''X'' is connected to exactly one selected vertex, as the highlighting makes clear.
 
== Equivalent problems ==
 
Although the canonical exact cover problem involves a collection <math>\mathcal{S}</math> of subsets of a set ''X'', the logic does not depend on the presence of subsets containing elements.
An "abstract exact cover problem" arises whenever there is a [[binary relation]] between two sets ''P'' and ''Q'' and the goal is to select a subset ''P*'' of ''P'' such that each element in ''Q'' is related to ''exactly one'' element in ''P*''.
In general, the elements of ''P'' represent choices and the elements of ''Q'' represent "exactly one" constraints on those choices.
 
More formally, given a binary relation ''R'' <math>\subseteq </math> ''P'' × ''Q'' between sets ''P'' and ''Q'', one can call a subset ''P*'' of ''P'' an "abstract exact cover" of ''Q'' if each element in ''Q'' is ''R''<sup> -1</sup>-related to exactly one element in ''P*''.
Here ''R''<sup> -1</sup> is the [[inverse relation|inverse]] of ''R''.
 
In general, ''R''<sup> -1</sup> [[restriction (mathematics)|restricted]] to ''Q'' × ''P*'' is a [[function (mathematics)|function]] from ''Q'' to ''P*'', which maps each element in ''Q'' to the unique element in ''P*'' that is ''R''-related that element in ''Q''.
This function is [[onto]], unless ''P*'' contains the "empty set," i.e., an element which isn't ''R''-related to any element in ''Q''.
 
In the canonical exact cover problem, ''P'' is a collection <math>\mathcal{S}</math> of subsets of ''X'', ''Q'' is the set ''X'', ''R'' is the binary relation "contains" between subsets and elements, and ''R''<sup> -1</sup> restricted to ''Q'' × ''P*'' is the function "is contained in" from elements to selected subsets.
 
== Exact hitting set ==
 
In [[mathematics]], given a collection <math>\mathcal{S}</math> of subsets of a set ''X'', an '''exact hitting set''' ''X*'' is a subset of ''X'' such that each subset in <math>\mathcal{S}</math> contains ''exactly one'' element in ''X*''. One says that each subset in <math>\mathcal{S}</math> '''is hit by''' exactly one element in ''X*''.
 
In [[computer science]], the '''exact hitting set problem''' is a [[decision problem]] to find an exact hitting set or else determine none exists.
 
The exact hitting set problem is an abstract exact cover problem.
In the [[#Equivalent problems|notation above]], ''P'' is the set ''X'', ''Q'' is a collection <math>\mathcal{S}</math> of subsets of ''X'', ''R'' is the binary relation "is contained in" between elements and subsets, and ''R''<sup> -1</sup> restricted to ''Q'' × ''P*'' is the function "contains" from subsets to selected elements.
 
Whereas an exact cover problem involves selecting subsets and the relation "contains" from subsets to elements, an exact hitting set problem involves selecting elements and the relation "is contained in" from elements to subsets.
In a sense, an exact hitting set problem is the inverse of the exact cover problem involving the same set and collection of subsets.
 
=== Exact hitting set example ===
 
As in the [[#Detailed example|detailed exact cover example]] above, let <math>\mathcal{S}</math> = {''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'' = {<span style="font-weight:bold; color:red">1</span>, 4, 7};
* ''B'' = {<span style="font-weight:bold; color:red">1</span>, 4};
* ''C'' = {4, <span style="font-weight:bold; color:red">5</span>, 7};
* ''D'' = {3, <span style="font-weight:bold; color:red">5</span>, 6};
* ''E'' = {<span style="font-weight:bold; color:red">2</span>, 3, 6, 7}; and
* ''F'' = {<span style="font-weight:bold; color:red">2</span>, 7}.
 
Then ''X*'' = {1, 2, 5} is an exact hitting set, since each subset in <math>\mathcal{S}</math> contains exactly one element in ''X*'', as the highlighting makes clear.
 
Moreover, {1, 2, 5} is the only exact hitting set, as the following argument demonstrates:
Because 2 and 7 are the only elements that hit ''F'', an exact hitting set must contain 2 or 7, but not both.
If an exact hitting set contains 7, then it doesn't contain 1, 2, 3, 4, 5, or 6, as each of these elements are contained in some subset also containing 7.
Then there are no more remaining elements, but {7} is not an exactly hitting set, as it doesn't hit ''B'' or ''D''.
In conclusion, there is no exact hitting set containing 7.
On the other hand, if an exact hitting set contains 2, then it doesn't contain 3, 6, or 7, as each of these elements are contained in some subset also containing 2.
Because 5 is the only remaining element that hits ''D'', the exact hitting set must contain 5.
If an exact hitting set contains 5, then it doesn't contain 4, as both hit ''C''.
Because 1 is the only remaining element that hits ''A'', the exact hitting set must contain 1.
Then there are no more remaining elements, and {1, 2, 5} is indeed an exact hitting set.
 
Although this example involves the same collection of subsets as the detailed exact cover example above, it is essentially a different problem. In a sense, the exact hitting set problem is the inverse (or transpose or converse) of the corresponding exact cover problem above, as the matrix representation makes clear:
 
:{| border="1" cellpadding="5" cellspacing="0"
! !! ''A'' !! ''B'' !! ''C'' !! ''D'' !! ''E'' !! ''F''
|-
! <span style="font-weight:bold; color:red">1</span>
| <span style="font-weight:bold; color:red">1</span> || <span style="font-weight:bold; color:red">1</span> || 0 || 0 || 0 || 0
|-
! <span style="font-weight:bold; color:red">2</span>
| 0 || 0 || 0 || 0 || <span style="font-weight:bold; color:red">1</span> || <span style="font-weight:bold; color:red">1</span>
|-
! 3
| 0 || 0 || 0 || 1 || 1 || 0
|-
! 4
| 1 || 1 || 1 || 0 || 0 || 0
|-
! <span style="font-weight:bold; color:red">5</span>
| 0 || 0 || <span style="font-weight:bold; color:red">1</span> || <span style="font-weight:bold; color:red">1</span> || 0 || 0
|-
! 6
| 0 || 0 || 0 || 1 || 1 || 0
|-
! 7
| 1 || 0 || 1 || 0 || 1 || 1
|}
 
=== Dual example ===
 
But there is another exact hitting set problem that is essentially the same as the [[#Detailed example|detailed exact cover example]] above, in which numbered elements become subsets and lettered subsets become elements, effectively inverting the relation between subsets and element.
 
For example, as the subset ''B'' contains the elements 1 and 4 in the exact cover problem, the subsets ''I'' and ''IV'' contain the element ''b'' in the dual exact hitting set problem.
 
In particular, let <math>\mathcal{S}</math> =  {''I'', ''II'', ''III'', ''IV'', ''V'', ''VI'', ''VII''} be a collection of subsets of a set ''X'' = {''a'', ''b'', ''c'', ''d'', ''e'', ''f''} such that:
* ''I'' = {''a'', <span style="font-weight:bold; color:red">''b''</span>}
* ''II'' = {''e'', <span style="font-weight:bold; color:red">''f''</span>}
* ''III'' = {<span style="font-weight:bold; color:red">''d''</span>, ''e''}
* ''IV'' = {''a'', <span style="font-weight:bold; color:red">''b''</span>, ''c''}
* ''V'' = {''c'', <span style="font-weight:bold; color:red">''d''</span>}
* ''VI'' = {<span style="font-weight:bold; color:red">''d''</span>, ''e''}
* ''VII'' = {''a'', ''c'', ''e'', <span style="font-weight:bold; color:red">''f''</span>}
 
Then ''X*'' = {''b'', ''d'', ''f''} is an exact hitting set, since each subset in <math>\mathcal{S}</math> contains (is hit by) exactly one element in ''X*'', as the highlighting makes clear.
 
The exact hitting set ''X*'' = {''b'', ''d'', ''f''} here is essentially the same as the exact cover <math>\mathcal{S}^*</math> = {''B'', ''D'', ''F''} above, as the matrix representation makes clear:
 
:{| border="1" cellpadding="5" cellspacing="0"
! !! ''I'' !! ''II'' !! ''III'' !! ''IV'' !! ''V'' !! ''VI'' !! ''VII''
|-
! ''a''
| 1 || 0 || 0 || 1 || 0 || 0 || 1
|-
! <span style="font-weight:bold; color:red">''b''</span>
| <span style="font-weight:bold; color:red">1</span> || 0 || 0 || <span style="font-weight:bold; color:red">1</span> || 0 || 0 || 0
|-
! ''c''
| 0 || 0 || 0 || 1 || 1 || 0 || 1
|-
! <span style="font-weight:bold; color:red">''d''</span>
| 0 || 0 || <span style="font-weight:bold; color:red">1</span> || 0 || <span style="font-weight:bold; color:red">1</span> || <span style="font-weight:bold; color:red">1</span> || 0
|-
! ''e''
| 0 || 1 || 1 || 0 || 0 || 1 || 1
|-
! <span style="font-weight:bold; color:red">''f''</span>
| 0 || <span style="font-weight:bold; color:red">1</span> || 0 || 0 || 0 || 0 || <span style="font-weight:bold; color:red">1</span>
|}
 
== Finding solutions ==
 
[[Knuth's Algorithm X]] is a [[Recursion (computer science)|recursive]], [[Nondeterministic algorithm|nondeterministic]], [[depth-first]], [[backtracking]] [[algorithm]] that finds all solutions to the exact cover problem.
 
[[Dancing Links]], commonly known as DLX, is the technique suggested by [[Donald Knuth]] to efficiently implement his Algorithm X on a computer.
Dancing Links uses the matrix representation of the problem.
Dancing Links implements the matrix as a series of [[doubly linked list]]s of the 1s of the matrix:
each 1 element has a link to the next 1 above, below, to the left, and to the right of itself.
 
== Generalizations ==
 
In a standard exact cover problem, each constraint must be satisfied exactly once.
It is a simple generalization to relax this requirement slightly and allow for the possibility that some "primary" constraints must be satisfied by ''exactly one'' selection but other "secondary" constraints can be satisfied by ''at most one'' selection.
 
As Knuth explains, a generalized exact cover problem can be converted to an equivalent exact cover problem by simply appending one row for each secondary column, containing a single 1 in that column.<ref>Donald Knuth explains this simple generalization in his paper "Dancing Links," in particular, in explaining the tetrastick and [[N queens problem|N queens]] problems.</ref> If in a particular candidate solution a particular secondary column is satisfied, then the added row isn't needed.
But if the secondary column isn't satisfied, as is allowed in the generalized problem but not the standard problem, then the added row can be selected to ensure the column is satisfied.
 
But Knuth goes on to explain that it is better working with the generalized problem directly, because the generalized algorithm is simpler and faster:
A simple change to his Algorithm X allows secondary columns to be handled directly.
 
The [[N queens problem]] is an example of a generalized exact cover problem, as the constraints corresponding to the diagonals of the chessboard have a maximum rather than an exact queen count.
 
== Noteworthy examples ==
 
Due to its NP-completeness, any problem in NP can be [[reduction (complexity)|reduced]] to exact cover problems, which then can be solved with techniques such as Dancing Links.
However, for some well known problems, the reduction is particularly direct.
For instance, the problem of tiling a board with [[pentominoes]], and solving [[Sudoku]] can both be viewed as exact cover problems.
 
=== Pentomino tiling ===
 
{{main|Pentomino}}
 
The problem of tiling a 60-square board with 12 [[pentominoes]] is an example of an exact cover problem, as [[Donald Knuth]] explains in his paper "Dancing links."<ref name="knuth">{{cite arxiv | author = [[Donald Knuth|Knuth, Donald]] | title = Dancing links | year = 2000 | eprint = cs/0011047 }}</ref>
 
For example, consider the problem of tiling with pentominoes an 8×8 chessboard with the 4 central squares removed:
 
:{| border="1" cellpadding="5" cellspacing="0"
| 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18
|-
| 21 || 22 || 23 || 24 || 25 || 26 || 27 || 28
|-
| 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38
|-
| 41 || 42 || 43 ||    ||    || 46 || 47 || 48
|-
| 51 || 52 || 53 ||    ||    || 56 || 57 || 58
|-
| 61 || 62 || 63 || 64 || 65 || 66 || 67 || 68
|-
| 71 || 72 || 73 || 74 || 75 || 76 || 77 || 78
|-
| 81 || 82 || 83 || 84 || 85 || 86 || 87 || 88
|}
 
The problem involves two kinds of constraints:
: '''Pentomino:''' For each of the 12 pentominoes, there is the constraint that it must be placed exactly once. Name these constraints after the corresponding pentominoes: F I L P N T U V W X Y Z.<ref>{{cite book | last = Golomb | first = Solomon W. | authorlink = Solomon W. Golomb | coauthors = Warren Lushbaugh | title = Polyominoes: Puzzles, Patterns, Problems, and Packings | edition = 2nd | publisher = Princeton University Press | location = Princeton, New Jersey | year = 1994 | isbn = 0-691-02444-8 | page = 7 }}</ref>
: '''Square:''' For each of the 60 squares, there is the constraint that it must be covered by a pentomino exactly once. Name these constraints after the corresponding squares in the board: ''ij'', where ''i'' is the rank and ''j'' is the file.
 
Thus there are 12+60 = 72 constraints in all.
 
As both kinds of constraints are "exactly one" constraints, the problem is an exact cover problem.
 
The problem involves many choices, one for each way to place a pentomino on the board.
It is convenient to consider each choice as a sets of 6 constraints: 1 constraint for the pentomino being placed and 5 constraints for the five squares where it is placed.
 
In the case of an 8×8 chessboard with the 4 central squares removed, there are 1568 such choices, for example:
* {F, 12, 13, 21, 22, 32}
* {F, 13, 14, 22, 23, 33}
* …
* {I, 11, 12, 13, 14, 15}
* {I, 12, 13, 14, 15, 16}
* …
* {L, 11, 21, 31, 41, 42}
* {L, 12, 22, 32, 42, 43}
* …
 
One of many solutions of this exact cover problem is the following set of 12 choices:
* {I, 11, 12, 13, 14, 15}
* {N, 16, 26, 27, 37, 47}
* {L, 17, 18, 28, 38, 48}
* {U, 21, 22, 31, 41, 42}
* {X, 23, 32, 33, 34, 43}
* {W, 24, 25, 35, 36, 46}
* {P, 51, 52, 53, 62, 63}
* {F, 56, 64, 65, 66, 75}
* {Z, 57, 58, 67, 76, 77}
* {T, 61, 71, 72, 73, 81}
* {V, 68, 78, 86, 87, 88}
* {Y, 74, 82, 83, 84, 85}
 
This set of choices corresponds to the following solution to the pentomino tiling problem:
 
[[File:Pentomino Puzzle Solution 8x8 Minus Center.svg|none|300px]]
 
A pentomino tiling problem is more naturally viewed as an exact cover problem than an exact hitting set problem, because it is more natural to view each choice as a set of constraints than each constraint as a set of choices.
Each choice is related to just 6 constraints, which are easy to enumerate. On the other hand, each constraint is related to many choices, which are harder to enumerate.
 
Whether viewed as an exact cover problem or an exact hitting set problem, the matrix representation is the same, having 1568 rows corresponding to choices and 72 columns corresponding to constraints.
Each row contains a single 1 in the column identifying the pentomino and five 1s in the columns identifying the squares covered by the pentomino.
Using the matrix, a computer can find all solutions relatively quickly, for example, using [[Dancing Links]].
 
See also [http://yucs.org/~gnivasch/pentomino/ Solving Pentomino Puzzles with Backtracking].
 
=== Sudoku ===
 
{{main|Sudoku}}
 
The problem in [[Sudoku]] is to assign numbers (or digits, values, symbols) to cells (or squares) in a grid so as to satisfy certain constraints.
 
In the standard 9×9 Sudoku variant, there are four kinds of constraints:
: '''Row-Column:'''  Each intersection of a row and column, i.e, each cell, must contain exactly one number.
: '''Row-Number:'''  Each row must contain each number exactly once
: '''Column-Number:'''  Each column must contain each number exactly once.
: '''Box-Number:'''  Each box must contain each number exactly once.
 
While the first constraint might seem trivial, it is nevertheless needed to ensure there is only one number per cell.  Intuitively, placing a number into a cell prohibits placing that number in any other cell sharing the same column, row, or box and also prohibits ''placing any other number'' into the now occupied cell. 
 
Solving Sudoku is an exact cover problem.
 
More precisely, solving Sudoku is an exact [[hitting set]] problem, which is equivalent to an exact cover problem, when viewed as a problem to select possibilities such that each constraint set contains (i.e., is hit by) exactly one selected possibility.
In the notation above for the (generalized) exact cover problem, ''X'' is the set of possibilities, ''Y'' is a set of constraint sets, and ''R'' is the binary relation "is contained in."
 
Each possible assignment of a particular number to a particular cell is a '''possibility''' (or candidate).
When Sudoku is played with pencil and paper, possibilities are often called pencil marks.
 
In the standard 9×9 Sudoku variant, in which each of 9×9 cells is assigned one of 9 numbers, there are 9×9×9=729 possibilities.
Using obvious notation for rows, columns and numbers, the possibilities can be labeled
: R1C1#1, R1C1#2, …, R9C9#9.
 
The fact that each kind of constraint involves exactly one of something is what makes Sudoku an exact hitting set problem.
The constraints can be represented by '''constraint sets'''.
The problem is to select possibilities such that each constraint set contains (i.e., is hit by) exactly one selected possibility.
 
In the standard 9×9 Sudoku variant, there are four kinds of constraints sets corresponding to the four kinds of constraints:
 
: '''Row-Column:''' A row-column constraint set contains all the possibilities for the intersection of a particular row and column, i.e., for a cell. For example, the constraint set for row 1 and column 1, which can be labeled R1C1, contains the 9 possibilities for row 1 and column 1 but different numbers:
::  R1C1 = { R1C1#1, R1C1#2, R1C1#3, R1C1#4, R1C1#5, R1C1#6, R1C1#7, R1C1#8, R1C1#9 }.
 
: '''Row-Number:''' A row-number constraint set contains all the possibilities for a particular row and number. For example, the constraint set for row 1 and number 1, which can be labeled R1#1, contains the 9 possibilities for row 1 and number 1 but different columns:
:: R1#1 = { R1C1#1, R1C2#1, R1C3#1, R1C4#1, R1C5#1, R1C6#1, R1C7#1, R1C8#1, R1C9#1 }.
 
: '''Column-Number:''' A column-number constraint set contains all the possibilities for a particular column and number. For example, the constraint set for column 1 and number 1, which can be labeled C1#1, contains the 9 possibilities for column 1 and number 1 but different rows:
:: C1#1 = { R1C1#1, R2C1#1, R3C1#1, R4C1#1, R5C1#1, R6C1#1, R7C1#1, R8C1#1, R9C1#1 }.
 
: '''Box-Number:''' A box-number constraint set contains all the possibilities for a particular box and number. For example, the constraint set for box 1 (in the upper lefthand corner) and number 1, which can be labeled B1#1, contains the 9 possibilities for the cells in box 1 and number 1:
:: B1#1 = { R1C1#1, R1C2#1, R1C3#1, R2C1#1, R2C2#1, R2C3#1, R3C1#1, R3C2#1, R3C3#1 }.
 
Since there are 9 rows, 9 columns, 9 boxes and 9 numbers, there are 9×9=81 row-column constraint sets, 9×9=81 row-number constraint sets,  9×9=81 column-number constraint sets,  and 9×9=81 box-number constraint sets: 81+81+81+81=324 constraint sets in all.
 
In brief, the standard 9×9 Sudoku variant is an exact hitting set problem with 729 possibilities and 324 constraint sets.
Thus the problem can be represented by a 729×324 matrix.
 
Although it is difficult to present the entire 729×324 matrix, the general nature of the matrix can be seen from several snapshots:
{| cellspacing="30"
|- valign="top"
|
{| border="1" cellpadding="5" cellspacing="0" style="text-align:center"
|+ '''Row-Column Constraints'''
!
! R1<br>C1 !! R1<br>C2 !! …
|-
! R1C1#1
| 1 || 0 || …
|-
! R1C1#2
| 1 || 0 || …
|-
! R1C1#3
| 1 || 0 || …
|-
! R1C1#4
| 1 || 0 || …
|-
! R1C1#5
| 1 || 0 || …
|-
! R1C1#6
| 1 || 0 || …
|-
! R1C1#7
| 1 || 0 || …
|-
! R1C1#8
| 1 || 0 || …
|-
! R1C1#9
| 1 || 0 || …
|-
! R1C2#1
| 0 || 1 || …
|-
! R1C2#2
| 0 || 1 || …
|-
! R1C2#3
| 0 || 1 || …
|-
! R1C2#4
| 0 || 1 || …
|-
! R1C2#5
| 0 || 1 || …
|-
! R1C2#6
| 0 || 1 || …
|-
! R1C2#7
| 0 || 1 || …
|-
! R1C2#8
| 0 || 1 || …
|-
! R1C2#9
| 0 || 1 || …
|-
! …
| … || … || …
|}
|
{| border="1" cellpadding="5" cellspacing="0" style="text-align:center"
|+ '''Row-Number Constraints'''
!
! R1<br>#1 !! R1<br>#2 !! …
|-
! R1C1#1
| 1 || 0 || …
|-
! R1C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C2#1
| 1 || 0 || …
|-
! R1C2#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C3#1
| 1 || 0 || …
|-
! R1C3#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C4#1
| 1 || 0 || …
|-
! R1C4#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C5#1
| 1 || 0 || …
|-
! R1C5#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C6#1
| 1 || 0 || …
|-
! R1C6#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C7#1
| 1 || 0 || …
|-
! R1C7#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C8#1
| 1 || 0 || …
|-
! R1C8#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C9#1
| 1 || 0 || …
|-
! R1C9#2
| 0 || 1 || …
|-
! …
| … || … || …
|}
|
{| border="1" cellpadding="5" cellspacing="0" style="text-align:center"
|+ '''Column-Number Constraints'''
!
! C1<br>#1 !! C1<br>#2 !! …
|-
! R1C1#1
| 1 || 0 || …
|-
! R1C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R2C1#1
| 1 || 0 || …
|-
! R2C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R3C1#1
| 1 || 0 || …
|-
! R3C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R4C1#1
| 1 || 0 || …
|-
! R4C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R5C1#1
| 1 || 0 || …
|-
! R5C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R6C1#1
| 1 || 0 || …
|-
! R6C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R7C1#1
| 1 || 0 || …
|-
! R7C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R8C1#1
| 1 || 0 || …
|-
! R8C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R9C1#1
| 1 || 0 || …
|-
! R9C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|}
|
{| border="1" cellpadding="5" cellspacing="0" style="text-align:center"
|+ '''Box-Number Constraints'''
!
! B1<br>#1 !! B1<br>#2 !! …
|-
! R1C1#1
| 1 || 0 || …
|-
! R1C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C2#1
| 1 || 0 || …
|-
! R1C2#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R1C3#1
| 1 || 0 || …
|-
! R1C3#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R2C1#1
| 1 || 0 || …
|-
! R2C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R2C2#1
| 1 || 0 || …
|-
! R2C2#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R2C3#1
| 1 || 0 || …
|-
! R2C3#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R3C1#1
| 1 || 0 || …
|-
! R3C1#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R3C2#1
| 1 || 0 || …
|-
! R3C2#2
| 0 || 1 || …
|-
! …
| … || … || …
|-
! R3C3#1
| 1 || 0 || …
|-
! R3C3#2
| 0 || 1 || …
|-
! …
| … || … || …
|}
|}
 
The [http://www.stolaf.edu/people/hansonr/sudoku/exactcovermatrix.htm complete 729×324 matrix] is available from Bob Hanson.
 
Note that the set of possibilities R''x''C''y''#''z'' can be arranged as a 9×9×9 cube in a 3-dimensional space with coordinates ''x'', ''y'', and ''z''.
Then each row R''x'', column C''y'', or number #''z'' is a 9×9×1 "slice" of possibilities; each box B''w'' is a 9x3×3 "tube" of possibilities; each row-column constraint set R''x''C''y'', row-number constraint set R''x''#''z'', or column-number constraint set C''y''#''z'' is a 9x1×1 "strip" of possibilities; each box-number constraint set B''w''#''z'' is a 3x3×1 "square" of possibilities; and each possibility R''x''C''y''#''z'' is a 1x1×1 "cubie" consisting of a single possibility.
Moreover, each constraint set or possibility is the [[intersection (set theory)|intersection]] of the component sets.
For example, R1C2#3 = R1 ∩ C2 ∩ #3, where ∩ denotes set intersection.
 
Although other Sudoku variations have different numbers of rows, columns, numbers and/or different kinds of constraints, they all involve possibilities and constraint sets, and thus can be seen as exact hitting set problems.
 
=== ''N'' queens problem ===
 
{{main|N queens problem}}
{{Expand section|date=July 2008}}
 
The [[N queens problem|''N'' queens problem]] is an example of a generalized exact cover problem.<ref name="knuth"/> The problem involves four kinds of constraints:
: '''Rank:''' For each of the ''N'' ranks, there must be exactly one queen.
: '''File:''' For each of the ''N'' files, there must be exactly one queen.
: '''Diagonals:''' For each of the 2''N''&nbsp;&minus;&nbsp;1 diagonals, there must be at most one queen.
: '''Reverse diagonals:''' For each of the 2''N''&nbsp;&minus;&nbsp;1 reverse diagonals, there must be at most one queen.
 
Note that the 2''N'' rank and file constraints form the primary constraints, while the 4''N''&nbsp;&minus;&nbsp;2 diagonal and reverse diagonals form the secondary constraints. Further, because the each of first and last diagonal and reverse diagonals involve only one square on the chessboard, these can be omitted and thus we can reduce the number of secondary constraints to 4''N''&nbsp;&minus;&nbsp;6. The matrix for the ''N'' queens problem then have ''N''<sup>2</sup> rows and 6''N''&nbsp;&minus;&nbsp;6 columns, each row for a possible queen placement on each square on the chessboard, and each column for each constraint.
 
== See also ==
 
* [[Constraint satisfaction problem]]
* [[Dancing Links]]
* [[Difference map algorithm]]
* [[Hitting set]]
* [[Karp's 21 NP-complete problems]]
* [[Knuth's Algorithm X]]
* [[List of NP-complete problems]]
* [[Perfect matching]] and [[3-dimensional matching]] are special cases of the exact cover problem
 
== References ==
 
{{reflist}}
* {{cite web
| last = Dahlke
| first = K
| title = Exact cover
| work = Math Reference Project
| url = http://www.mathreference.com/lan-cx-np,excov.html
| accessdate = 2008-06-21
}}
 
==External links==
*[http://cheeso.members.winisp.net/srcview.aspx?dir=Sudoku&file=ExactCover.cs Implementation of an Exact Cover solver in C#] - uses Algorithm X and Dancing Links.
 
{{DEFAULTSORT:Exact Cover}}
[[Category:Theoretical computer science]]
[[Category:NP-complete problems]]

Revision as of 04:10, 13 November 2013

In mathematics, 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 computer science, the exact cover problem is a decision problem to find an exact cover or else determine none exists. The exact cover problem is NP-complete[1] and is one of Karp's 21 NP-complete problems.[2] The exact cover problem is a kind of constraint satisfaction problem.

An exact cover problem can be represented by an incidence matrix or a bipartite graph.

Knuth's Algorithm X is an algorithm that finds all solutions to an exact cover problem. Dancing Links, commonly known as DLX, is the technique suggested by Donald Knuth to efficiently implement his Algorithm X on a computer.

The standard exact cover problem can be generalized slightly to involve not only "exactly one" constraints but also "at-most-one" constraints.

Finding Pentomino tilings and solving Sudoku are noteworthy examples of exact cover problems. The N queens problem is a slightly 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:

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:

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:

Basic examples

Let = {N, O, E, P} be a collection of subsets of a set X = {1, 2, 3, 4} such that:

  • N = { },
  • O = {1, 3},
  • E = {2, 4}, and
  • P = {2, 3}.

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. The intersection of the subsets E and P, {2}, is not empty: The subsets E and P are not disjoint. Moreover, the union of the subsets E and P, {2, 3, 4}, is not X = {1, 2, 3, 4}: Neither E nor P covers the element 1.

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 = {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}.

Then the subcollection = {B, D, F} is an exact cover, since each element in X is contained in exactly one of the subsets:

  • B = {1, 4};
  • D = {3, 5, 6}; or
  • F = {2, 7}.

Moreover, {B, D, F} is the only exact cover, as the following argument demonstrates: Because A and B are the only subsets containing 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 an element in common with A. Then D is the only remaining subset, but the collection {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 an element in common with B. Because D is the only remaining subset containing 5, D must be part of the exact cover. If an exact cover contains D, then it doesn't contain E, as E has an element in common with D. Then F is the only remaining subset, and the collection {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 binary relation "contains" between subsets in and elements in X. There are different equivalent ways to represent this relation.

Standard representation

The standard way to represent the relation "contains" is to list the elements in each subset.

For example, the detailed example above uses this standard representation:

  • A = {1, 4, 7};
  • B = {1, 4};
  • C = {4, 5, 7};
  • D = {3, 5, 6};
  • E = {2, 3, 6, 7}; and
  • F = {2, 7}.

Again, the subcollection = {B, D, F} is an exact cover, since each element is contained in exactly one selected subset, as the highlighting makes clear.

Inverse representation

The relation "contains" between subsets and elements can be inverted, listing the subsets each element is contained in.

For example, the relation "contains" in the detailed example above can be represented by listing the subsets each element is contained in:

  • 1 is contained in A, B;
  • 2 is contained in E, F;
  • 3 is contained in D, E;
  • 4 is contained in A, B, C;
  • 5 is contained in C, D;
  • 6 is contained in D, E; and
  • 7 is contained in A, C, E, F.

Again, the subcollection = {B, D, F} is an exact cover, since each element is contained in exactly one selected subset, as the highlighting makes clear.

When solving an exact cover problem, it is often useful to switch between the standard and inverse representations.

Matrix and hypergraph representations

The relation "contains" can be represented by an incidence matrix.

The matrix includes one row for each subset in and one column for each element in X. The entry in a particular row and column is 1 if the corresponding subset contains the corresponding element, and is 0 otherwise. As each row represents the elements contained in the corresponding subset and each column represents the subsets containing the corresponding element, an incidence matrix effectively provides both the standard and inverse representations.

In the matrix representation, an exact cover is a selection of rows such that each column contains a 1 in exactly one selected row.

For example, the relation "contains" in the detailed example above can be represented by a 6×7 incidence matrix:[3]

1 2 3 4 5 6 7
A 1 0 0 1 0 0 1
B 1 0 0 1 0 0 0
C 0 0 0 1 1 0 1
D 0 0 1 0 1 1 0
E 0 1 1 0 0 1 1
F 0 1 0 0 0 0 1

Again, the subcollection = {B, D, F} is an exact cover, since each element is contained in exactly one selected subset, i.e., each column contains a 1 in exactly one selected row, as the highlighting makes clear.

See the example in the article on Knuth's Algorithm X for a matrix-based solution to the detailed example above.

In turn, the incidence matrix can be seen also as describing a hypergraph. The hypergraph includes one node for each element in X and one edge for each subset in ; each node is included in exactly one of the edges forming the cover.

Graph representation

The relation "contains" can be represented by a bipartite graph.

The vertices of the graph are divided into two disjoint sets, one representing the subsets in and another representing the elements in X. If a subset contains an element, an edge connects the corresponding vertices in the graph.

In the graph representation, an exact cover is a selection of vertices corresponding to subsets such that each vertex corresponding to an element is connected to exactly one selected vertex.

For example, the relation "contains" in the detailed example above can be represented by a bipartite graph with 6+7 = 13 vertices:

Again, the subcollection = {B, D, F} is an exact cover, since each element is contained in exactly one selected subset, i.e., the vertex corresponding to each element in X is connected to exactly one selected vertex, as the highlighting makes clear.

Equivalent problems

Although the canonical exact cover problem involves a collection of subsets of a set X, the logic does not depend on the presence of subsets containing elements. An "abstract exact cover problem" arises whenever there is a binary relation between two sets P and Q and the goal is to select a subset P* of P such that each element in Q is related to exactly one element in P*. In general, the elements of P represent choices and the elements of Q represent "exactly one" constraints on those choices.

More formally, given a binary relation R P × Q between sets P and Q, one can call a subset P* of P an "abstract exact cover" of Q if each element in Q is R -1-related to exactly one element in P*. Here R -1 is the inverse of R.

In general, R -1 restricted to Q × P* is a function from Q to P*, which maps each element in Q to the unique element in P* that is R-related that element in Q. This function is onto, unless P* contains the "empty set," i.e., an element which isn't R-related to any element in Q.

In the canonical exact cover problem, P is a collection of subsets of X, Q is the set X, R is the binary relation "contains" between subsets and elements, and R -1 restricted to Q × P* is the function "is contained in" from elements to selected subsets.

Exact hitting set

In mathematics, given a collection of subsets of a set X, an exact hitting set X* is a subset of X such that each subset in contains exactly one element in X*. One says that each subset in is hit by exactly one element in X*.

In computer science, the exact hitting set problem is a decision problem to find an exact hitting set or else determine none exists.

The exact hitting set problem is an abstract exact cover problem. In the notation above, P is the set X, Q is a collection of subsets of X, R is the binary relation "is contained in" between elements and subsets, and R -1 restricted to Q × P* is the function "contains" from subsets to selected elements.

Whereas an exact cover problem involves selecting subsets and the relation "contains" from subsets to elements, an exact hitting set problem involves selecting elements and the relation "is contained in" from elements to subsets. In a sense, an exact hitting set problem is the inverse of the exact cover problem involving the same set and collection of subsets.

Exact hitting set example

As in the detailed exact cover example above, let = {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}.

Then X* = {1, 2, 5} is an exact hitting set, since each subset in contains exactly one element in X*, as the highlighting makes clear.

Moreover, {1, 2, 5} is the only exact hitting set, as the following argument demonstrates: Because 2 and 7 are the only elements that hit F, an exact hitting set must contain 2 or 7, but not both. If an exact hitting set contains 7, then it doesn't contain 1, 2, 3, 4, 5, or 6, as each of these elements are contained in some subset also containing 7. Then there are no more remaining elements, but {7} is not an exactly hitting set, as it doesn't hit B or D. In conclusion, there is no exact hitting set containing 7. On the other hand, if an exact hitting set contains 2, then it doesn't contain 3, 6, or 7, as each of these elements are contained in some subset also containing 2. Because 5 is the only remaining element that hits D, the exact hitting set must contain 5. If an exact hitting set contains 5, then it doesn't contain 4, as both hit C. Because 1 is the only remaining element that hits A, the exact hitting set must contain 1. Then there are no more remaining elements, and {1, 2, 5} is indeed an exact hitting set.

Although this example involves the same collection of subsets as the detailed exact cover example above, it is essentially a different problem. In a sense, the exact hitting set problem is the inverse (or transpose or converse) of the corresponding exact cover problem above, as the matrix representation makes clear:

A B C D E F
1 1 1 0 0 0 0
2 0 0 0 0 1 1
3 0 0 0 1 1 0
4 1 1 1 0 0 0
5 0 0 1 1 0 0
6 0 0 0 1 1 0
7 1 0 1 0 1 1

Dual example

But there is another exact hitting set problem that is essentially the same as the detailed exact cover example above, in which numbered elements become subsets and lettered subsets become elements, effectively inverting the relation between subsets and element.

For example, as the subset B contains the elements 1 and 4 in the exact cover problem, the subsets I and IV contain the element b in the dual exact hitting set problem.

In particular, let = {I, II, III, IV, V, VI, VII} be a collection of subsets of a set X = {a, b, c, d, e, f} such that:

  • I = {a, b}
  • II = {e, f}
  • III = {d, e}
  • IV = {a, b, c}
  • V = {c, d}
  • VI = {d, e}
  • VII = {a, c, e, f}

Then X* = {b, d, f} is an exact hitting set, since each subset in contains (is hit by) exactly one element in X*, as the highlighting makes clear.

The exact hitting set X* = {b, d, f} here is essentially the same as the exact cover = {B, D, F} above, as the matrix representation makes clear:

I II III IV V VI VII
a 1 0 0 1 0 0 1
b 1 0 0 1 0 0 0
c 0 0 0 1 1 0 1
d 0 0 1 0 1 1 0
e 0 1 1 0 0 1 1
f 0 1 0 0 0 0 1

Finding solutions

Knuth's Algorithm X is a recursive, nondeterministic, depth-first, backtracking algorithm that finds all solutions to the exact cover problem.

Dancing Links, commonly known as DLX, is the technique suggested by Donald Knuth to efficiently implement his Algorithm X on a computer. Dancing Links uses the matrix representation of the problem. Dancing Links implements the matrix as a series of doubly linked lists of the 1s of the matrix: each 1 element has a link to the next 1 above, below, to the left, and to the right of itself.

Generalizations

In a standard exact cover problem, each constraint must be satisfied exactly once. It is a simple generalization to relax this requirement slightly and allow for the possibility that some "primary" constraints must be satisfied by exactly one selection but other "secondary" constraints can be satisfied by at most one selection.

As Knuth explains, a generalized exact cover problem can be converted to an equivalent exact cover problem by simply appending one row for each secondary column, containing a single 1 in that column.[4] If in a particular candidate solution a particular secondary column is satisfied, then the added row isn't needed. But if the secondary column isn't satisfied, as is allowed in the generalized problem but not the standard problem, then the added row can be selected to ensure the column is satisfied.

But Knuth goes on to explain that it is better working with the generalized problem directly, because the generalized algorithm is simpler and faster: A simple change to his Algorithm X allows secondary columns to be handled directly.

The N queens problem is an example of a generalized exact cover problem, as the constraints corresponding to the diagonals of the chessboard have a maximum rather than an exact queen count.

Noteworthy examples

Due to its NP-completeness, any problem in NP can be reduced to exact cover problems, which then can be solved with techniques such as Dancing Links. However, for some well known problems, the reduction is particularly direct. For instance, the problem of tiling a board with pentominoes, and solving Sudoku can both be viewed as exact cover problems.

Pentomino tiling

Mining Engineer (Excluding Oil ) Truman from Alma, loves to spend time knotting, largest property developers in singapore developers in singapore and stamp collecting. Recently had a family visit to Urnes Stave Church.

The problem of tiling a 60-square board with 12 pentominoes is an example of an exact cover problem, as Donald Knuth explains in his paper "Dancing links."[5]

For example, consider the problem of tiling with pentominoes an 8×8 chessboard with the 4 central squares removed:

11 12 13 14 15 16 17 18
21 22 23 24 25 26 27 28
31 32 33 34 35 36 37 38
41 42 43 46 47 48
51 52 53 56 57 58
61 62 63 64 65 66 67 68
71 72 73 74 75 76 77 78
81 82 83 84 85 86 87 88

The problem involves two kinds of constraints:

Pentomino: For each of the 12 pentominoes, there is the constraint that it must be placed exactly once. Name these constraints after the corresponding pentominoes: F I L P N T U V W X Y Z.[6]
Square: For each of the 60 squares, there is the constraint that it must be covered by a pentomino exactly once. Name these constraints after the corresponding squares in the board: ij, where i is the rank and j is the file.

Thus there are 12+60 = 72 constraints in all.

As both kinds of constraints are "exactly one" constraints, the problem is an exact cover problem.

The problem involves many choices, one for each way to place a pentomino on the board. It is convenient to consider each choice as a sets of 6 constraints: 1 constraint for the pentomino being placed and 5 constraints for the five squares where it is placed.

In the case of an 8×8 chessboard with the 4 central squares removed, there are 1568 such choices, for example:

  • {F, 12, 13, 21, 22, 32}
  • {F, 13, 14, 22, 23, 33}
  • {I, 11, 12, 13, 14, 15}
  • {I, 12, 13, 14, 15, 16}
  • {L, 11, 21, 31, 41, 42}
  • {L, 12, 22, 32, 42, 43}

One of many solutions of this exact cover problem is the following set of 12 choices:

  • {I, 11, 12, 13, 14, 15}
  • {N, 16, 26, 27, 37, 47}
  • {L, 17, 18, 28, 38, 48}
  • {U, 21, 22, 31, 41, 42}
  • {X, 23, 32, 33, 34, 43}
  • {W, 24, 25, 35, 36, 46}
  • {P, 51, 52, 53, 62, 63}
  • {F, 56, 64, 65, 66, 75}
  • {Z, 57, 58, 67, 76, 77}
  • {T, 61, 71, 72, 73, 81}
  • {V, 68, 78, 86, 87, 88}
  • {Y, 74, 82, 83, 84, 85}

This set of choices corresponds to the following solution to the pentomino tiling problem:

A pentomino tiling problem is more naturally viewed as an exact cover problem than an exact hitting set problem, because it is more natural to view each choice as a set of constraints than each constraint as a set of choices. Each choice is related to just 6 constraints, which are easy to enumerate. On the other hand, each constraint is related to many choices, which are harder to enumerate.

Whether viewed as an exact cover problem or an exact hitting set problem, the matrix representation is the same, having 1568 rows corresponding to choices and 72 columns corresponding to constraints. Each row contains a single 1 in the column identifying the pentomino and five 1s in the columns identifying the squares covered by the pentomino. Using the matrix, a computer can find all solutions relatively quickly, for example, using Dancing Links.

See also Solving Pentomino Puzzles with Backtracking.

Sudoku

Mining Engineer (Excluding Oil ) Truman from Alma, loves to spend time knotting, largest property developers in singapore developers in singapore and stamp collecting. Recently had a family visit to Urnes Stave Church.

The problem in Sudoku is to assign numbers (or digits, values, symbols) to cells (or squares) in a grid so as to satisfy certain constraints.

In the standard 9×9 Sudoku variant, there are four kinds of constraints:

Row-Column: Each intersection of a row and column, i.e, each cell, must contain exactly one number.
Row-Number: Each row must contain each number exactly once
Column-Number: Each column must contain each number exactly once.
Box-Number: Each box must contain each number exactly once.

While the first constraint might seem trivial, it is nevertheless needed to ensure there is only one number per cell. Intuitively, placing a number into a cell prohibits placing that number in any other cell sharing the same column, row, or box and also prohibits placing any other number into the now occupied cell.

Solving Sudoku is an exact cover problem.

More precisely, solving Sudoku is an exact hitting set problem, which is equivalent to an exact cover problem, when viewed as a problem to select possibilities such that each constraint set contains (i.e., is hit by) exactly one selected possibility. In the notation above for the (generalized) exact cover problem, X is the set of possibilities, Y is a set of constraint sets, and R is the binary relation "is contained in."

Each possible assignment of a particular number to a particular cell is a possibility (or candidate). When Sudoku is played with pencil and paper, possibilities are often called pencil marks.

In the standard 9×9 Sudoku variant, in which each of 9×9 cells is assigned one of 9 numbers, there are 9×9×9=729 possibilities. Using obvious notation for rows, columns and numbers, the possibilities can be labeled

R1C1#1, R1C1#2, …, R9C9#9.

The fact that each kind of constraint involves exactly one of something is what makes Sudoku an exact hitting set problem. The constraints can be represented by constraint sets. The problem is to select possibilities such that each constraint set contains (i.e., is hit by) exactly one selected possibility.

In the standard 9×9 Sudoku variant, there are four kinds of constraints sets corresponding to the four kinds of constraints:

Row-Column: A row-column constraint set contains all the possibilities for the intersection of a particular row and column, i.e., for a cell. For example, the constraint set for row 1 and column 1, which can be labeled R1C1, contains the 9 possibilities for row 1 and column 1 but different numbers:
R1C1 = { R1C1#1, R1C1#2, R1C1#3, R1C1#4, R1C1#5, R1C1#6, R1C1#7, R1C1#8, R1C1#9 }.
Row-Number: A row-number constraint set contains all the possibilities for a particular row and number. For example, the constraint set for row 1 and number 1, which can be labeled R1#1, contains the 9 possibilities for row 1 and number 1 but different columns:
R1#1 = { R1C1#1, R1C2#1, R1C3#1, R1C4#1, R1C5#1, R1C6#1, R1C7#1, R1C8#1, R1C9#1 }.
Column-Number: A column-number constraint set contains all the possibilities for a particular column and number. For example, the constraint set for column 1 and number 1, which can be labeled C1#1, contains the 9 possibilities for column 1 and number 1 but different rows:
C1#1 = { R1C1#1, R2C1#1, R3C1#1, R4C1#1, R5C1#1, R6C1#1, R7C1#1, R8C1#1, R9C1#1 }.
Box-Number: A box-number constraint set contains all the possibilities for a particular box and number. For example, the constraint set for box 1 (in the upper lefthand corner) and number 1, which can be labeled B1#1, contains the 9 possibilities for the cells in box 1 and number 1:
B1#1 = { R1C1#1, R1C2#1, R1C3#1, R2C1#1, R2C2#1, R2C3#1, R3C1#1, R3C2#1, R3C3#1 }.

Since there are 9 rows, 9 columns, 9 boxes and 9 numbers, there are 9×9=81 row-column constraint sets, 9×9=81 row-number constraint sets, 9×9=81 column-number constraint sets, and 9×9=81 box-number constraint sets: 81+81+81+81=324 constraint sets in all.

In brief, the standard 9×9 Sudoku variant is an exact hitting set problem with 729 possibilities and 324 constraint sets. Thus the problem can be represented by a 729×324 matrix.

Although it is difficult to present the entire 729×324 matrix, the general nature of the matrix can be seen from several snapshots:

Row-Column Constraints
R1
C1
R1
C2
R1C1#1 1 0
R1C1#2 1 0
R1C1#3 1 0
R1C1#4 1 0
R1C1#5 1 0
R1C1#6 1 0
R1C1#7 1 0
R1C1#8 1 0
R1C1#9 1 0
R1C2#1 0 1
R1C2#2 0 1
R1C2#3 0 1
R1C2#4 0 1
R1C2#5 0 1
R1C2#6 0 1
R1C2#7 0 1
R1C2#8 0 1
R1C2#9 0 1
Row-Number Constraints
R1
#1
R1
#2
R1C1#1 1 0
R1C1#2 0 1
R1C2#1 1 0
R1C2#2 0 1
R1C3#1 1 0
R1C3#2 0 1
R1C4#1 1 0
R1C4#2 0 1
R1C5#1 1 0
R1C5#2 0 1
R1C6#1 1 0
R1C6#2 0 1
R1C7#1 1 0
R1C7#2 0 1
R1C8#1 1 0
R1C8#2 0 1
R1C9#1 1 0
R1C9#2 0 1
Column-Number Constraints
C1
#1
C1
#2
R1C1#1 1 0
R1C1#2 0 1
R2C1#1 1 0
R2C1#2 0 1
R3C1#1 1 0
R3C1#2 0 1
R4C1#1 1 0
R4C1#2 0 1
R5C1#1 1 0
R5C1#2 0 1
R6C1#1 1 0
R6C1#2 0 1
R7C1#1 1 0
R7C1#2 0 1
R8C1#1 1 0
R8C1#2 0 1
R9C1#1 1 0
R9C1#2 0 1
Box-Number Constraints
B1
#1
B1
#2
R1C1#1 1 0
R1C1#2 0 1
R1C2#1 1 0
R1C2#2 0 1
R1C3#1 1 0
R1C3#2 0 1
R2C1#1 1 0
R2C1#2 0 1
R2C2#1 1 0
R2C2#2 0 1
R2C3#1 1 0
R2C3#2 0 1
R3C1#1 1 0
R3C1#2 0 1
R3C2#1 1 0
R3C2#2 0 1
R3C3#1 1 0
R3C3#2 0 1

The complete 729×324 matrix is available from Bob Hanson.

Note that the set of possibilities RxCy#z can be arranged as a 9×9×9 cube in a 3-dimensional space with coordinates x, y, and z. Then each row Rx, column Cy, or number #z is a 9×9×1 "slice" of possibilities; each box Bw is a 9x3×3 "tube" of possibilities; each row-column constraint set RxCy, row-number constraint set Rx#z, or column-number constraint set Cy#z is a 9x1×1 "strip" of possibilities; each box-number constraint set Bw#z is a 3x3×1 "square" of possibilities; and each possibility RxCy#z is a 1x1×1 "cubie" consisting of a single possibility. Moreover, each constraint set or possibility is the intersection of the component sets. For example, R1C2#3 = R1 ∩ C2 ∩ #3, where ∩ denotes set intersection.

Although other Sudoku variations have different numbers of rows, columns, numbers and/or different kinds of constraints, they all involve possibilities and constraint sets, and thus can be seen as exact hitting set problems.

N queens problem

Mining Engineer (Excluding Oil ) Truman from Alma, loves to spend time knotting, largest property developers in singapore developers in singapore and stamp collecting. Recently had a family visit to Urnes Stave Church.
Template:Expand section

The N queens problem is an example of a generalized exact cover problem.[5] The problem involves four kinds of constraints:

Rank: For each of the N ranks, there must be exactly one queen.
File: For each of the N files, there must be exactly one queen.
Diagonals: For each of the 2N − 1 diagonals, there must be at most one queen.
Reverse diagonals: For each of the 2N − 1 reverse diagonals, there must be at most one queen.

Note that the 2N rank and file constraints form the primary constraints, while the 4N − 2 diagonal and reverse diagonals form the secondary constraints. Further, because the each of first and last diagonal and reverse diagonals involve only one square on the chessboard, these can be omitted and thus we can reduce the number of secondary constraints to 4N − 6. The matrix for the N queens problem then have N2 rows and 6N − 6 columns, each row for a possible queen placement on each square on the chessboard, and each column for each constraint.

See also

References

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

External links

  1. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534 This book is a classic, developing the theory, then cataloguing many NP-Complete problems.
  2. 55 years old Systems Administrator Antony from Clarence Creek, really loves learning, PC Software and aerobics. Likes to travel and was inspired after making a journey to Historic Ensemble of the Potala Palace.

    You can view that web-site... ccleaner free download
  3. Donald Knuth in his paper "Dancing Links" gives this example, as equation (3), only with the rows reordered.
  4. Donald Knuth explains this simple generalization in his paper "Dancing Links," in particular, in explaining the tetrastick and N queens problems.
  5. 5.0 5.1 Template:Cite arxiv
  6. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534