Algorithm Search⌘K

Theoremadvanced

Lin-Zhao loop formula theorem

Also called loop formulas.

The stable models of a finite normal program are exactly the models of its completion that satisfy one loop formula for each loop of the positive dependency graph.

The Lin-Zhao theorem gives a classical description of the stable models of any finite normal program. The Clark completion admits extra models in which atoms on a positive cycle support each other, and Fages' theorem says this is the only problem. Lin and Zhao (2004) found the formulas that remove exactly these extra models: one loop formula for each loop of the program. With them, a SAT solver can compute stable models of programs that are not tight, which their system ASSAT did, and the same formulas, as loop nogoods, are part of modern answer set solvers.

Statement

Let PP be a finite ground normal program over the atoms AA, with rules h←b1,…,bm,not c1,…,not ckh \leftarrow b_1, \ldots, b_m, \mathit{not}\ c_1, \ldots, \mathit{not}\ c_k. The positive dependency graph GPG_P has the vertices AA and an edge h→bih \to b_i for each rule and each positive body atom bib_i.

  • A loop is a nonempty set L⊆AL \subseteq A such that for all a,b∈La, b \in L there is a path of length at least one from aa to bb in GPG_P that stays inside LL. A single atom is a loop only if it has a self edge.
  • The external support ES(L)\mathrm{ES}(L) is the set of rules whose head is in LL and which have no positive body atom in LL.
  • The loop formula of LL is
LF(L)=(⋁a∈La)→⋁r∈ES(L)body(r),\mathrm{LF}(L) = \Big(\bigvee_{a \in L} a\Big) \rightarrow \bigvee_{r \in \mathrm{ES}(L)} \mathrm{body}(r),

where body(r)=b1∧⋯∧bm∧¬c1∧⋯∧¬ck\mathrm{body}(r) = b_1 \wedge \cdots \wedge b_m \wedge \neg c_1 \wedge \cdots \wedge \neg c_k and the empty disjunction is ⊥\bot.

Theorem (Lin and Zhao 2004). A set M⊆AM \subseteq A is a stable model of PP if and only if MM is a model of Comp(P)\mathrm{Comp}(P) and of LF(L)\mathrm{LF}(L) for every loop LL of PP.

A loop formula says: if some atom of the loop is true, the loop must get support from outside itself.

In plain words

Two facts can hold each other up with nothing else under them: "the door is locked because the alarm is on, and the alarm is on because the door is locked". The plain reading of a program as "true when a rule applies" accepts such a pair. The stable model reading does not, because nothing starts the chain. The theorem finds every group of atoms that can lean on each other in this way, and adds one condition per group: if any member of the group is true, then some rule must make it true without using the group. With these extra conditions, the plain reading gives exactly the stable models, and a general solver for logic formulas can find them.

Proof

The theorem is from Lin and Zhao (2004). The short proof below goes through the least model of the reduct, lm(PM)\mathrm{lm}(P^M), and uses Steps 1 and 2 of the proof of Fages' theorem: the models of Comp(P)\mathrm{Comp}(P) are the supported models (M=TP(M)M = T_P(M)), and every stable model is supported.

Stable implies the loop formulas. Let M=lm(PM)M = \mathrm{lm}(P^M). It is a model of the completion by Step 2. Let LL be a loop with L∩M≠∅L \cap M \neq \emptyset. Compute lm(PM)\mathrm{lm}(P^M) by forward chaining, adding one atom at a time, and let aa be the first atom of LL that is added. It is added by a rule a←b1,…,bma \leftarrow b_1, \ldots, b_m of PMP^M whose bib_i were added before aa, so they are in MM and not in LL. This rule comes from a rule rr of PP with no cj∈Mc_j \in M. So r∈ES(L)r \in \mathrm{ES}(L), its body is true in MM, and LF(L)\mathrm{LF}(L) holds.

The loop formulas imply stable. Let MM be a model of Comp(P)\mathrm{Comp}(P) and of all loop formulas. Then MM is supported, and lm(PM)⊆M\mathrm{lm}(P^M) \subseteq M as in Step 3 of Fages' proof. Suppose that D=M∖lm(PM)D = M \setminus \mathrm{lm}(P^M) is not empty. For each a∈Da \in D, take any rule rr with head aa and body true in MM; one exists because MM is supported. If all positive atoms of rr were in lm(PM)\mathrm{lm}(P^M), the rule a←b1,…,bma \leftarrow b_1, \ldots, b_m of PMP^M would put aa in lm(PM)\mathrm{lm}(P^M). So rr has a positive body atom in DD. Hence every vertex of the subgraph of GPG_P induced by DD has an edge inside DD. Take a strongly connected component CC of this subgraph that is a sink: no edge leaves CC to the rest of DD. Each vertex of CC has an edge inside DD, so inside CC, and CC is a loop. Since C⊆MC \subseteq M, LF(C)\mathrm{LF}(C) gives a rule r∈ES(C)r \in \mathrm{ES}(C) whose body is true in MM. Its head is in C⊆DC \subseteq D, so by the argument above it has a positive body atom b∈Db \in D, and b∉Cb \notin C because rr is external. The edge from the head to bb leaves CC inside DD, which contradicts the choice of CC. So D=∅D = \emptyset and M=lm(PM)M = \mathrm{lm}(P^M).

A check by hand. Take

p ← q.    q ← p.    p ← not r.    r.

The completion is p↔q∨¬rp \leftrightarrow q \vee \neg r, q↔pq \leftrightarrow p, rr. Its models are {r}\{r\} and {p,q,r}\{p, q, r\}. The only loop is {p,q}\{p, q\}, with external support p←not rp \leftarrow \mathit{not}\ r, so LF({p,q})=p∨q→¬r\mathrm{LF}(\{p, q\}) = p \vee q \rightarrow \neg r. It is false in {p,q,r}\{p, q, r\} and true in {r}\{r\}, which is the only stable model: the reduct by {p,q,r}\{p, q, r\} is {p←q, q←p, r}\{p \leftarrow q,\ q \leftarrow p,\ r\}, whose least model is {r}\{r\}.

Consequences

  • ASSAT. Lin and Zhao compute stable models with a SAT solver: solve the clauses of the completion; if the model MM is not stable, the proof above finds a violated loop in M∖lm(PM)M \setminus \mathrm{lm}(P^M) in linear time with Tarjan's algorithm; add its loop formula and solve again. Each round removes MM, and the loop formulas are added only when they are needed.
  • Fages' theorem. A tight program has no loops, so the theorem reduces to the completion alone.
  • Conflict-driven solvers. In conflict-driven answer set solving, the solver clasp treats the completion as nogoods for unit propagation and adds loop nogoods when an unfounded set is found during the search (Gebser et al. 2012).
  • Many loops. The number of loops can be exponential. If PP has the rules ai←aja_i \leftarrow a_j for all i≠ji \neq j among nn atoms, every set of at least two atoms is a loop, which gives 2n−n−12^n - n - 1 loops. Lifschitz and Razborov (2006) proved that this cannot be avoided by a cleverer formula in the same atoms: if P⊈NC1/poly\mathrm{P} \not\subseteq \mathrm{NC}^1/\mathrm{poly}, there is no translation of programs into propositional formulas over the same atoms that preserves the models and has polynomial size. Translations with new atoms of polynomial size exist, so the bound is about the vocabulary.

Tightness

  • All loops are needed, not only the maximal ones. Take aa, a←ba \leftarrow b and b←a,bb \leftarrow a, b. The loops are {b}\{b\}, from the self edge, and {a,b}\{a, b\}. The completion a↔⊤a \leftrightarrow \top, b↔a∧bb \leftrightarrow a \wedge b has the models {a}\{a\} and {a,b}\{a, b\}, and the only stable model is {a}\{a\}. The maximal loop {a,b}\{a, b\} has the fact aa as external support, so its formula is always true. The loop {b}\{b\} has no external support, and LF({b})=b→⊥\mathrm{LF}(\{b\}) = b \rightarrow \bot removes {a,b}\{a, b\}.
  • The completion is needed. For p←not qp \leftarrow \mathit{not}\ q there are no loops, so the loop formulas alone allow every set of atoms. The completion makes {p}\{p\} the only model.
  • Finiteness is needed. The infinite program pi←pi+1p_i \leftarrow p_{i+1} for i=0,1,2,…i = 0, 1, 2, \ldots has no loops, as its graph has no cycle, yet its completion has the model in which every pip_i is true, which is not stable.

History

Lin and Zhao presented loop formulas and ASSAT at AAAI 2002 and published the full version in 2004. The home page of ASSAT gives a correction to the definition of loops in the published paper. Later work extended loop formulas to disjunctive programs and to arbitrary propositional formulas. Lifschitz and Razborov (2006) explained why the number of loop formulas has to be large, and solvers such as clasp turned loop formulas into learned nogoods (Gebser et al. 2012).

References

  1. Fangzhen Lin and Yuting Zhao, ASSAT: computing answer sets of a logic program by SAT solvers, Artificial Intelligence 157(1-2), 115 to 137 (2004), the definitions of loops and loop formulas, the main theorem and the ASSAT procedure
  2. Vladimir Lifschitz and Alexander Razborov, Why are there so many loop formulas?, ACM Transactions on Computational Logic 7(2), 261 to 268 (2006), the lower bound on the size of translations without new atoms
  3. François Fages, Consistency of Clark's completion and existence of stable models, Methods of Logic in Computer Science 1(1), 51 to 60 (1994), the case of programs without positive cycles
  4. Martin Gebser, Roland Kaminski, Benjamin Kaufmann and Torsten Schaub, Answer Set Solving in Practice, Morgan and Claypool (2012), the chapter on the characterization of stable models by completion and loop nogoods, and their use in clasp

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/CK4JH0/text.yaml