1: %&biglatex
2: \documentclass{LMCS}
3:
4: \usepackage{amsmath,hyperref}
5:
6: \input{definitions.tex}
7: \input{defpart.tex}
8:
9: \def\doi{2 (4:1) 2006}
10: \lmcsheading%
11: {\doi}
12: {1--15}
13: {}
14: {}
15: {Jan.~\phantom{0}4, 2006}
16: {Sep.~27, 2006}
17: {}
18:
19: \begin{document}
20:
21: \title{Generalized Majority-Minority Operations are Tractable}
22:
23: \author[V.~Dalmau]{V\'{\i}ctor Dalmau}
24: \address{Departament de Tecnologia, Universitat Pompeu Fabra, \\
25: Estaci\'o de Fran\c{c}a, Passeig de la Circumval.lacio 8. Barcelona 08003, Spain}
26: \email{victor.dalmau@tecn.upf.es}
27:
28: \keywords{constraint satisfaction, complexity, Mal'tsev, near-unanimity}
29: \subjclass{F.4.1}
30:
31: \begin{abstract}
32:
33: Generalized majority-minority (GMM) operations are introduced as a
34: common generalization of near unanimity operations and Mal'tsev
35: operations on finite sets. We show that every instance of the
36: constraint satisfaction problem (CSP), where all constraint
37: relations are invariant under a (fixed) GMM operation, is solvable in
38: polynomial time. This constitutes one of the largest tractable cases
39: of the CSP.
40: \end{abstract}
41:
42: \maketitle
43:
44: \section{Introduction}
45:
46: Constraint satisfaction problems arise in a wide variety of domains,
47: such as combinatorics, logic, algebra, and artificial intelligence.
48: An instance of the constraint satisfaction problem (CSP)
49: consists of a set of variables, a set of values (which can be taken
50: by the variables), called domain, and a set of constraints,
51: where a constraint is a pair given by a list of variables, called
52: scope, and a relation indicating the valid combinations of values for
53: the variables in the scope;
54: the goal is to decide whether or not there is an assignment of values to the
55: variables satisfying all of the constraints.
56: It is well known that the CSP admits several different but equivalent definitions.
57: Feder and Vardi~\cite{Feder/Vardi:1998} formulated it as the problem of deciding whether
58: there
59: exists an homomorphism between two given relational structures. Also, an instance
60: of the CSP can be viewed as a positive primitive sentence; the question
61: is to decide whether or not the sentence is true.
62:
63: In its full generality the CSP is NP-complete. This fact motivates
64: the project of identifying restricted subclasses of the problem that
65: are solvable in polynomial time. The most customary way to restrict
66: the CSP is by fixing a set of relations $\Gamma$, generally called
67: {\em constraint language} or {\em basis} and consider only instances
68: of the CSP in which every relation appearing in a constraint belongs
69: to $\Gamma$; this restricted version of the problem is generally
70: denoted by $\csp(\Gamma)$. Much effort has been devoted to the goal
71: of isolating those constraint languages, $\Gamma$, for which its
72: associated constraint satisfaction problem, $\csp(\Gamma)$, is
73: polynomial-time solvable. Despite the large amount of results in
74: this
75: direction~\cite{Bulatov:3element,Bulatov:maltsev,Bulatov03:conservative,Bulatov04:graph,Bulatov:2semilattices,Bulatov/Jeavons/Volkov:2001,Bulatov/Krokhin/Jeavons:2000,Bulatov/Krokhin/Jeavons:2001,Chen/Dalmau:laac,Dalmau:2000,Dalmau/Gavalda/Tesson/Therien:05,Dalmau/Pearson:1999,Feder:nearsubgroup,Feder/Vardi:1998,Jeavons/Cohen/Cooper:1998,Jeavons/Cohen/Gyssens:1997,Kirousis:1993},
76: a complete classification is still not known.
77:
78: The other usual way to define subclasses of the general CSP is by
79: restricting the possible scopes, not the relations, that can appear
80: in a constraint. The state of affaires here is a way better: It has
81: been proved~\cite{Grohe:03} that, under certain plausible assumptions,
82: the tractable class identified in~\cite{Dalmau/Kolaitis/Vardi:02} is the only one,
83: settling completely the question.
84:
85: Our goal in this paper is to introduce a general condition, such that every constraint
86: language $\Gamma$ satisfying this condition, leads to a subclass of the CSP, $\csp(\Gamma)$,
87: solvable in polynomial time. In order to place our result in context it will be necessary to
88: include a short description of the cases of the CSP, known to be tractable.
89:
90: In our classification we shall distinguish between {\em pure} and {\em hybrid} tractable cases.
91: Intuitively, {\em pure} tractable cases are those that are explained by a simple and concrete
92: combinatorial principle whereas {\em hybrid} tractable cases are those that can be reduced (not necessarily
93: without a considerable degree of sophistication) to a combination of pure cases. Let us recall here that this distinction is our rather personal attempt
94: to classify the tractable cases of the CSP and does not pretend to be any claim about the ``true nature'' of the tractable
95: cases.
96:
97: According to our view there are basically three pure maximal
98: tractable cases: {\em width 1}, {\em bounded strict width}, and {\em
99: Mal'tsev} problems. This classification corresponds to the three
100: tractable families isolated in Feder and
101: Vardi~\cite{Feder/Vardi:1998}: width 1, bounded strict width, and
102: subgroup problems, in which the latter has been enlarged as to
103: include all Mal'tsev problems, proven to be tractable recently by
104: Bulatov~\cite{Bulatov:maltsev} (see also~\cite{Bulatov/Dalmau:05}).
105: The vast majority of tractable cases of the CSP identified in the
106: past (prior~\cite{Bulatov/Krokhin/Jeavons:2001}) fall in one of
107: these three pure categories. As an illustrative example consider the
108: six tractable cases in the boolean domain identified by
109: Schaefer~\cite{Schaefer:1978}, namely, $0$-valid, $1$-valid, Horn,
110: dual-Horn, bijunctive and affine problems. The first four classes
111: are particular instances of width 1 problems whereas the fifth and
112: sixth class belong to bounded strict width and Mal'tsev
113: respectively.
114:
115: In~\cite{Bulatov/Krokhin/Jeavons:2001}, the pursuit of new tractable cases of the CSP took
116: a new direction. The new class identified in~\cite{Bulatov/Krokhin/Jeavons:2001}, the so-called paper-scissor-stone problems,
117: could be regarded as constituted by an amalgam of Horn problems (and hence width 1 problems) and
118: dual discriminator problems~\cite{Cooper/Cohen/Jeavons:1994}, known to be particular instances of bounded strict width problems.
119: The algorithm devised in~\cite{Bulatov/Krokhin/Jeavons:2001} exploits the fact that the interaction between the width $1$ part and
120: the bounded strict width part of the instance is very constrained. The class of paper-scissor-stone problems
121: is the first hybrid tractable case.
122:
123: All tractable cases identified
124: after~\cite{Bulatov/Krokhin/Jeavons:2001} with the notable exception
125: of Mal'tsev problems are hybrid problems (the
126: references~\cite{Bulatov:3element,Bulatov03:conservative,Bulatov04:graph,Bulatov:2semilattices,Chen/Dalmau:laac,Dalmau/Gavalda/Tesson/Therien:05}
127: constitute, up to the best of our knowledge, a complete list).
128: Indeed, it is not daring to say that is very likely that much of the
129: future progress in the study of the complexity of the CSP will come
130: from a better understanding of the interaction between the different
131: sources of pure tractability.
132:
133:
134: A unifying framework for tractability of constraint satisfaction has been developed by Jeavons and coauthors
135: in a sequence of papers culminating in~\cite{Jeavons/Cohen/Gyssens:1997}; the key theme of this framework is that it is generally
136: possible to explain the tractability of a certain subclass of the CSP, $\csp(\Gamma)$, by means of
137: certain algebraic invariance properties of the relations in $\Gamma$. Consider, for instance,
138: the class of bounded strict width problems: It is well known~\cite{Feder/Vardi:1998} (see also~\cite{Jeavons/Cohen/Cooper:1998}) that a
139: constraint language
140: $\Gamma$ is bounded strict width if an only if there exists a near-unanimity operation
141: $\varphi$, namely, an operation $\varphi:A^k\rightarrow A$ with $k\geq 3$ satisfying
142: \begin{center}
143: $\varphi(x,y,..,y)=\varphi(y,x,..,y)=\cdots=\varphi(y,y,..,x)=y$
144: \end{center}
145: for all $x,y\in A$, such that every relation in $\Gamma$ is invariant under $\varphi$.
146:
147: In a similar vein, a constraint
148: language $\Gamma$ is Mal'tsev if all its relations are invariant under a Mal'tsev operation, ie,
149: an operation $\varphi:A^3\rightarrow A$ satisfying
150: $$\varphi(x,y,y)=\varphi(y,y,x)=x, \text{ for all } x,y\in A.$$
151:
152: Similar characterizations, in terms of algebraic invariance properties, are known for the vast majority of tractable
153: cases of the CSP. In fact, the connection between tractability of CSP and invariance properties is tighter,
154: as it can be shown that the complexity of a given subclass of the CSP, $\csp(\Gamma)$, depends {\em only}
155: on the the set of operations under which $\Gamma$ is invariant~\cite{Jeavons:1998}.
156:
157: Generalized majority-minority
158: operations first arose in the study of the learnability of relatively quantified generalized formulas~\cite{Bulatov/Chen/Dalmau:04}.
159: An operation $\varphi:A^k\rightarrow A$ with $k\geq 3$ is a
160: \emph{generalized majority-minority (GMM) operation} if
161: for all $a,b \in A$,
162: \begin{center}
163: $\varphi(x,y,..,y)=\varphi(y,x,..,y)=\cdots=\varphi(y,y,..,x)=y$
164:
165: \hspace{5cm} for all $x,y\in\{a,b\}$
166:
167: or
168:
169: $\varphi(x,y,..,y)=\varphi(y,y,..,x)=x \;\; \text{ for all } x,y\in\{a,b\}.$
170: \end{center}
171:
172: GMM operations generalize both near-unanimity and Mal'tsev operations. Intuitively, an operation is GMM if for each $2$-element
173: subset of its domain acts either as a near-unanimity or as a Mal'tsev.
174: In this paper we prove that every constraint language $\Gamma$ in which all its relations are
175: invariant under a GMM operation $\varphi$, gives rise to a subclass of the CSP solvable in polynomial-time.
176: This new family of constraint satisfaction problems includes among other all bounded strict width and
177: all Mal'tsev problems and, hence, constitutes one of the largest tractable classes of the CSP.
178: Our algorithm exploits a feature which is already used -at least implicitely- in the known algorithms for
179: Malt'sev and Near-unanimity problems: for any relation $R$ invariant under a GMM operation $\varphi$ it is always possible
180: to obtain a ``succint'' representation, in the form of a relation $G\subseteq R$ that {\em generates} $R$, i.e., such that $R$ is the
181: smallest relation invariant under $\varphi$ containing $G$. Indeed, our algorithm for GMM problems can be viewed as
182: a mixture of the algorithms for Near-unanimity and Malt'sev problems. However, it should be point out that the interaction between
183: the two conditions is rather intricate.
184:
185:
186: \section{Preliminaires}
187:
188:
189:
190: Let
191: $A$ be a finite set and let
192: $n$ be a positive integer. A $n$-ary relation on $A$ is any subset of $A^n$.
193: In what follows, for every positive integer $n$, $[n]$ will denote the set $\{1,\dots,n\}$.
194:
195: A constraint
196: satisfaction problem is a natural way to express simultaneous
197: requirements for values of variables. More precisely,
198:
199:
200: \begin{defi} An instance of a {\em constraint satisfaction problem} consists of:
201: \begin{itemize}
202: \item a finite set of variables, $V=\{v_1,\dots,v_n\}$;
203: \item a finite domain of values, $A$;
204: \item a finite set of constraints $\{C_1,\dots,C_m\}$;
205: each constraint $C_l,\; l\in[m]$, is a pair $((v_{i_1},\dots,v_{i_{k_l}}),S_l)$ where:
206: \begin{itemize}
207: \item $(v_{i_1},\dots,v_{i_{k_l}})$ is a tuple of variables of length $k_l$, called the {\em constraint scope} and
208: \item $S_l$ is an $k_l$-ary relation on $A$, called the {\em contraint relation}.
209: \end{itemize}
210: \end{itemize}
211: \end{defi}
212:
213:
214:
215: A {\em solution} to a constraint satisfaction instance is
216: a mapping $s:V\rightarrow A$ such that for each constraint $C_l$,
217: $l\in [m]$, we have that $(s(v_{i_1}),\dots,s(v_{k_l}))$
218: belongs to $S_l$.
219: Deciding whether or not a given problem instance has a
220: solution is NP-complete in general, even when
221: the constraints are restricted to binary
222: constraints~\cite{Mackworth:1977} or the domain of the problem has
223: size 2~\cite{Cook:1971}. However by imposing restrictions on
224: the constraint relations it is possible to
225: obtain restricted versions of the problem that are tractable.
226:
227:
228: \begin{defi}
229: For any set of relations $\Gamma$, $\csp(\Gamma)$ is defined to be the
230: class of decision problems with:
231: \begin{itemize}
232: \item Instance: A constraint satisfaction problem instance ${\mathcal P}$,
233: in which all constraint relations are elements of $\Gamma$.
234: \item Question: Does ${\mathcal P}$ have a solution?
235: \end{itemize}
236: \end{defi}
237:
238:
239: In the last few years much effort has been devoted to the
240: identification of those sets $\Gamma$ for which $\csp(\Gamma)$ is
241: solvable in polynomial time
242: (See~\cite{Bulatov:3element,Bulatov:maltsev,Bulatov03:conservative,Bulatov04:graph,Bulatov:2semilattices,Bulatov/Jeavons/Volkov:2001,Bulatov/Krokhin/Jeavons:2000,Bulatov/Krokhin/Jeavons:2001,Chen/Dalmau:laac,Dalmau:2000,Dalmau/Gavalda/Tesson/Therien:05,Dalmau/Pearson:1999,Feder:nearsubgroup,Feder/Vardi:1998,Jeavons/Cohen/Cooper:1998,Jeavons/Cohen/Gyssens:1997,Kirousis:1993}).
243: In order to isolate such ``islands of tractability'' it has been
244: particulary useful to consider certain closure conditions on the
245: relations of $\Gamma$. In order to make this more precise we need to
246: introduce the following definition, which constitues the cornerstone
247: of the so-called {\em algebraic approach} of the study of the CSP.
248:
249:
250: \begin{defi}
251: \label{def:preserves}
252: Let $\varphi:A^k\rightarrow A$ be an $k$-ary operation on $A$ and let $R$ be a $n$-ary
253: relation over $A$. We say that $R$ is invariant under $\varphi$ if
254: for all (not necessarily different) tuples ${\bf t_1}=(t^1_1,\dots,t^1_n),
255: \dots,{\bf t_k}=(t^k_1,\dots,t^k_n)$ in $R$, the tuple
256: $\varphi({\bf t_1},\dots,{\bf t_k})$ defined as
257: $$(\varphi(t^1_1,\dots,t^k_1),\dots,\varphi(t^1_n,\dots,t^k_n))$$
258: belongs to $R$.
259: \end{defi}
260:
261:
262: Given a relation $R$ and an operation $\varphi$, we denote by $\langle R\rangle_{\varphi}$
263: the smallest relation $S$ that contains $R$ and that it is invariant under $\varphi$.
264: Very often, the operation $\varphi$ will be clear from the context and we will
265: drop it writting $\langle R\rangle$ instead of $\langle R\rangle_{\varphi}$.
266:
267:
268: Let $\varphi:A^k\rightarrow A$ be any operation on $A$. We denote by $\inv(\varphi)$ the
269: set containg all relations on $A$ invariant under $\varphi$.
270:
271: The vast majority of constraint languages $\Gamma$ such that $\csp(\Gamma)$ is in PTIME
272: can be expressed as $\inv(\varphi)$ for some operation
273: $\varphi$. We refer the reader to the references pointed out in the
274: introduction for a complete (up to the best of our knowledge) list
275: of operations that lead to a tractable class of the CSP. In what
276: follows we shall introduce only two families of operations, namely
277: near-unanimity and Malt'sev, which will be particularly relevant to
278: our work.
279:
280: \begin{exa}{\bf (Near-Unanimity Operations)}
281: An operation $\varphi:A^k\rightarrow A$ with $k\geq 3$ is
282: near-unanimity (NU) if for all $x,y\in A$, we have that
283: $$\varphi(x,y,..,y)=\varphi(y,x,..,y)=\dots=\varphi(y,y,..,x)=y$$
284: Tractability of $\csp(\inv(\varphi))$ for any arbitrary near-unanimity
285: operation $\varphi$ was proved in~\cite{Feder/Vardi:1998} (See
286: also~\cite{Jeavons/Cohen/Cooper:1998}).
287: \end{exa}
288:
289: Many well known tractable cases of the CSP, such as $2$-SAT, or
290: the family of CSP with implicative constraints~\cite{Kirousis:1993,Cooper/Cohen/Jeavons:1994} are, in fact, particular instances
291: of this general case.
292:
293: \begin{exa}{\bf(Mal'tsev Operations)}
294: An operation $\varphi:A^3\rightarrow A$ is Mal'tsev if
295: for all $x,y\in A$, we have
296: $$\varphi(x,y,y)=\varphi(y,y,x)=x$$
297: In~\cite{Bulatov:maltsev} (see~\cite{Bulatov/Dalmau:05} for a simpler
298: proof), it was shown that for every Malt'sev operation $\varphi$,
299: $\csp(\inv(\varphi))$ is solvable in polynomial time. This general
300: result encompasses some previously known tractable cases of the CSP,
301: such as CSP with constraints defined by a system of linear
302: equations~\cite{Jeavons/Cohen/Gyssens:1997} or CSP with near-subgroups
303: and its cosets~\cite{Feder/Vardi:1998,Feder:nearsubgroup}.
304: \end{exa}
305:
306: The class of generalized majority-minority operations
307: generalizes both near-unanimity and Mal'tsev operations.
308:
309: \begin{defi}
310: An operation $\varphi: A^k \rightarrow A$ with $k \geq 3$
311: is a \emph{generalized majority-minority (GMM) operation} if
312: for all $a, b \in A$, either
313: \begin{equation}\label{eqn1}
314: \begin{array}{r}
315: \varphi(x,y,..,y)=\varphi(y,x,..,y)=\cdots=\varphi(y,y,..,x)=y \\
316: \text{for all } x,y\in\{a,b\}
317: \end{array}
318: \end{equation}
319: or
320: \begin{equation}\label{eqn2}
321: \varphi(x,y,..,y)=\varphi(y,y,..,x)=x \;\; \text{for all } x,y\in\{a,b\}
322: \end{equation}
323: \end{defi}
324:
325:
326: Generalized majority-minority operations were introduced in the study
327: of the learnability of relatively quantified generalized formulas~\cite{Bulatov/Chen/Dalmau:04}.
328:
329: Let us fix a GMM operation on a set $A$. A pair $a,b\in A$ is said to
330: be a \emph{majority} pair if $\varphi$ on $a,b$ satisfies (\ref{eqn1}). It
331: is said to be a \emph{minority} pair if $\varphi$ satisfies
332: (\ref{eqn2}). If $a=b$ then we will say $\{a,b\}$ is
333: a majority pair.
334:
335:
336: In this paper we prove the following result:
337:
338: \begin{thm}
339: \label{th1}
340: For every GMM operation $\varphi$, $\csp(\inv(\varphi))$ is solvable in polynomial time.
341: \end{thm}
342:
343:
344: The proof is given in Section~\ref{proof}.
345:
346:
347:
348: \section{Signatures and Representations}
349:
350: Let $A$ be a finite set, let $n$ be a positive integer, let ${\bf t}=(t_1,\dots,t_n)$ be a $n$-ary tuple of elements in $A$, and
351: let $i_1,\dots,i_j$ elements in $[n]$. By $\pr_{i_1,\dots,i_j} {\bf t}$ we denote the tuple $(t_{i_1},\dots,t_{i_j})$.
352: Similarly, for every $n$-ary relation $R$ on $A$ and for every $i_1,\dots,i_j\in [n]$ we denote
353: by $\pr_{i_1,\dots,i_j} R$ the $j$-ary relation given by $\{\pr_{i_1,\dots,i_j} {\bf t} : {\bf t}\in R\}$.
354: Given a subset $I=\{i_1,\dots,i_j\}$ of $[n]$ with $i_1<i_2<\dots<i_j$ we shall use
355: $\pr_I R$ to denote $\pr_{i_1,\dots,i_j} R$.
356:
357: Let $n$ be a positive integer, let $A$ be a finite set,
358: let ${\bf t}$, ${\bf t'}$ be $n$-ary tuples and let $(i,a,b)$ be any element in $[n]\times A^2$
359: with $a\neq b$.
360: We say that $({\bf t},{\bf t'})$
361: witnesses $(i,a,b)$ if
362: $\pr_{1,\dots,i-1} {\bf t}=\pr_{1,\dots,i-1} {\bf t'}$,
363: $\pr_i {\bf t}=a$, and $\pr_i {\bf t'}=b$.
364: We also say that ${\bf t}$ and ${\bf t'}$ witness
365: $(i,a,b)$ meaning that $({\bf t},{\bf t'})$ witnesses $(i,a,b)$.
366:
367: Let $\varphi:A^k\rightarrow A$, $k\geq 3$, be a GMM operation
368: and let $R$ be any $n$-ary relation on $A$ (not necessarily invariant under $\varphi$).
369: We define the {\em signature} of $R$ {\em relative to $\varphi$},
370: $\sig_R\subseteq [n]\times A^2$, as the set containing all those $(i,a,b)\in [n]\times A^2$,
371: with $\{a,b\}$ a minority pair witnessed by tuples in $R$, that is
372: $$\begin{array}{r}
373: \sig_R=\{ (i,a,b)\in [n]\times A^2: \{a,b\} \text{ a minority pair }, \\
374: \exists {\bf t},{\bf t'}\in R \text { such that }( {\bf t},{\bf t'}) \text{ witnesses } (i,a,b)\}\end{array}$$
375:
376: Fix a non-negative integer $j$. A subset $R'$ of $R$ is called a {\em representation} of $R$ {\em relative to $\varphi$}
377: of order $j$ if $\sig_R=\sig_{R'}$ and for every $I\subseteq\{1,\dots,n\}$ with
378: $|I|\leq j$, $\pr_I R=\pr_I R'$. We also say that $R'$ is a $j$-representation of $R$ relative to $\varphi$.
379: Observe that for any
380: $n$-ary relation there exists a $j$-representation with size bounded above by
381: $2|\sig_R|+\sum_{I\subseteq [n], |I|\leq j} |\pr_I R|$. We call any
382: such representation, a {\em compact representation} of $R$.
383: Note: When the operation $\varphi$ is clear from the context we shall drop the ``relative to $\varphi$''
384: with the implicit understanding that signatures and representations are relative to $\varphi$.
385:
386:
387: \begin{exa}\label{E:three}
388: Let $A$ be a finite set, let $\varphi:A^k\rightarrow A$, $k\geq 3$, be a GMM operation and let $j$ and $n$ positive integers.
389: We shall construct a $j$-representation $R'$ of $R=A^n$.
390:
391: Initially $R'$ is empty. Fix any arbitrary element $d$ in $A$.
392: First, observe that $\sig_{R}$ contains all $(i,a,b)$ in $[n]\times A^2$ where
393: $\{a,b\}$ is a minority pair. For each triple $(i,a,b)$ in $\sig_R$ we
394: add to $R'$ two tuples ${\bf t^i_a}$, ${\bf t^i_b}$, where ${\bf t^i_a}$ is the tuple that has
395: $a$ in its $i$th coordinate and $d$ elsewhere and, accordingly, ${\bf t^i_b}$ is the tuple that has $b$ in
396: its $i$th coordinate and $d$ elsewhere. Notice that $({\bf t^i_a},{\bf t^i_b})$ witnesses $(i,a,b)$.
397: Hence, after adding to $R'$ a corresponding pair ${\bf t^i_a},{\bf t^i_b}$ for each $(i,a,b)$ in $\sig_R$
398: we have that $\sig_R=\sig_{R'}$. In a second step we add for each $i_1,\dots,i_{j'}$ with $j'\leq j$
399: and $i_1<i_2<\dots<i_j$, and every $a_1,\dots,a_{j'}\in A$, the tuple ${\bf t^{i_1,\dots,i_{j'}}_{a_1,\dots,a_{j'}}}$
400: that has $a_l$ in its $i_l$th coordinate for each $l\in[j']$, and $d$ elsewhere. It is easy to verify that we
401: obtain a relation $R'$ such that for all $I\subseteq[n]$ with $|I|\leq j$, $\pr_I R'=A^{|I|}=\pr_I R$.
402: Hence $R'$ is a representation of $R$ of order $j$. Observe that, indeed, $R'$ is a {\em compact
403: representation} of $R$.
404: \end{exa}
405:
406: The algorithm we propose relies on the following lemma.
407:
408: \begin{lem} Let $A$ be a finite set, let
409: $\varphi:A^k\rightarrow A$, $k\geq 3$ be a GMM operation, let $R$
410: be a relation on $A$ invariant under $\varphi$ and let $R'$
411: be a representation of $R$ of order $k-1$. Then $\langle R'\rangle = R$
412: \end{lem}
413:
414: \proof Let $n$ be the arity of $R$. We shall show that for every
415: $i\in[n]$, $\pr_{1,\dots,i} \langle R'\rangle=\pr_{1,\dots,i} R$ by
416: induction on $i$. The case $i\leq k-1$ follows from
417: $\pr_{1,\dots,k-1} R'=\pr_{1,\dots,k-1} R$. So let $i\geq k$ and let
418: ${\bf a}=(a_1,\dots,a_i)\in\pr_{1,\dots,i} R$. By induction
419: hypothesis, for some $b_i$, the tuple ${\bf
420: a'}=(a_1,\dots,a_{i-1},b_i)$ belongs to $\pr_{1,\dots,i} \langle
421: R'\rangle$. In what follows we shall denote $\pr_{1,\dots,i} \langle
422: R'\rangle$ as $S$.
423:
424: We consider two cases.
425:
426: \medskip
427: \noindent{\em Case 1.} $\{a_i,b_i\}$ is majority.
428: \smallskip
429:
430: In this case we show that, for every $I\subseteq\{1,\ldots, i\}$,
431: $\pr_I {\bf a}\in\pr_I S$. We show it by induction on
432: the cardinality $m$ of $I$. The result is true for $m\leq k-1$
433: due to the fact that $R'$ is a $(k-1)$-representation of $R$.
434: It is also true for
435: every set $I$ that does not contain $i$, since ${\bf a'}\in S$
436: certifies it. Thus let $I=\{j_1,\dots,j_m\}$ be any set of indices
437: $1\leq j_1< j_2<\dots<j_m=i$ with $m\geq k$ and also let
438: ${\bf a^*}=\pr_I {\bf a}$. To simplify the notation let
439: us denote ${\bf a^*}=(c_1,\dots,c_m)$. By
440: induction hypothesis, $\pr_I S$ contains the tuples
441: ${\bf d_1}=(d_1,c_2,\dots,c_m)$, ${\bf d_2}=(c_1,d_2,c_3,\dots,c_m)$,
442: $\dots$, ${\bf d_m}=(c_1,\dots,c_{m-1},d_m)$ for some $d_1,\dots,d_m\in A$.
443: If for some $i$, $c_i=d_i$ then we are done. Otherwise,
444: we can assume that $d_m=b_i$ and $c_m=a_i$ and henceforth
445: $\{d_m,c_m\}$ is majority. If for some $j$, the pair $\{d_j,c_j\}$ is
446: minority then we are done, because
447: $\varphi({\bf d_j},{\bf d_j},\dots,{\bf d_j},{\bf d_m})={\bf a^*}$.
448: Otherwise, $\{d_j,c_j\}$ is majority for any $j$. In this case
449: we have $\varphi({\bf d_1},{\bf d_2}\dots,{\bf d_{k-1}},{\bf d_k})={\bf a^*}$.
450:
451: \medskip
452: \noindent{\em Case 2.} $\{a_i,b_i\}$ is minority.
453: \smallskip
454:
455: Since ${\bf a}$ and ${\bf a'}$ belong to $\pr_{1,\dots,i} R$ then
456: there exists some tuples ${\bf t},{\bf t'}\in R$ such that
457: $\pr_{1,\dots,i} {\bf t}={\bf a}$ and $\pr_{1,\dots,i} {\bf t'}={\bf
458: a'}$. Consequently, ${\bf t}$ and ${\bf t'}$ witness $(i,a_i,b_i)$
459: and since $\sig_{R'}=\sig_R$ we can conclude that $\pr_{1,\dots,i} R'$
460: (and hence $S$) contains tuples ${\bf c}=(c_1,\dots,c_{i-1},a_i)$ and
461: ${\bf c'}=(c_1,\dots,c_{i-1},b_i)$ witnessing $(i,a_i,b_i)$. We shall
462: show that ${\bf a}$ can be obtained from ${\bf a'}$, ${\bf c}$ and
463: ${\bf c'}$ by applying operation $\varphi$. We need first an
464: intermediate tuple; we define ${\bf d}=(d_1,\dots,d_i)$ as
465: $\varphi({\bf a'},{\bf c'},\dots,{\bf c'},{\bf c})$. Finally we
466: obtain ${\bf e}=(e_1,\dots,e_i)$ as $\varphi({\bf a'},{\bf
467: a'},\dots,{\bf a'},{\bf d})$. Let us see that the tuple obtained
468: ${\bf e}$ is indeed ${\bf a}$. For each $l\in[i-1]$, if $\{a_l,c_l\}$
469: is a majority pair then $d_l=\varphi(a_l,c_l,\dots,c_l,c_l)=c_l$, and
470: consequently $e_l=\varphi(a_l,a_l,\dots,a_l,c_l)=a_l$. Otherwise, if
471: $\{a_l,c_l\}$ is a minority pair, then
472: $d_l=\varphi(a_l,c_l,\dots,c_l)=a_l$ and consequently
473: $e_l=\varphi(a_l,a_l\dots,a_l,a_l)=a_l$. Finally, let us look at the
474: value of $e_i$. Since $\{a_i,b_i\}$ is a minority pair we have that
475: $d_i=\varphi(b_i,b_i,\dots,b_i,a_i)=a_i$ and hence
476: $e_i=\varphi(b_i,b_i,\dots,b_i,a_i)=a_i$ and we are done.\qed
477:
478:
479: \section{Proof of Theorem~\ref{th1}}
480: \label{proof}
481:
482: We prove Theorem~\ref{th1} by giving a polynomial-time algorithm that
483: decides correctly whether a CSP($\inv(\varphi)$) instance has a
484: solution. The structure of the algorithm mimics that
485: of~\cite{Bulatov/Dalmau:05}.
486:
487:
488: Let ${\mathcal P}=(\{v_1,\dots,v_n\} ,A,\{C_1,\dots,C_m\})$ be a
489: CSP($\inv(\varphi)$) instance which will be the input of the
490: algorithm.
491:
492: For each $l\in\{0,\dots,m\}$ we define ${\mathcal P_l}$ as the CSP
493: instance that contains the first $l$ constraints of ${\mathcal P}$,
494: that is ${\mathcal
495: P}_l=(\{v_1,\dots,v_n\},A,\{C_1,\dots,C_l\})$. Furthermore, we shall
496: denote by $R_l$ the $n$-ary relation on $A$ defined as
497: $$R_l=\{(s(v_1),\dots,s(v_n)) : s \text{ is a solution of } {\mathcal P}_l)$$
498:
499: In a nutshell, the algorithm introduced in this section computes for
500: each $l\in\{0,\dots,m\}$ a compact representation $R'_l$ of $R_l$. In
501: the initial case ($l=0$), ${\mathcal P_0}$ does not have any
502: constraint at all, and consequently, $R_0=A^n$. Hence, a compact
503: representation of $R_0$ can be easily obtained as in Example 3. Once a
504: compact representation $R'_0$ of $R_0$ has been obtained the algorithm
505: starts an iterative process in which a compact representation
506: $R'_{l+1}$ of $R_{l+1}$ is obtained from $R'_l$ and the constraint
507: $C_{l+1}$. This is achieved by means of a call to procedure {\tt
508: Next}, which constitutes the core of the algorithm. The algorithm
509: then, goes as follows:
510:
511: \begin{tabbing}
512: {\bf Algorithm} {\tt GMM}($(\{v_1,\dots,v_n),A,\{C_1,\dots,C_m\})$) \\
513: {\em Step 1} \ \ \ \= {\bf set} $R'_0$ as in Example 3 \\
514: {\em Step 2} \> {\bf for each} $l\in\{0,\dots,m-1\}$ {\bf do} \\
515: \> \ \ \ \ \= (let $C_{l+1}$ be $((v_{i_1},\dots,{v_{i_{k_{l+1}}}}),S_{l+1})$) \\
516: {\em Step 2.1} \> \> {\bf set} $R'_{l+1}:=\text{\tt Next}(R'_l,i_1,\dots,i_{k_{l+1}},S_{l+1})$ \\
517: \> {\bf end for each} \\
518: {\em Step 3} \> {\bf if} $R'_m\neq \emptyset$ {\bf return yes} \\
519: {\em Step 4} \> \> {\bf otherwise return no}
520: \end{tabbing}
521:
522: Observe that if we modify step 3 so that the algorithm returns an arbitrary tuple in $R'_m$ instead
523: of ``yes'' then we have an algorithm that does not merely solve the decision question but actually
524: provides a solution.
525:
526: Correctness and polynomial time complexity of the algorithm are
527: direct consequences of the correctness and the running time of the
528: procedure {\tt Next}: As it is shown in Section~\ref{next}
529: (Lemma~\ref{le:next}) at each iteration of Step 2.1, the call $\text{\tt Next}(R'_l,i_1,\dots,i_{l+1},S_{l+1})$
530: correctly computes a compact
531: representation of the relation $\{ {\bf t}\in R_l :
532: \pr_{i_1,\dots,i_{l+1}} {\bf t}\in S_{l+1}\}$ which is indeed
533: $R_{l+1}$. Furthermore the cost of the call is polynomial in $n$,
534: $|A|$, and $|S_{l+1}|$, which gives as a total running time for the
535: algorithm polynomial (see Corollary~\ref{cor:solve} for a rough
536: approximation of the running time) in the size of the input. This
537: finishes the proof of the correctness and time complexity of the
538: algorithm, and hence, of Theorem~\ref{th1}.
539: \endproof
540:
541: Let us remark that our emphasis here is on simplicity rather than in
542: efficiency. In fact, much better time bounds that the ones provided in
543: our analysis can be obtained by improving the code using data
544: structures and by performing a more accurate analysis of the running
545: time.
546:
547:
548: The remainder of the paper is devoted to defining and analyzing
549: procedure {\tt Next}. In order to define procedure {\tt Next} it is
550: convenient to introduce previously a pair of procedures, namely {\tt
551: Nonempty} and {\tt Fix-values}, which will be intensively used by our
552: procedure {\tt Next}.
553:
554:
555: \subsection{Procedure {\tt Nonempty}}
556:
557: This procedure receives as input a $k$-order compact representation
558: $R'$ of a relation $R$ invariant under $\varphi$, a sequence
559: $i_1,\dots,i_j$ of elements in $[n]$ where $n$ is the arity of $R$,
560: and a $j$-ary relation $S$ also invariant under $\varphi$. The output
561: of the procedure is either an $n$-ary tuple ${\bf t}\in R$ such that
562: $\pr_{i_1,\dots,i_j} {\bf t}\in S$ or ``no'' meaning that such a tuple
563: does not exist.
564:
565:
566: \begin{tabbing}
567: {\bf Procedure} {\tt Nonempty}($R',i_1,\dots,i_j,S$) \\
568: {\em Step 1} \ \ \ \= {\bf set} $U:=R'$ \\
569: {\em Step 2} \> {\bf while} $\exists {\bf t_1},{\bf t_2},\dots,{\bf t_k}\in U$ such that \\
570: \> \ \ \ \ \ \ \ \ \ \ $\pr_{i_1,\dots,i_j} \varphi({\bf t_1},{\bf t_2},\dots,{\bf t_k})\not\in \pr_{i_1,\dots,i_j} U$ {\bf do} \\
571: {\em Step 2.1} \> \ \ \ \= {\bf set} $U:=U\cup\{\varphi({\bf t_1},{\bf t_2},\dots,{\bf t_k})\}$ \\
572: \> {\bf endwhile} \\
573: {\em Step 3} \> {\bf if } $\exists {\bf t}$ in $U$ such that $\pr_{i_1,\dots,i_j} {\bf t}\in S$
574: {\bf then return} ${\bf t}$ \\
575: {\em Step 4} \> {\bf else return} ``no''
576: \end{tabbing}
577:
578:
579:
580: We shall start by studying its correctness. First observe that every tuple in $U$ belongs initially to $R'$
581: (and hence to $R$), or it has been obtained by applying $\varphi$ to some tuples
582: ${\bf t_1},{\bf t_2},\dots,{\bf t_k}$
583: that previously belong to $U$. Therefore, since $R$ is invariant under $\varphi$, we can conclude that
584: during all the execution of the procedure $U\subseteq R$.
585: Consequently, if a tuple ${\bf t}$ is returned in step 3, then it belongs to $R$
586: and also satisfies that $\pr_{i_1,\dots,i_j} {\bf t}\in S$, as desired. It only
587: remains to show that if a ``no'' is returned in step 4 then there does not exist any tuple ${\bf t}$
588: in $R$ such that $\pr_{i_1,\dots,i_j} {\bf t}\in S$. In order to do this we need to
589: show some simple facts about $U$. Notice that at any point of the execution of the procedure $R'\subseteq U$. Then $U$ is also a representation
590: of $R$ and hence $\langle U\rangle=R$. Therefore we have that
591: $$\langle \pr_{i_1,\dots,i_j} U\rangle=\pr_{i_1,\dots,i_j} \langle U\rangle=\pr_{i_1,\dots,i_j} R$$
592: By the condition on the ``while'' of step 2 we have that when the
593: procedure leaves the execution of step $2$ it is necessarily the
594: case that for all ${\bf t_1},{\bf t_2},\dots,{\bf t_k}\in U$,
595: $\pr_{i_1,\dots,i_j} \varphi({\bf t_1},{\bf t_2},\dots,{\bf t_k})\in
596: \pr_{i_1,\dots,i_j} U$ and consequently $\pr_{i_1,\dots,i_j}
597: U=\langle \pr_{i_1,\dots,i_j} U\rangle=\pr_{i_1,\dots,i_j} R$.
598: Hence, if there exists some ${\bf t}$ in $R$ such that
599: $\pr_{i_1,\dots,i_j} {\bf t}\in S$ then it must exist some ${\bf
600: t'}$ in $U$ such that $\pr_{i_1,\dots,i_j} {\bf t'}\in S$ and we are
601: done.
602:
603: Let us study now the running time of the procedure. It is only necessary to focus on steps 2 and 3.
604: At each iteration of the loop in step 2, cardinality of $U$ increases by one. So we can bound
605: the number of iterations by the size $|U|$ of $U$ at the end of the execution of the procedure.
606:
607: The cost of each iteration is basically dominated by the amount of
608: computational time needed to check whether there exists some tuples
609: $\exists {\bf t_1},{\bf t_2},\dots,{\bf t_k}\in U$ such that
610: $\pr_{i_1,\dots,i_j} \varphi({\bf t_1},{\bf t_2},\dots,{\bf
611: t_k})\not\in \pr_{i_1,\dots,i_j} U$ in step 2. In order to try all
612: possible combinations for ${\bf t_1},{\bf t_2},\dots,{\bf t_k}$ in
613: $U$, $|U|^k$ steps suffice. Each one of these steps requires time
614: $O(|U| n)$, as tuples have arity $n$ and checking whether
615: $\varphi({\bf t_1},{\bf t_2},\dots,{\bf t_k})$ belongs to $U$ can be
616: done naively by a sequential search in $U$. Thus, the total running
617: time of step 2 is $O(|U|^{k+1} n)$. The cost of step $3$ is the cost
618: of finding a tuple ${\bf t}$ in $U$ satisfying $\pr_{i_1,\dots,i_j}
619: {\bf t}\in S$ which is $O(|U| |S| n)$. Putting all together we
620: obtain that the complete running time of the procedure is
621: $O(|U|^{k+2} n+|U| |S| n)$ which we can bound by $O(|U|^{k+2} |S|
622: n)$. So, it only remains to bound the size of $U$ (at the end of the
623: execution of the procedure). The size of $U$ can be bounded by the
624: initial size of $R'$ which is at most $O(n|A|^2+n^k |A|^k)=O((n
625: |A|)^k)$ (since $R'$ is compact) plus the number of iterations in
626: step 2, which is bounded by $|\pr_{i_1,\dots,i_j} R|$.
627:
628:
629: Consequently the total running time of the procedure can be bounded
630: by
631: $$O\left( \left((n|A|)^k +|\pr_{i_1,\dots,i_j} R|\right)^{k+2} |S| n\right
632: ).$$ We want to remark here that the size of $\pr_{i_1,\dots,i_j} R$
633: can be exponentially large in the size of the input. For now we do
634: not deal with this issue. Later we shall see how, in order to
635: overcome this difficulty, we organize invoking to {\tt Nonempty} in
636: such a way that the value of $\pr_{i_1,\dots,i_j} R$ is conveniently
637: bounded.
638:
639:
640:
641: \subsection{Procedure {\tt Fix-values}}
642:
643: This procedure receives as input a compact representation $R'$ of a relation $R$
644: invariant under $\varphi$ and a sequence $a_1,\dots,a_m$, $m\leq n$ of elements of $A$ ($n$ is
645: the arity of $R$). The output is a compact representation of the relation given by
646: $$\{ {\bf t}\in R : \pr_1 {\bf t}=a_1,\dots,\pr_m {\bf t}=a_m\}$$
647:
648:
649: \begin{figure*}
650: \begin{tabbing}
651: {\bf Procedure} {\tt Fix-values}($R',a_1,\dots,a_m$) \\
652: {\em Step 1} \ \ \ \ \ \ \ \ \= {\bf set} $j:=0$; $U_j:=R'$ \\
653: {\em Step 2} \> {\bf while} $j<m$ {\bf do} \\
654: {\em Step 2.1} \> \ \ \ \= {\bf set} $U_{j+1}:=\emptyset$ \\
655: {\em Step 2.2} \> \> {\bf for each} $(i,a,b)\in[n]\times A^2$, $\{a,b\}$ is a minority pair, {\bf do} \\
656: {\em Step 2.2.1} \> \> \ \ \ \ {\bf if} \= $\text{\tt Nonempty}(U_j,j+1,i,\{(a_{j+1},a)\})\neq $''no'' and \\
657: \> \> \> $(i,a,b)\in\sig U_j$ and $i> j+1$ {\bf then} \\
658: \> \> \> \ \ \ \ \= (let ${\bf t_1}$ be the tuple returned by $\text{\tt Nonempty}(U_j,j+1,i,\{(a_{j+1},a)\})$ \\
659: \> \> \> \> and let ${\bf t_2}$,${\bf t_3}$ be tuples in $U_j$ witnessing $(i,a,b)$ ) \\
660: {\em Step 2.2.1.1} \> \> \> \> {\bf set} ${\bf t_4}:=\varphi({\bf t_1},{\bf t_2},\dots,{\bf t_2},{\bf t_3})$ \\
661: {\em Step 2.2.1.2} \> \> \> \> {\bf set} ${\bf t_5}:=\varphi({\bf t_1},{\bf t_1},\dots,{\bf t_1},{\bf t_4})$ \\
662: {\em Step 2.2.1.3} \> \> \> \> {\bf set} $U_{j+1}:=U_{j+1}\cup\{{\bf t_1},{\bf t_5}\}$ \\
663: \> \> {\bf end for each} \\
664: {\em Step 2.3} \> \> {\bf for each } $k'\in [k-1]$ \\
665: \> \> \> {\bf for each} $l_1,\dots,l_{k'}\in [n]$ with $l_1<l_2<\dots<l_{k'}$ \\
666: \> \> \> \> {\bf for each} $d_1,\dots,d_{k'}\in A$ {\bf do} \\
667: {\em Step 2.3.1} \> \> \> \> \ \ \ \= {\bf if} $\text{\tt Nonempty}(U_j,l_1,\dots,l_{k'},j+1,\{(d_1,\dots,d_{k'},a_{j+1})\})\neq $''no'' {\bf then} \\
668: \> \> \> \> \> (let ${\bf t_6}$ be the tuple returned by the call \\
669: \> \> \> \> \> to $\text{\tt Nonempty}(U_j,l_1,\dots,l_{k'},j+1,\{(d_1,\dots,d_{k'},a_{j+1})\})$) \\
670: \> \> \> \> \> {\bf set} $U_{j+1}:=U_{j+1}\cup\{{\bf t_6}\}$ \\
671: \> \> {\bf end for each} \\
672: {\em Step 2.4} \> \> {\bf set} $j:=j+1$ \\
673: \> {\bf end while} \\
674: {\em Step 3} \> {\bf return $U_m$} \\
675: \end{tabbing}
676: \caption{Fix-values}
677: \label{Fix-values}
678: \end{figure*}
679:
680: Figure~\ref{Fix-values} contains a description of the procedure.
681: Let us study its correctness. We shall show by induction on $j\in\{0,\dots,m\}$
682: that $U_j$ is a compact representation of $R_j=\{{\bf t}\in R : \pr_1 {\bf t}=a_1,\dots,\pr_j {\bf t} =a_j\}$.
683: The case $j=0$ is correctly settled in step 1. Hence it is only necessary to show that at every iteration
684: of the while loop in step 2, if $U_j$ is a compact representation of $R_j$ then $U_{j+1}$
685: is a compact representation of $R_{j+1}$. We shall start by showing that at the end
686: of the execution of step 2.2, $\sig_{U_{j+1}}=\sig_{R_{j+1}}$.
687: It is easy to see that
688: if any of the conditions of the ``if'' in step 2.2.1 is falsified then $(i,a,b)$ is not in $\sig_{R_{j+1}}$.
689: So it only remains to see that when the ``if'' in step 2.2.1 is satisfied, we have that (a)
690: $({\bf t_1},{\bf t_5})$ witnesses $(i,a,b)$, and
691: (b) ${\bf t_1}$ and
692: ${\bf t_5}$ are tuples in $R_{j+1}$,
693:
694:
695: Proof of (a): We shall first show that for each $l\in[i-1]$, $\pr_l {\bf t_1}=\pr_l {\bf t_5}$.
696: Let $c_l$ to be $\pr_l {\bf t_1}$ and let $d_l=\pr_l {\bf t_2}=\pr_l {\bf t_3}$. If $\{c_l,d_l\}$
697: is a majority pair then $\pr_l {\bf t_4}=\varphi(c_l,d_l,\dots,d_l,d_l)=d_l$ and hence
698: $\pr_l {\bf t_5}=\varphi(c_l,c_l,\dots,c_l,d_l)=c_l$. Otherwise,
699: if $\{c_l,d_l\}$ is a minority pair, then $\pr_l {\bf t_4}=\varphi(c_l,d_l,\dots,d_l,d_l)=c_l$ and
700: consequently $\pr_l {\bf t_5}=\varphi(c_l,c_l,\dots,c_l,c_l)=c_l$. So it only remains to show
701: that $\pr_i {\bf t_1}=a$ and $\pr_i {\bf t_5}=b$. We have $\pr_i {\bf t_1}=a$ as a direct consequence
702: of the fact that ${\bf t_1}$ is the tuple returned by the call to
703: $\text{\tt Nonempty}(U_j,j+1,i,\{(a_{j+1},a)\})$. Observe also that as $({\bf t_2},{\bf t_3})$
704: witnesses $(i,a,b)$ we have that $\pr_i {\bf t_2}=a$ and $\pr_i {\bf t_3}=b$. Consequently,
705: since $\{a,b\}$ is a minority pair we have that
706: $\pr_i {\bf t_4}=\varphi(a,a,\dots,a,b)=b$ and hence $\pr_i {\bf t_5}=\varphi(a,a,\dots,a,b)=b$,
707: as desired.
708:
709: Proof of (b): As ${\bf t_1}$ is the output of the call $\text{\tt Nonempty}(U_j,j+1,i,\{(a_{j+1},a)\})$, we can conclude that ${\bf t_1}$ belongs to $R_j$, $\pr_{j+1} {\bf t_1}=a_{j+1}$,
710: and $\pr_i {\bf t_1}=a$. Consequently ${\bf t_1}$ belongs to $R_{j+1}$. Furthermore, as ${\bf t_1}$, ${\bf t_2}$, and ${\bf t_3}$ are
711: in $R_j$ and $R_j$ is invariant under $\varphi$, we can conclude that ${\bf t_5}$ belongs to
712: $R_j$. Thus in order to see that ${\bf t_5}$ belongs to $R_{j+1}$ it only remains to
713: show that $\pr_{j+1} {\bf t_5}=a_{j+1}$. This can be obtained as a direct consequence of
714: (a), since as $({\bf t_1},{\bf t_5})$ witnesses $(i,a,b)$ and $i>j+1$, we have that
715: $a_{j+1}=\pr_{j+1} {\bf t_1}=\pr_{j+1} {\bf t_5}$.
716:
717: We have just seen that at the end of step 2.2,
718: $\sig_{U_{j+1}}=\sig_{R_{j+1}}$. In Step 2.3, procedure {\tt
719: Fix-values} enlarges $U_{j+1}$ so that for every set $I\subseteq[n]$
720: with $|I|\leq k-1$, $\pr_I U_{j+1}=\pr_I R_{j+1}$. The proof of this
721: fact is rather straightforward. Let $k'$, $l_1,\dots,l_{k'}$,
722: $d_1,\dots,d_{k'}$ be the running parameters of a given interation
723: of step 2.3. It is easy to observe that the call to $\text{\tt
724: Nonempty}(U_j,l_1,\dots,l_{k'},j+1,\{(d_1,\dots,d_{k'},a_{j+1})\})$
725: is different than ``no'' if and only if
726: $(d_1,\dots,d_{k'})\in\pr_{l_1,\dots,l_{k'}} R_{j+1}$. Furthermore,
727: if the call returns a tuple ${\bf t_6}$ then we can guarantee that
728: ${\bf t_6}$ belongs to $R_{j+1}$ and that $\pr_I {\bf
729: t_6}=(d_1,\dots,d_{k'})$. We have just seen that at the end of the
730: execution of step 2.3 for every set $I\subseteq[n]$ with $|I|\leq
731: k-1$, $\pr_I U_{j+1}=\pr_I R_{j+1}$.
732:
733: Notice that at each iteration of step 2.2, at most $2$ tuples are added for each $(i,a,b)$ in $\sig_{R_{j+1}}$.
734: Furthermore at each iteration of step 2.3, at most one tuple is added per each $k'$, $I$ with $|I|\leq k-1$
735: and tuple in $\pr_I R_{j+1}$. Consequently,
736: $U_{j+1}$ is compact. This completes the proof of its correctness.
737:
738:
739: Let us study now its time complexity. The ``while'' loop at step 2
740: is performed $m\leq n$ times. At each iteration the procedure
741: executes two loops (Step 2.2 and Step 2.3). The ``for each'' loop at
742: step 2.2 is executed for each $(i,a,b)$ in $[n]\times A^2$ with
743: $\{a,b\}$ a minority pair. That is a total number of times bounded
744: by $n |A|^2$. The cost of each iteration of the loop in Step 2.2 is
745: basically dominated by the cost of the call to procedure ${\tt
746: Nonempty}$ which costs $O(((n|A|)^k+|A|^2)^{k+2} n)$ which is $O((n
747: |A|)^{k(k+2)+1})$. The ``for each'' loop at step 2.3 is executed
748: $O((n |A|)^k)$ times. The cost of each iteration is basically the
749: cost of the call to {\tt Nonempty} which is
750: $O(((n|A|)^k+|A|^k)^{k+2}n)=O((n|A|)^{k(k+2)+1})$. Thus the total
751: cost of step 2.3 is $O((n|A|)^{k(k+2)+1+k})$. Thus the combined cost
752: of steps 2.2 and 2.3 is dominated by the cost of 2.3 which gives as
753: a total cost of $O((n|A|)^{k(k+2)+1+k})$ for each iteration of step
754: $2$. Since step $2$ is executed at most $n$ times we have a total
755: cost of the procedure of $O((n|A|)^{k(k+2)+1+k}n)$ which we shall
756: bound by $O((n|A|)^{(k+1)(k+2)})$.
757:
758:
759:
760: \subsection{Procedure {\tt Next}}
761: \label{next}
762: We are now almost in a position to introduce procedure {\tt Next}.
763: Procedure {\tt Next} receives as input a compact representation $R'$ of a relation
764: $R$ invariant under $\varphi$, a sequence $i_1,\dots,i_j$ of elements in $[n]$
765: where $n$ is the arity of $R$, and a $j$-ary relation $S$ invariant under $\varphi$. The output of {\tt Next}
766: is a compact representation of the relation
767: $R^*=\{{\bf t}\in R : \pr_{i_1,\dots,i_j} {\bf t}\in S$\}.
768: It is an easy exercise to verify that $R^*$ must also be invariant under $\varphi$.
769:
770: We shall start by defining a procedure, called {\tt Next-beta} that although equivalent
771: to {\tt Next} has a worse running time. In particular, the running time of {\tt Next-beta}
772: might be exponential to the arity $j$ of $S$ (recall that arities can be unbounded as
773: we allow infinite constraint languages).
774:
775:
776: \begin{figure*}
777: \begin{tabbing}
778: {\bf Procedure} {\tt Next-beta}($R',i_1,\dots,i_j,S$) \\
779: {\em Step 1} \ \ \ \= {\bf set} $U:=\emptyset$ \\
780: {\em Step 2} \> {\bf for each} $(i,a,b)\in[n]\times A^2$, $\{a,b\}$ is a minority pair {\bf do} \\
781: {\em Step 2.1} \> \ \ \= {\bf if } {\tt Nonempty}$(R',i_1,\dots,i_j,i,S\times\{a\})\neq$''no'' {\bf then} \\
782: \> \> \ \ \ \= (let ${\bf t_1}$ be {\tt Nonempty}$(R',i_1,\dots,i_j,i,S\times\{a\})$) \\
783: {\em Step 2.2} \> \> \> {\bf if} $\text{\tt Nonempty}(\text{\tt Fix-values}(R',\pr_1 {\bf t_1},\dots,\pr_{i-1} {\bf t_1}),i_1,\dots,i_j,i,S\times\{b\})\neq$''no'' \\
784: \> \> \> \ \ \= (let ${\bf t_2}$ be $\text{\tt Nonempty}(\text{\tt Fix-values}(R',\pr_1 {\bf t},\dots,\pr_{i-1} {\bf t}),i_1,\dots,i_j,i,S\times\{b\})$) \\
785: \> \> \> \> {\bf set} $U:=U\cup\{{\bf t_1},{\bf t_2}\}$ \\
786: \> {\bf end for each} \\
787: {\em Step 3} \> {\bf for each} $k'\in [k-1]$ \\
788: \> \> {\bf for each} $l_1,\dots,l_{k'}\in [n]$ with $l_1<l_2<\dots<l_{k'}$ \\
789: \> \> \> {\bf for each} $d_1,\dots,d_{k'}\in A$ {\bf do} \\
790: {\em Step 3.1} \> \> \> {\bf if } $\text{\tt Nonempty}(R',i_1,\dots,i_j,l_1,\dots,l_{k'},S\times\{(d_1,\dots,d_{k'})\})\neq$''no'' {\bf then} \\
791: \> \> \> \> (let ${\bf t_3}=\text{\tt Nonempty}(R',i_1,\dots,i_j,l_1,\dots,l_{k'},S\times\{(d_1,\dots,d_{k'})\})$) \\
792: \> \> \> \> {\bf set} $U:=U\cup\{{\bf t_3}\}$ \\
793: {\em Step 4} \> {\bf return} $U$ \\
794: \end{tabbing}
795: \caption{Next-beta}
796: \label{Next-beta}
797: \end{figure*}
798:
799: Figure~\ref{Next-beta} contains a description of the procedure.
800: The overall structure of procedure {\tt Next-beta} is similar to that of procedure {\tt Fix-values}.
801: The procedure constructs a representation $U$ of $R^*$. Initially $U$ is empty. In step 2, {\text Next-beta} adds tuples
802: to $U$ so that when it leaves the execution of step 2, $\sig_U=\sig_R$. Let us analyze step 2. Observe that the condition of the ``if'' statement
803: $$\text{\tt Nonempty}(R',i_1,\dots,i_j,i,S\times\{a\})\neq\text{''no''}$$
804: of step 2.1 is satisfied if and only if there exists a tuple ${\bf t_1}\in R$ such that $\pr_{i_1,\dots i_j} {\bf t_1}\in S$ and
805: $\pr_i {\bf t_1}=a$. Hence if such a tuple does not exist then $(i,a,b)$ is not in $\sig_{R^*}$ and nothing needs to
806: be done for $(i,a,b)$. Now consider the condition of the ``if'' statement in step 2.2 which is given by
807: $$\begin{array}{c}\text{\tt Nonempty}(\text{\tt Fix-values}(R',\pr_1 {\bf t_1},\dots,\pr_{i-1} {\bf t_1}), \\
808: i_1,\dots,i_j,i,S\times\{b\})\neq\text{''no''}\end{array}$$
809:
810: This condition is satisfied if and only if there exists some ${\bf t_2}$ in $R$ such that $\pr_{i_1,\dots,i_j} {\bf t_2}\in S$,
811: $\pr_{1,\dots,i-1} {\bf t_2}=\pr_{1,\dots,i-1} {\bf t_1}$ and $\pr_i {\bf t_2}=b$. It is immediate to see that if
812: the condition holds then ${\bf t_2}\in R^*$ and $({\bf t_1},{\bf t_2})$ witnesses $(i,a,b)$. It only remains to show that if $(i,a,b)\in\sig_{R^*}$ then
813: such a ${\bf t_2}$ must exist: Let
814: ${\bf t_a},{\bf t_b}$ be tuples in $R^*$ witnessing $(i,a,b)$ and let ${\bf t_1}$ be
815: the tuple returned by the call to procedure {\tt Nonempty} in step 2.1. In order to prove the existence of
816: ${\bf t_2}$ we shall use the usual trick. First define a tuple ${\bf u}$ as
817: $\varphi({\bf t_1},{\bf t_a},\dots,{\bf t_a},{\bf t_b})$ and finally let us define ${\bf t_2}$
818: as $\varphi({\bf t_1},{\bf t_1},\dots,{\bf t_1},{\bf u})$. Since ${\bf t_1},{\bf t_a},{\bf t_b}$
819: belong to $R^*$ and $R^*$ is invariant under $\varphi$ we can conclude that ${\bf t_2}$ belongs to $R^*$.
820: Let us show that $\pr_{1,\dots,i-1} {\bf t_2}=\pr_{1,\dots,i-1} {\bf t_1}$:
821: For each $l\in [i-1]$, let $c_l$ be $\pr_l {\bf t_1}$ and let $d_l$ be $\pr_l {\bf t_a}=\pr_l {\bf t_b}$.
822: If $\{c_l,d_l\}$ is a majority pair then $\pr_l {\bf u}=\varphi(c_l,d_l,\dots,d_l,d_l)=d_l$ and
823: hence $\pr_l {\bf t_2}=\varphi(c_l,c_l,\dots,c_l,d_l)=c_l$. Otherwise, $\{c_l,d_l\}$ is a minority
824: pair and hence $\pr_l {\bf u}=\varphi(c_l,d_l,\dots,d_l,d_l)=c_l$.
825: Consequently, $\pr_l {\bf t_2}=\varphi(c_l,c_l,\dots,c_l,c_l)=c_l$ and we are done. Finally we
826: need to see that $\pr_i {\bf t_2}=b$. Observe that since $\{a,b\}$ is a minority pair
827: we have that $\pr_i {\bf u}=\varphi(a,a,\dots,a,b)=b$ and hence $\pr_i {\bf t_2}=\varphi(a,a,\dots,a,b)=b$.
828:
829:
830: We have just proved that, if $U$ is the representation output by
831: the procedure in Step 4, then $\sig_U=\sig_{R^*}$. It is
832: straightforward to verify that step 3 guarantees that for each $I$
833: with $|I|\leq k-1$, $\pr_I U=\pr_I R^*$. The analysis here is
834: basically identical to that of step 2.3 in procedure {\tt Fix-values}.
835: Consequently, $U$ is a representation of $R^*$.
836:
837:
838: At each iteration of step 2, at most $2$ tuples are added for each $(i,a,b)$ in $\sig_{R^*}$.
839: Furthermore at each iteration of step 3, at most one tuple is added per each $k'$, $I$, with $|I|\leq k-1$
840: and tuple in $\pr_I R_{j+1}$. Consequently,
841: $U$ is compact. This completes the proof of its correctness.
842:
843:
844: Let us study the running time of procedure {\tt Next-beta}. The loop of step $2$ is performed $n|A|^2$ times and the
845: cost of each iteration is basically the cost of steps 2.1 and 2.2 in which other procedures are called.
846: The cost of calling
847: {\tt Nonempty}$(R',i_1,\dots,i_j,i,S\times\{a\})\}$ in step 2.1 is $O(((n|A|)^k+r)^{k+2} |S| n)$
848: where $r$ is $|\pr_{i_1,\dots,i_j,i} R|$.
849:
850: The cost of calling
851: $$\begin{array}{c}\text{\tt Nonempty}(\text{\tt Fix-values}(R',\pr_1 {\bf t_1},\dots,\pr_{i-1} {\bf t_1}), \\
852: i_1,\dots,i_j,i,S\times\{b\})\end{array}$$
853:
854: in step 2.2 is the sum of the call to {\tt Fix-values} which is
855: $O((n|A|)^{(k+1)(k+2)})$ and the call to ${\tt Nonempty}$ which is
856: $O(((n|A|)^k+r)^{k+2} |S| n)$. Therefore, the total cost of an
857: iteration of the loop of step $2$ is
858: $$O\left(\left((n|A|)^k+r\right)^{k+2} |S| \; n +
859: (n|A|)^{(k+1)(k+2)}\right)$$ Hence, in order to obtain the total
860: running time for the procedure we only need to multiply the previous
861: quantify by the number of iterations, which is $n|A|^2$, obtaining
862:
863: $$n|A|^2\left(\left((n|A|)^k+r\right)^{k+2} |S| \; n +
864: (n|A|)^{(k+1)(k+2)}\right)$$
865:
866: Let us take a closer look at the value of $r=|\pr_{i_1,\dots,i_j,i}
867: R|$. It is important to notice here that the set of possible
868: constraints $S$ that can appear in an instance is {\em infinite} and
869: henceforth it is not possible to bound the value of $j$.
870: Consequently, the value of $r$ might be exponential in the worst
871: case. However, it would be possible to bound the value of $j$ and
872: get a polynomial bound for $r$ if a {\em finite} subset $\Gamma$ of
873: $\inv(\varphi)$ is fixed beforehand and we assume that all
874: constraint instances use only constraint relations from $\Gamma$.
875: Such a situation is not completely unusual. In fact, a good number
876: of results on the complexity of $\csp(\Gamma)$ including the
877: pioneering work of Schaeffer~\cite{Schaefer:1978} assumes $\Gamma$
878: to be finite. By using the procedure {\tt Next-beta} it could be
879: possible to define a polynomial-time algorithm that solves
880: $\csp(\Gamma)$ for every finite subset $\Gamma$ of $\inv(\varphi)$.
881: However we are aiming here for a more general result. To this end,
882: we define a new procedure {\tt Next} which makes a sequence of calls
883: to {\tt Next-beta}.
884:
885: \begin{tabbing}
886: {\bf Procedure} {\tt Next}($R',i_1,\dots,i_j,S$) \\
887: {\em Step 1} \ \= {\bf set} $l:=0$, $U_l:=R'$ \\
888: {\em Step 2} \> {\bf while} $l<j$ {\bf do} \\
889: {\em Step 2.1} \> \ \ \ \= {\bf set} $U_{l+1}:=\text{\tt Next-beta}(U_l,i_1,\dots,i_{l+1},\pr_{1,\dots,l+1} S)$ \\
890: {\em Step 2.2} \> \> {\bf set} $l:=l+1$ \\
891: \> {\bf end while} \\
892: {\em Step 3} \> {\bf return } $U_j$
893: \end{tabbing}
894:
895: Observe that at each call of the procedure {\tt Next-beta} in step
896: 2.1, the value of $r$ can be bounded by $|\pr_{1,\dots,l}
897: S||A|$, and hence the running time of each call to {\tt Next-beta}
898: can be bounded (very grossly) by
899: $$O\left(n^{(k+1)(k+2)+1}
900: |A|^{(k+1)(k+2)+2} |S|^{k+3}\right)$$
901:
902: Finally the running time of {\tt Next} is obtained by multiplying by
903: $n$ (which always bounds $j$) the previous quantity.
904:
905: \begin{lem}
906: \label{le:next} For every $n\geq 1$, every $n$-ary relation $R$
907: invariant under $\varphi$, every compact representation $R'$ of $R$,
908: every $i_1,\dots,i_j\in [n]$, and every $j$-ary relation $S$
909: invariant under $\varphi$, $\text{\tt Next}(R',i_1,\dots,i_j,S)$
910: computes a compact representation of $R^*=\{{\bf t}\in R :
911: \pr_{i_1,\dots,i_j}\in S\}$ in time $O\left((n|A|)^{(k+1)(k+2)+2}
912: |S|^{k+3}\right)$. Furthermore $R^*$ is invariant under $\varphi$.\qed
913: \end{lem}
914:
915: Finally, we have
916:
917: \begin{cor}
918: \label{cor:solve} Algorithm {\tt Solve} decides correctly if an
919: instance $\mathcal P$ of $\csp(\inv(\varphi))$ is satisfiable in
920: time $O(m(n|A|)^{(k+1)(k+2)+2} |S^*|^{k+3})$ where $n$ is the number
921: of variables of ${\mathcal P}$, $m$ is its number of constraints and
922: $S^*$ is the largest constraint relation occurring in ${\mathcal
923: P}$.\qed
924: \end{cor}
925:
926:
927: \section{Acknowledgments}
928: Research partially supported by the MCyT under grants TIC
929: 2002-04470-C03, TIC 2002-04019-C03, TIN 2004-04343, the EU PASCAL Network of Excellence,
930: IST-2002-506778, and the
931: MODNET Marie Curie Research Training Network, MRTN-CT-2004-512234.
932:
933:
934:
935:
936: \bibliographystyle{plain}
937: \bibliography{../../common/bibliography}
938:
939:
940:
941:
942:
943:
944:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957:
958:
959: \end{document}
960: