Algorithm Search⌘K

Theoremadvanced

NP-completeness of stable model existence

Also called Marek-Truszczynski theorem.

Deciding whether a finite propositional normal logic program has a stable model is NP-complete.

This theorem places the main reasoning task of answer set programming exactly in the complexity landscape. A stable model can be checked in linear time, so the existence question is in NP, and the even cycles of negation in a program can encode any 3-SAT instance, so it is NP-hard. The result is due to Marek and Truszczyński (1991), and Bidoit and Froidevaux (1991) proved it in an equivalent setting. It explains why stable model solvers search like SAT solvers, and why programs with disjunction, which reach one level higher, need a different theorem.

Statement

A finite propositional normal program PP is a finite set of rules h←b1,…,bm,not c1,…,not cnh \leftarrow b_1, \ldots, b_m, \mathit{not}\ c_1, \ldots, \mathit{not}\ c_n, where hh, the bib_i and the cjc_j are atoms from a finite set AA and m,n≥0m, n \geq 0. The program has no variables and no disjunction in the heads. For M⊆AM \subseteq A, the reduct PMP^M deletes each rule with some cj∈Mc_j \in M and deletes the negative literals of the other rules. MM is a stable model if MM is the least model of PMP^M (Gelfond and Lifschitz 1988). The size of PP is the number of rules plus the number of literals.

Theorem (Marek and Truszczyński 1991; Bidoit and Froidevaux 1991). The problem "given a finite propositional normal program PP, does PP have a stable model?" is NP-complete.

The same holds when constraints ←b1,…,not cn\leftarrow b_1, \ldots, \mathit{not}\ c_n are allowed, and NP-hardness holds already for programs in which each rule has at most three positive body atoms and at most one negative body literal.

In plain words

To check a proposed answer, you only have to follow the rules forward once, which is fast. So the question is no harder than the problems where a good guess can be checked quickly. It is also no easier than any of them. A pair of rules that say "this is true unless that is true" and "that is true unless this is true" acts like a free choice between two values, one pair for each variable of a logic formula. One more rule for each clause of the formula rejects every choice that makes the clause false. So the program has an answer exactly when the formula can be satisfied, and a fast method for answers would give a fast method for every problem in NP.

Proof

Membership in NP. A certificate is a set M⊆AM \subseteq A. The reduct PMP^M is computed in linear time, and its least model in linear time by the counter method of Dowling and Gallier (1984). Comparing it with MM takes linear time. With constraints, also check that MM satisfies no constraint body.

NP-hardness. We reduce 3-SAT. Let φ=C1∧⋯∧Ck\varphi = C_1 \wedge \cdots \wedge C_k be a CNF formula over the variables x1,…,xnx_1, \ldots, x_n. Use the atoms xix_i and xˉi\bar{x}_i for each variable and one more atom ff. For a literal ll, let σ(l)\sigma(l) be the atom that says that ll is false: σ(xi)=xˉi\sigma(x_i) = \bar{x}_i and σ(¬xi)=xi\sigma(\neg x_i) = x_i. The program PφP_\varphi has the rules

xi←not xˉi,xˉi←not xi(1≤i≤n),x_i \leftarrow \mathit{not}\ \bar{x}_i, \qquad \bar{x}_i \leftarrow \mathit{not}\ x_i \qquad (1 \leq i \leq n),
f←σ(l1),…,σ(lr),not ffor each clause C=l1∨⋯∨lr.f \leftarrow \sigma(l_1), \ldots, \sigma(l_r), \mathit{not}\ f \qquad \text{for each clause } C = l_1 \vee \cdots \vee l_r.

It has 2n+k2n + k rules and is built in linear time. For an assignment τ\tau, let Mτ={xi:τ(xi)=1}∪{xˉi:τ(xi)=0}M_\tau = \{x_i : \tau(x_i) = 1\} \cup \{\bar{x}_i : \tau(x_i) = 0\}.

(a) Every stable model MM is MτM_\tau for some τ\tau and does not contain ff. If f∈Mf \in M, the reduct deletes every rule with head ff, so ff is not in the least model, a contradiction. If neither xix_i nor xˉi\bar{x}_i is in MM, the reduct keeps the fact xi←x_i \leftarrow, so xix_i is in the least model, a contradiction. If both are in MM, the reduct deletes both rules, and no other rule has xix_i as its head, a contradiction.

(b) MτM_\tau is a stable model if and only if τ\tau satisfies φ\varphi. The reduct by MτM_\tau keeps exactly the facts xi←x_i \leftarrow with τ(xi)=1\tau(x_i) = 1, the facts xˉi←\bar{x}_i \leftarrow with τ(xi)=0\tau(x_i) = 0, and the rules f←σ(l1),…,σ(lr)f \leftarrow \sigma(l_1), \ldots, \sigma(l_r), since f∉Mτf \notin M_\tau. Its least model is MτM_\tau, plus ff if the body of some clause rule lies in MτM_\tau. That body lies in MτM_\tau exactly when every literal of the clause is false under τ\tau. So the least model equals MτM_\tau exactly when τ\tau satisfies every clause.

By (a) and (b), τ↦Mτ\tau \mapsto M_\tau is a bijection between the satisfying assignments of φ\varphi and the stable models of PφP_\varphi. In particular, PφP_\varphi has a stable model if and only if φ\varphi is satisfiable. Each clause rule has at most three positive atoms and one negative literal. With constraints, the clause rules can be written ←σ(l1),…,σ(lr)\leftarrow \sigma(l_1), \ldots, \sigma(l_r) without ff. □\square

Example. For φ=(x1∨x2)∧(¬x1∨x3)∧(¬x2∨¬x3)\varphi = (x_1 \vee x_2) \wedge (\neg x_1 \vee x_3) \wedge (\neg x_2 \vee \neg x_3), the constraint version of PφP_\varphi has the six choice rules and the constraints ←xˉ1,xˉ2\leftarrow \bar{x}_1, \bar{x}_2, ←x1,xˉ3\leftarrow x_1, \bar{x}_3 and ←x2,x3\leftarrow x_2, x_3. Its stable models are {xˉ1,x2,xˉ3}\{\bar{x}_1, x_2, \bar{x}_3\} and {x1,xˉ2,x3}\{x_1, \bar{x}_2, x_3\}, and the satisfying assignments of φ\varphi are (0,1,0)(0, 1, 0) and (1,0,1)(1, 0, 1).

Consequences

  • Brave and cautious reasoning. Deciding whether an atom aa is in some stable model is NP-complete: add the constraint ←not a\leftarrow \mathit{not}\ a. Deciding whether aa is in every stable model is coNP-complete: it fails exactly when the program with ←a\leftarrow a added has a stable model (Dantsin, Eiter, Gottlob and Voronkov 2001).
  • Search is needed. Unless P = NP, no polynomial algorithm finds stable models. Solvers such as the smodels search and conflict-driven answer set solving use the methods of SAT solvers for this reason.
  • ASP solves exactly NP. Every problem in NP can be written as a program whose stable models are the certificates, by the construction above applied to a SAT encoding obtained from the Cook-Levin theorem. This is the basis of the claim that ASP captures NP search problems.
  • Polynomial approximations. The well-founded model is computed in polynomial time and is contained in every stable model, so it can prune the search but cannot decide existence.

Tightness

  • Hard even for tight programs. The program PφP_\varphi has no positive cycle: the atoms xix_i and xˉi\bar{x}_i have no positive body, and ff depends positively only on these atoms. So the problem stays NP-complete on tight programs, where stable models are the models of the completion.
  • Polynomial cases. For a program without negation the unique stable model is the least model, found in linear time. For a stratified program the unique stable model is the perfect model, also found in polynomial time. So some negation through a cycle is necessary for hardness, and PφP_\varphi uses even cycles of length two.
  • Disjunction goes higher. For disjunctive programs, existence is Σ2p\Sigma_2^p-complete (Eiter and Gottlob 1995); for head-cycle-free disjunctive programs it stays in NP.
  • Variables go higher. For programs with variables and no function symbols, the problem is NEXPTIME-complete when the program is part of the input, and NP-complete when the program is fixed and only the facts vary (Dantsin, Eiter, Gottlob and Voronkov 2001).

History

Gelfond and Lifschitz defined stable models in 1988. Marek and Truszczyński (1991) studied autoepistemic logic, whose stable expansions correspond to stable models through Gelfond's translation, and proved among other results that the existence of a stable model of a finite propositional program is NP-complete. Bidoit and Froidevaux (1991) obtained the same bound for their default semantics of logic programs, which coincides with the stable model semantics. Marek and Truszczyński (1999) and Niemelä (1999) later used the result to argue that logic programs with stable models are a language for NP search problems, which started answer set programming as a programming method.

References

  1. Victor W. Marek and Mirosław Truszczyński, Autoepistemic logic, Journal of the ACM 38(3) (1991), the complexity results for stable expansions and for stable models of logic programs, including the NP-completeness of the existence of a stable model
  2. Nicole Bidoit and Christine Froidevaux, Negation by default and unstratifiable logic programs, Theoretical Computer Science 78(1), 85 to 112 (1991), the complexity of the default semantics of logic programs, which coincides with the stable model semantics
  3. Victor W. Marek and Mirosław Truszczyński, Stable models and an alternative logic programming paradigm, in Krzysztof R. Apt, Victor W. Marek, Mirosław Truszczyński and David S. Warren (eds.), The Logic Programming Paradigm: a 25-Year Perspective, Springer, 375 to 398 (1999), the section on the complexity of stable model existence
  4. Evgeny Dantsin, Thomas Eiter, Georg Gottlob and Andrei Voronkov, Complexity and expressive power of logic programming, ACM Computing Surveys 33(3), 374 to 425 (2001), the propositional complexity of normal programs under the stable model semantics, for existence, brave and cautious reasoning
  5. Michael Gelfond and Vladimir Lifschitz, The stable model semantics for logic programming, in Robert A. Kowalski and Kenneth A. Bowen (eds.), Logic Programming: Proceedings of the Fifth International Conference and Symposium, MIT Press, 1070 to 1080 (1988), the definition of stable models
  6. William F. Dowling and Jean H. Gallier, Linear-time algorithms for testing the satisfiability of propositional Horn formulae, Journal of Logic Programming 1(3), 267 to 284 (1984), the linear-time least model computation used in the membership proof
  7. Ilkka Niemelä, Logic programs with stable model semantics as a constraint programming paradigm, Annals of Mathematics and Artificial Intelligence 25(3-4), 241 to 273 (1999), the discussion of stable models as a language for NP search problems

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/5555AX/text.yaml