1 Introduction

The need for logics that could capture human way of thinking triggered the development of an area of Artificial Intelligence called nonmonotonic reasoning. A number of formalisms emerged. One of the most important and best studied is circumscription introduced by McCarthy [17]. The circumscription of a formula is the set of its minimal models that are supposed to represent possible situations that are consistent with common sense.

It is often the case [6, 9, 11, 18] that models are compared according to the preorder \((\le _{(P,Z)})\) induced by a partition of variables V into three subsets PZQ (possibly empty) where P — variables that are subject to minimizing, Q — variables that maintain the fixed value, and Z — variables whose value can vary. Now, for two assignments \(\alpha ,\beta : V \rightarrow D\) we will have \((\alpha \le _{(P,Z)}\beta )\) if \(\alpha [Q] = \beta [Q]\) (\(\alpha \) is equal to \(\beta \) on variables in Q) and \(\alpha [P] \le \beta [P]\) (\(\alpha \) is less than or equal to \(\beta \) on variables in P) where \(\le \) is the coordinatewise extension of the natural order on \(\{0, 1 \}\) with \(0 < 1\).

As every logical formalism does, circumscription gives rise to two main computational problems: the model-checking problem and the inference problem. In this paper we concentrate on the inference problem for propositional circumscription, called also the minimal inference problem. In the most general formulation an instance of this problem in the Boolean case consists of two CNF formulas: a knowledge base \(\varphi \) and a query \(\psi \) over the same set of variables V partitioned into PZQ. In the minimal inference problem we ask if every \((\le _{(P,Z)})\)-min model (minimal model wrt. \((\le _{(P,Z)})\)) of \(\varphi \) is a model of \(\psi \). Since this task can be performed for every clause of \(\psi \) independently and we are interested in the complexity of the problem up to polynomial time reduction, we can assume that \(\psi \) is a disjunction of propositional literals (a clause). This problem is in general \(\Pi ^{P}_2\)-complete [10]. Thus, one considers the general minimal inference problem \(\text {GMININF}(\Gamma )\) parameterized by a set of relations \(\Gamma \) over \(\{0,1 \}\).

figure a

The complete complexity classification of \(\text {GMININF}(\Gamma )\) with respect to \(\Gamma \) has been obtained after a series of papers, e.g. [6, 8, 10, 15] in [9]. Under usual complexity theoretical assumptions, in this case that: \(\text {P} \subsetneq \text {coNP} \subsetneq \Pi ^{P}_2\), it is shown that \(\text {GMININF}(\Gamma )\) is either \(\Pi ^P_2\)-complete, or coNP-complete, or in P. This raises a question about a similar classification in many-valued logics, or, more generally, over arbitrary finite domains. Especially that circumscription over larger finite domains has been studied in the literature, e.g. in [7, 20].

The same course of events took place in the case of the problem \(\text {CSP}(\Gamma )\) where a question is whether a given conjunction of atomic formulas over the signature of \(\Gamma \) is satisfiable. In [22], Schaefer established the dichotomy between NP-complete and in P in the case where \(\Gamma \) is over the two-element domain. Then researchers turned to a so-called Feder-Vardi conjecture that states that a similar dichotomy holds for arbitrary finite domains. The understanding and many advanced partial resultsFootnote 1, see [16] for a recent survey, were possible thanks to the development of the so-called algebraic approach [5, 12]. This approach has been also already applied to the model checking and the inference problem in propositional circumscription over arbitrary finite domains in [19]. Here we use algebra for the inference problem in a bit different formulation.

Certainly every relation \(R \subseteq D^n\) over any finite domain D can be defined by a conjunction of disjunctions of disequalities (a CNF of disequalities) of the form \((x \ne d)\) where x is a variable and \(d \in D\) simply by the formula: \(\bigwedge _{(d_1, \ldots , d_n) \notin R} (x_1 \ne d_1 \vee \cdots \vee x_n \ne d_n)\). This implies that in the most general version of the minimal inference problem the input may consist of a CNF of disequalities that states for a knowledge base, a CNF of disequalities that states for a query and a linear order \(\mathcal {O}= (D; \le ^{\mathcal {O}})\). The preorder \(\le _{(P,Z)}^{\mathcal {O}}\) is defined as in the two-element case with a difference that we use \(\le ^{\mathcal {O}}\) on coordinates instead of \(0 < 1\). Since CNFs of disequalities coincide with clauses if \(\left| D \right| = 2\), we have that the minimal inference problem in this formulation is \(\Pi ^P_2\)-hard. It is straightforward to show that the problem is in fact \(\Pi ^P_2\)-complete. Thus, it is natural to ask about the complexity of the parametrized version \(\text {GMININF}(\Gamma , \mathcal {O})\) defined below. As in the Boolean case we can assume that a query consists of a single disjunction of disequalities.

figure b

For an example, consider \(\Gamma \) over \(D = \{1,2,3 \}\) containing the relation \(R_{\ne } := \{ (d_1, d_2) \in D^2 \mid d_1 \ne d_2 \}\) and the order \(1<^{\mathcal {O}}2 <^{\mathcal {O}}3\). A formula \(R_{\ne }(x_1, x_2) \wedge R_{\ne }(x_2, x_3) \wedge R_{\ne }(x_3, x_4) \wedge R_{\ne }(x_2, x_3)\) and a disjunction \((x_1 \ne 2 \vee x_4 \ne 1)\) form an instance of \(\text {GMININF}(\Gamma , \mathcal {O})\). This problem is \(\Pi ^P_2\)-complete. Throughout the paper we give parametrizations of \(\text {GMININF}(\Gamma , \mathcal {O})\) of lower complexity.

Fig. 1.
figure 1

An illustrative presentation of the lattice of relational clones over a domain D.

Contribution. Our attack on the complexity classification of \(\text {GMININF}(\Gamma , \mathcal {O})\) is based on the algebraic approach. All the notions we use in this paper are defined carefully in Sect. 2. As explained there in order to complete the classification task, it is enough to establish the complexity only for relational clones that are constraint languages closed under primitive positive definitions. Equivalently, a relational clone is the set, denoted by \(\text {Inv}(F)\), of all relations invariant under (preserved by) all operations in some set F. The relational clones over D are organized in the lattice ordered by inclusion. The larger is the relational clone, the complexity of the problem is harder. An illustrative presentation of the lattice over some D containing only kinds of relational clones we look at in this paper is presented in Fig. 1. For a pair of relational clones linked by a line the one placed higher contains the one which is below. The solid lines indicate that there are no relational clones inbetween, the dashed ones that there might be some. The top element of the lattice is the set of all relations \(\Gamma _D\) over D. The only operations that preserve all relations in \(\Gamma _D\) are projections. The bottom of the lattice is the set of relations primitively positively definable by means of equality. Such are preserved by all operations over D.

The problem \(\text {GMININF}(\Gamma _D, \mathcal {O})\) is \(\Pi ^P_2\)-complete for all \(\left| D \right| \ge 2\). To find subproblems of lower complexity we climb down the lattice of relational clones. The natural choice for the languages to be studied first are maximal constraint languages that in the lattice lay directly below \(\Gamma _D\). According to Rosenberg’s Five Types Theorem [21], it is enough to consider languages of the form \(\text {Inv}(\{f \})\) where f is a unary operation, a semiprojection, a binary idempotent operation, a majority operation or an affine operation, see Fig. 1. Their complexity was analyzed for many problems parametrized by constraint languages: for CSPs the result can be found in [1, 4] We show that \(\text {GMININF}(\Gamma ,\mathcal {O})\) is coNP-hard for all such languages. Furthermore for maximal conservative (i.e., containing all unary relations) languages the problem is either \(\Pi ^P_2\)-complete or coNP-complete. See [3] for the CSP classification over conservative languages.

In order to find tractable (polynomial-time decidable) classes we climb down the lattice of relational clones even further. In particular we give dichotomies between coNP-complete and P for:

  • \(\text {GMININF}(\text {Inv}(\{\sqcap , \sqcup \}), \mathcal {O})\) where \(\sqcap , \sqcup \) are the join and the meet of some lattice, and

  • \(\text {GMININF}(\text {Inv}(\{\sqcap , f \}), \mathcal {O})\) where \(\sqcap \) is the meet of some semilattice and f a newly defined pms-operation.

This gives us new large tractability classes and new coNP-hardness results. Futhermore, our algorithms are based on polymorphisms which is crucial for further generalizations, consult again [16] to see the importance of polymorphisms in providing algorithms for the CSP.

Related Work. Classifications such as a trichotomy for \(\text {GMININF}(\Gamma )\) for \(\Gamma \) over the two-element domain as one presented in [9] are much easier to be obtained than analogical results over arbitrary finite domains. The reason is that in the two-element case, the lattice of relational clones (so-called Post’s lattice) has countably many and very well described elements. Thus, in order to obtain a classification it is enough to consider the problem for each of them. The situation is very different already over the three-element domain where there are uncountably many relational clones and the lattice is not comprehensible.

The results on the minimal inference problem over arbitrary finite domains included in [19] concern a version of \(\text {GMININF}(\Gamma , \mathcal {O})\) where the query \(\psi \) is a single atomic formula \(R(x_1, \ldots , x_k)\) where R corresponds to some k-ary relation over the domain of \(\Gamma \), and the order \(\mathcal {O}\) is a part of the input. The authors of [19] provide mainly preliminary results that may be seen as tools for classifying the problem. Some of these results such as Theorem 1 we reprove here for our version of the problem and use heavily in our paper. The only complexity result in [19], however, is a dichotomy between \(\Pi ^P_2\)-complete and in coNP for conservative languages \(\Gamma \) over the three-element domainFootnote 2 and even this specific result follows in a rather straightforward way from the dichotomy for \(\text {CSP}(\Gamma )\) over the three-element domain [2].

In this paper, for the first time, we provide complexity results characteristic for the minimal inference problem over larger domains. We expect the classification for the problem \(\text {GMININF}\) to be completely different than and not easily obtainable from the one for \(\text {CSP}\). This is already true over two elements. For the first time, we provide here polynomial algorithms. The tractability results for \(\text {GMININF}(\text {Inv}(\{\sqcap , \sqcup \}), \mathcal {O})\) and \(\text {GMININF}(\text {Inv}(\{\sqcap , f \}), \mathcal {O})\) substantially generalize these for \(\text {GMININF}(\text {Inv}(\wedge , \vee ))\) and \(\text {GMININF}(\text {Inv}(\{\wedge , (x \wedge (y \vee \lnot z)) \}))\) from the two-element world. Our dichotomy: between \(\Pi ^P_2\)-complete and in coNP for conservative maximal languages generalize a dichotomy between these two classes for the two-element domain from [9] and for the three-element conservative case (up to a small difference in the definition of the problems) from [19].

2 Preliminaries

We write \(t = (t[1], \ldots , t[n])\) for a tuple of elements and [n] to denote the set \(\{1, \ldots , n\}\). The reverse of the order \(\mathcal {O}_1 = (D; \le ^{\mathcal {O}})\) is \(\mathcal {O}_2 = (D; (\le ^{\mathcal {O}})^{-1})\) where \((\le ^{\mathcal {O}})^{-1}\) is the relation \(\{ (a,b) \in D \mid (b,a) \in \le ^{\mathcal {O}}\}\).

Constraint Languages. In this paper a (constraint) language over (always finite) domain D, denoted by capital Greek letters such as \(\Gamma \), is a set of relations over D. A signature of \(\Gamma \) denoted usually by \(\tau \) is a set of relation symbols associated to relations in \(\Gamma \). For the sake of simplicity we usually use the same symbols to denote both a relation symbol and the corresponding relation. We also assume that the domain of a relation or a language under consideration is the set D.

A primitive positive formula (pp-formula) over a signature \(\tau \) is a first-order formula built exclusively from conjunction, existential quantifiers and atomic formulas over \(\tau \) and equalities, that is atomic formulas of the form \((x = y)\). We say that a relation R has a pp-definition over a set of relations \(\Gamma \) if there exists a pp-formula over the signature of \(\Gamma \) that holds exactly on those tuples that are contained in R. We say that a set of relations \(\Delta \) has a pp-definition over \(\Gamma \) if every relation in \(\Delta \) has a pp-definition over \(\Gamma \). A set of relations with a pp-definition over \(\Gamma \) is denoted by and called a relational clone.

We define a \(\Gamma \)-formula to be a conjunction of atomic formulas over a signature of \(\Gamma \). Observe that a \(\Gamma \)-formula is a special form of a pp-formula where quantifiers and equality are not in use. Let \(\psi := R(x_1, \ldots , x_k)\) be an atomic \(\Gamma \)-formula with \(x_1, \ldots , x_k\) not necessarily different and \(W \subseteq \{x_1, \ldots , x_k\}\). We write \({ \left. \psi \right| _{W} }\) for an atomic formula \({ \left. R \right| _{W} }(y_1, \ldots , y_l)\) where \({ \left. R \right| _{W} }\) is a projection of R to coordinates corresponding to variables in W and \(y_1, \ldots , y_l\) is a subsequence of \(x_1, \ldots , x_k\) containing only variables in W. For a \(\Gamma \)-formula \(\varphi = \psi _1 \wedge \ldots \wedge \psi _n\) over V and \(W \subseteq V\) we write \({ \left. \varphi \right| _{W} }\) to indicate \({ \left. \psi _1 \right| _{W} } \wedge \ldots \wedge { \left. \psi _n \right| _{W} }\).

Operations, Polymorphisms. Let \(\Gamma \) be a language over domain D. An operation \(f:D^n \rightarrow D\) is a polymorphism of an m-ary relation R if for all m-tuples \(t_1, \ldots , t_n \in R\), it holds that the tuple \((f(t_1[1], \ldots , t_n[1]), \ldots , f(t_1[m], \ldots , t_n[m]))\) is also in R. An operation f is a polymorphism of a language \(\Gamma \) if it is a polymorphism of every relation in \(\Gamma \). If \(f :D^n \rightarrow D\) is a polymorphism of \(\Gamma , R\), we say that f preserves \(\Gamma , R\). The set of relations preserved by a set of operations F is denoted by \(\text {Inv}(F)\). The following Galois correspondence links sets of polymorphisms and relational clones, see e.g. [12].

Lemma 1

Let \(\Gamma \) be a constraint language. Then if and only if \(\text {Pol}(\Gamma _2) \subseteq \text {Pol}(\Gamma _1)\).

Here we list some kinds of operations that are of use for this paper. We say that an operation \(f: D^n \rightarrow D\) is idempotent if for all \(x \in D\) we have \(f(x, \ldots , x) = x\). An operation \(f:D \rightarrow D\) that is bijective is said to be a permutation. An operation \(f: D^n \rightarrow D\) is a projection if there exists \(i \in [n]\) such that \(f(x_1, \ldots , x_i, \ldots , x_n) = x_i\) for all \(x_1, \ldots , x_n \in D\). We say that a ternary operation \(f:D^3 \rightarrow D\) is a majority operation if for all \(x, y \in D\) we have \(f(x, x, y) = f(x, y, x) = f(y, x, x) = x\), and that f is affine if for all \(x_1, x_2,x_3 \in D\) we have \(f(x_1, x_2, x_3) = x_1 - x_2 + x_3\), where \(+\) and − are the operations of an Abelian (commutative) group \((D; +,-)\). An operation \(f: D^n \rightarrow D\) with \(D \ge 3\) is said to be a semiprojection if there exists \(i \in [n]\) such that for all \(x_1, \ldots , x_n \in D\) we have \(f(x_1, \ldots , x_n) = x_i\) whenever \(\left| \{x_1, \ldots , x_n \} \right| < n\) and f is not a projection. A semilattice operation s on a set D is an idempotent operation satisfying universally the identities \(s(x,y) = s(y,x)\) and \(s(s(x,y), z) = s(x, s(y,z))\). The first of these identities implies that s is commutative and the other that s is associative. We define a ternary operation \(f: D^3 \rightarrow D\) to be a pms-operation compliant with a semilattice operation s if for all \(x,y \in D\) it satisfies: \(f(x,y,y) = x\), \(f(y,x,y) = y\) and \(f(y,y,x) = s(x,y)\).

The General Minimal Inference Problem. We now give a careful definition of the \(\text {GMININF}\) problem and provide basic results that help classifying the complexity of the problem. Some of them for a variant of the problem we study here are already available in the literature [8, 9, 19].

Let V be a set of variables and D a finite set. We use small Greek letters: \(\alpha , \beta , \gamma \) to denote assignments of the type \(V \rightarrow D\). We say that \(\alpha : V_1 \rightarrow D\) is a restriction of \(\beta : V_2 \rightarrow D\) to (variables in) \(V_1\) if \(V_1 \subseteq V_2\) and for all \(v \in V_1\), we have \(\alpha (v) = \beta (v)\). In this case we also say that \(\beta \) is an extension of \(\alpha \) to (variables in) \(V_2\). For \(\alpha : V \rightarrow D\) and \(V_1 \subseteq V\), we write \(\alpha [V_1]\) to indicate the restriction of \(\alpha \) to \(V_1\).

Let \(\mathcal {O} = (D; \le ^{\mathcal {O}})\) be a linear order. We extend the order to assignments in the natural way. For \(\alpha , \beta : V \rightarrow D\) we have \(\alpha \le ^{\mathcal {O}}\beta \) if for all \(v \in V\) it holds \(\alpha (v) \le ^{\mathcal {O}}\beta (v)\). We write \(\alpha <^{\mathcal {O}}\beta \) if \(\alpha \le ^{\mathcal {O}}\beta \) and for at least one \(v \in V\) it holds \(\alpha (v) <^{\mathcal {O}}\beta (v)\). For the purposes of this paper we need also a special preorder on assignments denoted by \((\le _{(P,Z)}^{\mathcal {O}})\) and defined as follows. Let \(\alpha , \beta : V \rightarrow D\) and PZQ be a partition of V. We have \((\alpha \le _{(P,Z)}^{\mathcal {O}}\beta )\) if \(\alpha [Q] = \beta [Q]\) and \(\alpha [P] \le ^{\mathcal {O}}\beta [P]\) and \((\alpha <_{(P,Z)}^{\mathcal {O}}\beta )\) if \(\alpha [Q] = \beta [Q]\) and \(\alpha [P] <^{\mathcal {O}}\beta [P]\). Let \(\Gamma \) be a constraint language over D and \(\varphi \) be a \(\Gamma \)-formula over variables V. An assignment \(\alpha : V \rightarrow D\) is a model of \(\varphi \) if for every conjunct \(R(x_1, \ldots , x_k)\) of \(\varphi \) we have \((\alpha (x_1), \ldots , \alpha (x_k)) \in R\). We say that a model \(\alpha \) of \(\varphi \) is a \((\le _{(P,Z)}^{\mathcal {O}})\)-minimal (\((\le _{(P,Z)}^{\mathcal {O}})\)-min) model of \(\varphi \) if there is no model \(\beta \) of \(\varphi \) such that \(\beta <_{(P,Z)}^{\mathcal {O}}\alpha \).

We now rephrase the definition of \(\text {GMININF}(\Gamma , \mathcal {O})\) from the introduction using new notions introduced in this section. The definitions are equivalent.

Definition 1

[\(\text {GMININF}(\Gamma , \mathcal {O})\)]

  • INSTANCE: A \(\Gamma \)-formula \(\varphi \) over variables V partitioned into three sets PZQ and a disjunction of disequalities \(\psi \) over V.

  • QUESTION: Is every \((\le _{(P,Z)}^{\mathcal {O}})\)-min model of \(\varphi \) a model of \(\psi \)?

For finite \(\Gamma \) we measure the complexity of \(\text {GMININF}(\Gamma , \mathcal {O})\) as a function of the length of a \(\Gamma \)-formula. In this paper we consider \(\Gamma \) and \(\mathcal {O}\) that make the problem \(\Pi ^P_2\)-complete, coNP-complete or in P. For an infinite set of relations \(\Gamma \) we use the usual convention. We say that \(\text {GMININF}(\Gamma , \mathcal {O})\) is \(\Pi ^P_2\)-hard (coNP-hard) if there is a finite \(\Gamma ' \subseteq \Gamma \) such that \(\text {GMININF}(\Gamma ', \mathcal {O})\) is \(\Pi ^P_2\)-hard (coNP-hard) and that \(\text {GMININF}(\Gamma , \mathcal {O})\) is in \(\Pi ^P_2\), coNP or P if for every finite \(\Gamma ' \subseteq \Gamma \) the problem \(\text {GMININF}(\Gamma ', \mathcal {O})\) is in \(\Pi ^P_2\), coNP or P, respectively.

The computational complexity of \(\text {GMININF}(\Gamma , \mathcal {O})\) is fully captured by the relational clone , or equivalently the set of polymorphisms of \(\Gamma \).

Theorem 1

Let \(\Gamma _1, \Gamma _2\) be constraint languages such that (or equivalently \(\text {Pol}(\Gamma _2) \subseteq \text {Pol}(\Gamma _1)\)), then there is a polynomial-time reduction from \(\text {GMININF}(\Gamma _1, \mathcal {O})\) to \(\text {GMININF}(\Gamma _2, \mathcal {O})\).

This is usually easier to look at \(\text {GMINEXT}\) than \(\text {GMININF}\).

Definition 2

[\(\text {GMINEXT}(\Gamma , \mathcal {O})\)]

  • INSTANCE: A \(\Gamma \)-formula \(\varphi \) over variables V partitioned into three sets PZQ and a partial assignment \(\alpha : V_1 \rightarrow D\) with \(V_1 \subseteq V\).

  • QUESTION: Is there an extension \(\beta :V \rightarrow D\) of \(\alpha \) such that \(\beta \) is a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model of \(\varphi \)?

The following proposition reveals the connection between the problems. We have that the complement of \(\text {GMININF}(\Gamma , \mathcal {O})\) and \(\text {GMINEXT}(\Gamma , \mathcal {O})\) are polynomially equivalent. The reduction from the complement of \(\text {GMININF}(\Gamma , \mathcal {O})\) to \(\text {GMINEXT}(\Gamma , \mathcal {O})\) comes to replacing a disjunction \(\psi := (x_1 \ne d_1 \vee \cdots \vee x_k \ne d_k)\) with \(\alpha : \{ x_1, \ldots , x_k \} \rightarrow D\) such that \(\alpha (x_i) = d_i\) for \(i \in [k]\). Now, if there is a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model \(\beta \) of \(\varphi \) (the same for both instances) that is not a model of \(\psi \) it satisfies \(\beta (x_i) = d_i\) for \(i \in [k]\), and hence \(\beta \) extends \(\alpha \). On the other hand, if there is a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model \(\beta \) of \(\varphi \) extending \(\alpha \), then it certainly does not satisfy \(\psi \). For the reduction from \(\text {GMINEXT}(\Gamma , \mathcal {O})\) to the complement of \(\text {GMININF}(\Gamma , \mathcal {O})\), we replace \(\alpha \) with \(\psi := (x_1 \ne \alpha (x_1) \vee \cdots \vee x_k \ne \alpha (x_k))\), where \(\{ x_1, \ldots , x_k \}\) is the domain of \(\alpha \). The proof is analogous.

Proposition 1

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a constraint language over D. The problem \(\text {GMINEXT}(\Gamma , \mathcal {O})\) is \(\Sigma ^P_2\)-hard, NP-hard, in NP, in P if and only if \(\text {GMININF}(\Gamma ,\mathcal {O})\), is \(\Pi ^P_2\)-hard, coNP-hard, in coNP, in P, respectively.

3 Maximal Constraint Languages

In this section we give a lower bound for \(\text {GMININF}(\Gamma , \mathcal {O})\) over maximal constraint languages \(\Gamma \) and a dichotomy for conservative maximal languages.

Definition 3

Let \(\Gamma _D\) be the set of all relations over domain D. A constraint language \(\Gamma \subseteq \Gamma _D\) is maximal if and for every \(R \notin \Gamma \), we have that . A constraint language \(\Gamma \) over D is conservative if \(\Gamma \) contains all subsets of D as unary relations.

To build the classification we use some methods [4] and some results [6, 9] known from the literature. We start with Rosenberg’s theorem.

Theorem 2

(Rosenberg Theorem). Every maximal constraint language has the form \(\text {Inv}(\{f\})\) where the operation f is of one of the following types:

  1. 1.

    a unary operation which is either a permutation or else acts identically on its range;

  2. 2.

    a binary operation which is not a projection;

  3. 3.

    a majority operation;

  4. 4.

    an affine operation;

  5. 5.

    a semiprojection.

We need to know the complexity of \(\text {GMININF}(\text {Inv}(f), \mathcal {O})\) for every type of operations from Theorem 2. In the case where \(f: D^3 \rightarrow D\) is an affine operation we focus on two particular relations \(R_{+}\) and \(R_{++}\) defined as follows. Let \(\bot , \square \in D\) be the two least elements in \(\mathcal {O}\), i.e., \(\bot<^{\mathcal {O}}\square <^{\mathcal {O}}x\) for all \(x \in D \setminus \{\bot , \square \}\). We will have:

  • \(R_{+} = \{ (x,y) \mid x + y = \bot + \square \}\),

  • \(R_{++} = \{(x,y,z) \mid x + y + z = \bot + \bot + \square \}\),

where \(+\) comes from an Abelian group \((D; +, -)\). Since \(R_{+}\) and \(R_{++}\) are defined by a single equation, it is straightforward to show that they are both in \(\text {Inv}(f)\).

Lemma 2

Let \((D; +, -)\) be an Abelian group and \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) a linear order. Then \(\text {GMININF}( \Gamma , \mathcal {O})\) with \(\Gamma = \{R_+ , R_{++} \}\) is coNP-hard.

We first prove that the problem for maximal constraint languages is coNP-hard.

Theorem 3

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a maximal constraint language over \(\Gamma \), then \(\text {GMININF}(\Gamma ,\mathcal {O})\) is coNP-hard.

We are able to prove the full dichotomy only under an additional assumption that languages are conservative.

Theorem 4

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) be a linear order and \(\text {Inv}(\{f \})\), for some operation f, a conservative maximal constraint language over D. Then we have exactly one of the following:

  1. 1.

    f is a unary operation, or there is a two-element \(D' \subseteq D\) such that \({ \left. f \right| _{D'} }\) is a projection and then \(\text {GMININF}(\text {Inv}(\{ f \}), \mathcal {O})\) is \(\Pi ^P_2\)-complete.

  2. 2.

    f is a commutative binary operation, a majority operation, or an affine operation and then \(\text {GMININF}(\text {Inv}(\{f \}), \mathcal {O})\) is coNP-complete.

4 The Minimal Inference Problem and Semilattice Operations

Let \(\mathcal {O}= (D;\le ^{\mathcal {O}})\) be a linear order, \(\Gamma \) a constraint language over D and \(\varphi \) a \(\Gamma \)-formula. We say that a model \(\alpha \) of \(\varphi \) is the least (the greatest) model of \(\varphi \) wrt. \(\le ^{\mathcal {O}}\) if for every model \(\beta \) of \(\varphi \), it holds \(\alpha \le ^{\mathcal {O}}\beta \) (\(\beta \le ^{\mathcal {O}}\alpha \)). The least (the greatest) model does not have to exist. However, if \(\Gamma \) is preserved by some well-behaved semilattice operation, then we have the following.

Observation 1

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a constraint language over D preserved by the meet \(\sqcap \) (the join \(\sqcup \)) of some meet-semilattice (join-semilattice) \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) such that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\). Let \(\varphi \) be a \(\Gamma \)-formula. Then there exists a model \(\alpha \) of \(\varphi \) such that \(\alpha \) is the least (the greatest) model of \(\varphi \) wrt the order \(\le ^{\mathcal {L}}\) and at the same time \(\alpha \) is the least (the greatest) model of \(\varphi \) wrt the order \(\le ^{\mathcal {O}}\).

In the case described by the previous observation we can quickly compute the least (the greatest) wrt both \(\le ^{\mathcal {L}}\) and \(\le ^{\mathcal {O}}\) model of a \(\Gamma \)-formula extending a given assignment \(\alpha \). The procedure is very well known [12] and may be performed by enforcing generalized arc consistency. We refer to this procedure by \(\text {leastext}(\mathcal {O}, \varphi , \alpha , V_2)\) (\(\text {greatext}(\mathcal {O}, \varphi , \alpha , V_2)\)).

Proposition 2

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a constraint language preserved by the meet \(\sqcap \) (the join \(\sqcup \)) of some meet-semilattice (join-semilattice) \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) such that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\). Then the procedure \(\text {leastext}(O, \varphi , \alpha , V_2)\) (the procedure greatext \((O, \varphi , \alpha , V_2)\) ) for a \(\Gamma \)-formula \(\varphi \) and a partial assignment \(\alpha :V_1 \rightarrow D\) with \(V_1 \subseteq V_2 \subseteq V\) returns:

  • \(\texttt {false}\) if there is no model of \({ \left. \varphi \right| _{V_2} }\) extending \(\alpha \);

  • the least (the greatest), wrt \(\le ^{\mathcal {O}}\), model of \({ \left. \varphi \right| _{V_2} }\) extending \(\alpha \).

The procedures work in polynomial time.

In the case we consider here \(\alpha [P]\) of a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model \(\alpha \) is uniquely determined by \(\alpha [Q]\).

Observation 2

Let \(\mathcal {O}= (D; \le )\) be a linear order and \(\Gamma \) a constraint language preserved by the meet \(\sqcap :D^2 \rightarrow D\) of some meet-semilattice \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) such that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\). Let \(\varphi \) be a \(\Gamma \)-formula over variables V partitioned into PZQ. Then \(\alpha \) is a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model of \(\varphi \) if and only if \( \alpha [P] = \beta [P]\) where \(\beta = \text {leastext}(\mathcal {O}, \varphi , \alpha [Q], V)\).

Theorem 5.2 in [13] states that a relation R is preserved by the meet \(\sqcap \) of a linear order \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) iff it can be defined by a conjunction of clauses of the form \((x_1 \ge ^{\mathcal {L}}a_1 \vee \cdots \vee x_k \ge ^{\mathcal {L}}a_k) \rightarrow (x_i >^{\mathcal {L}}b_i)\) where \(x_1, \ldots , x_k\) are variables; \(a_1, \ldots , a_k, b_i\) with \(i \le k\) are in D. We note that this result can be extended to all semilattices.

5 Lattice

In this section we consider relations in \(\text {Inv}(\{\sqcap , \sqcup \})\) where \(\sqcap , \sqcup \) are the meet and the join of some lattice \(\mathcal {L}= (D; \le ^{\mathcal {L}})\). For an example of such a relation consider \(D = \{ \bot , a_1,a_2, a_3, b_2, \top \}\) and the order \(\le ^{\mathcal {L}}\) such that \(\bot \le ^{\mathcal {L}}a_1 \le ^{\mathcal {L}}a_2 \le ^{\mathcal {L}}b_2 \le ^{\mathcal {L}}\top \) and \(a_1 \le ^{\mathcal {L}}a_3 \le ^{\mathcal {L}}\top \). Thus, in particular \(a_2, b_2\) are not comparable with \(a_3\). It is now straightforward to show that \(R := ((x_1 \ge ^{\mathcal {L}}a_1 \wedge x_2 \ge ^{\mathcal {L}}a_2) \rightarrow x_2 \ge ^{\mathcal {L}}b_2) \wedge (x_1 \ge a_1 \rightarrow x_2 \ge a_3)\) is preserved by \(\sqcup \) and \(\sqcap \).

In Fig. 2, we present an algorithm for \(\text {GMINEXT}(\text {Inv}(\{\sqcap , \sqcup \}), \mathcal {O})\) for the case where \(\sqcap , \sqcup \) are the meet and the join of some lattice \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) that can be extended to \(\mathcal {O}\). The algorithm works in polynomial time. By Proposition 1, it gives us a polynomial algorithm for the problem \(\text {GMININF}\).

Fig. 2.
figure 2

Algorithm lattice

Lemma 3

Let \(\mathcal {O} = (D; \le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a constraint language preserved by \(\sqcap , \sqcup \) that are the meet and the join of some lattice \(\mathcal {L} = (D; \le ^{\mathcal {L}})\) such that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\). For a given \(\Gamma \)-formula \(\varphi \) over variables V partitioned into PZQ and a partial assignment \(\alpha : V_1 \rightarrow D\) with \(V_1 \subseteq V\) we have that \(\alpha \) can be extended to a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model of \(\varphi \) iff the algorithm \(\text {Lattice}\) returns \(\texttt {true}\). The algorithm \(\text {Lattice}\) works in polynomial time.

We now turn to the hardness result. We use the notation \(Z_{a,b}^{c,d}\), where \(a \ne c\) and \(b \ne d\), for the relation \(\{(a,b), (a,d), (c,d) \}\).

Lemma 4

Let \(\mathcal {O}= (D; \le ^{\mathcal {O}})\) and \(a,b,c,d,e,f \in D\) such that \(a \ne b\), \(c <^{\mathcal {O}}d\) and \(e <^{\mathcal {O}}f\). Then \(\text {GMININF}(\Gamma , \mathcal {O})\) where \(\Gamma = \{ Z_{b,c}^{a,d}, Z_{a,e}^{b,f} \}\) is coNP-hard.

Finally we give the dichotomy.

Theorem 5

Let \(\mathcal {O}= (D;\le ^{\mathcal {O}})\) be a linear order and \(\sqcup ,\sqcap \) the meet and the join of some lattice \(\mathcal {L} = (D, \le ^{\mathcal {L}})\). Then we have one of the following.

  • If \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\) or \((\le ^{\mathcal {L}})^{-1} \subseteq \le ^{\mathcal {O}}\), then \(\text {GMININF}(\text {Inv}(\{\sqcap , \sqcup \}),\mathcal {O})\) is in P.

  • If neither \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\) nor \((\le ^{\mathcal {L}})^{-1} \subseteq \le ^{\mathcal {O}}\), then \(\text {GMININF}(\text {Inv}(\{\sqcap , \sqcup \}),\mathcal {O})\) is coNP-hard.

6 Semilattice and a \(\textit{pms}\)-operation

In this section we consider \(\text {GMININF}(\text {Inv}(\{\sqcap , f \}), \mathcal {O})\) in the case where \(\sqcap \) is the meet of some meet-semilattice \(\mathcal {L} = (D,\le ^{\mathcal {L}})\) and f is a \(pms \)-operation compliant with \(\sqcap \). When it comes to examples of relations preserved by both operations, it is straightforward to prove that all relations definable by conjunctions of clauses of the form \((x \ge ^{\mathcal {L}}d)\) and \((\lnot x_1 \ge ^{\mathcal {L}}d_1 \vee \cdots \vee \lnot x_k \ge ^{\mathcal {L}}d_k)\) are in \(\text {Inv}(\{\sqcap , f \})\) where f is a pms-operation that for three pairwise different \(d_1, d_2, d_3 \in D\) returns \((d_1 \sqcap d_2 \sqcap d_3)\).

We now turn to the complexity of the problem. Again we work rather with \(\text {GMINEXT}(\text {Inv},( \{\sqcap , f \}), \mathcal {O})\) than \(\text {GMININF}(\text {Inv}( \{\sqcap , f \}), \mathcal {O})\). The procedure in Fig. 3 solves the problem in P on the condition that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\).

Fig. 3.
figure 3

Algorithm \(\text {MeetPMS}\)

Lemma 5

Let \(\mathcal {O}= (D;\le ^{\mathcal {O}})\) be a linear order and \(\Gamma \) a constraint language preserved by both the meet \(\sqcap \) of some meet-semilattice \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) such that \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\) and a \(\textit{pms}\)-operation f compliant with \(\sqcap \). For a given \(\Gamma \)-formula \(\varphi \) over variables V partitioned into PZQ and a partial assignment \(\alpha :V_1 \rightarrow D\) with \(V_1 \subseteq V\) we have that \(\alpha \) can be extended to a \((\le _{(P,Z)}^{\mathcal {O}})\)-min model of \(\varphi \) iff the algorithm \(\text {MeetPMS}\) returns \(\texttt {true}\). The algorithm \(\text {MeetPMS}\) works in polynomial time.

We close this section by complementing Lemma 5 with a hardness result.

Theorem 6

Let \(\mathcal {O}= (D;\le ^{\mathcal {O}})\) be a linear order, \(\sqcap \) the meet of some meet-semilattice \(\mathcal {L}= (D; \le ^{\mathcal {L}})\) and f a pms-operation compliant with \(\sqcap \). Then we have one of the following.

  • If \(\le ^{\mathcal {L}}\subseteq \le ^{\mathcal {O}}\), then \(\text {GMININF}(\text {Inv}( \{\sqcap , f \}), \mathcal {O})\) is in P.

  • If \(\le ^{\mathcal {L}}\nsubseteq \le ^{\mathcal {O}}\), then \(\text {GMININF}(\text {Inv}( \{\sqcap , f \}), \mathcal {O})\) is coNP-hard.

7 Summary and Future Work

In this article we have systematically studied the complexity of the minimal inference problem over arbitrary finite domains. We considered a version of the problem parameterized by a constraint language and a linear order. We provided a dichotomy for maximal conservative languages: between \(\Pi ^P_2\)-complete and coNP-complete and two tractability results complemented by coNP-hardness results. This gives two dichotomies: between coNP-complete and in P. Furthermore, one of the tractability results is based on a newly discovered operation: a pms-operation. Identifying tractable classes and appropriate polymorphisms is crucial when one works in algebraic approach.

We believe that our research will soon result in more advanced classifications, e.g., for all conservative languages or all languages over the three-element domain. Both classifications were provided for the CSP, see [2, 3].