Algorithm Search⌘K

Definitioncore

Stratified logic program

Also called stratified negation.

A logic program is stratified when no predicate depends on its own negation. Such a program has one standard model, computed layer by layer, and every major semantics agrees on it.

A stratified logic program is a normal program whose predicates can be put in layers so that each predicate depends positively on predicates of its own or lower layers and negatively only on predicates of strictly lower layers. Apt, Blair and Walker (1988) showed that such a program has one natural model, the standard (or perfect) model, which does not depend on the choice of layers. The evaluation of stratified Datalog in databases, stratum by stratum with semi-naive evaluation, is on the Datalog pages. This page gives the definition for general logic programs and its place among the semantics of negation as failure: it is the class on which they all agree.

Definition

The dependency graph of a program PP has a vertex for each predicate and an edge from pp to qq for each rule with head predicate pp and qq in its body. The edge is positive if qq occurs in a positive literal and negative if it occurs under not\mathit{not}; an edge can be both.

A stratification of PP is a map σ\sigma from the predicates to the natural numbers such that, for each rule with head predicate pp,

  • σ(q)≤σ(p)\sigma(q) \le \sigma(p) for each predicate qq in a positive body literal, and
  • σ(q)<σ(p)\sigma(q) < \sigma(p) for each predicate qq in a negative body literal.

PP is stratified if it has a stratification. Equivalently, no cycle of the dependency graph contains a negative edge, which can be tested in linear time by computing the strongly connected components and checking that no negative edge joins two vertices of the same component.

Let PiP_i be the rules whose head predicate has stratum ii. The standard model is M0=∅M_0 = \emptyset and Mi+1M_{i+1} the least set that contains MiM_i and is closed under the rules of PiP_i, with each not q(t⃗)\mathit{not}\ q(\vec{t}) read as q(t⃗)∉Miq(\vec{t}) \notin M_i. This reading is fixed while PiP_i is evaluated, because qq lies in a lower stratum. For a finite number of strata the last MiM_i is the standard model.

A program is locally stratified (Przymusinski) if the same condition holds for its ground instance, with ground atoms in place of predicates and an ordinal-valued σ\sigma.

Examples and non-examples

  • Stratified. Reachability in a graph and its complement:

    reach(X, Y) ← edge(X, Y).
    reach(X, Y) ← edge(X, Z), reach(Z, Y).
    unreach(X, Y) ← node(X), node(Y), not reach(X, Y).
    

    The strata are {edge,node}\{\mathit{edge}, \mathit{node}\} at 0, reach\mathit{reach} at 0 or 1, and unreach\mathit{unreach} above reach\mathit{reach}. The recursion through reach\mathit{reach} is positive.

  • Stratified. {p←not q, r←p, r←r}\{p \leftarrow \mathit{not}\ q,\ r \leftarrow p,\ r \leftarrow r\} with σ(q)=0\sigma(q) = 0 and σ(p)=σ(r)=1\sigma(p) = \sigma(r) = 1. The standard model is {p,r}\{p, r\}.

  • Not stratified. {p←not q, q←not p}\{p \leftarrow \mathit{not}\ q,\ q \leftarrow \mathit{not}\ p\}: the cycle p→q→pp \to q \to p has negative edges. It has two stable models.

  • Not stratified. {p←not p}\{p \leftarrow \mathit{not}\ p\}: a negative self loop.

  • Locally stratified, not stratified. even(0)\mathit{even}(0), even(s(X))←not even(X)\mathit{even}(s(X)) \leftarrow \mathit{not}\ \mathit{even}(X). The predicate even\mathit{even} depends negatively on itself, but each ground atom even(sn+1(0))\mathit{even}(s^{n+1}(0)) depends only on even(sn(0))\mathit{even}(s^n(0)).

  • Not locally stratified. The game win(X)←move(X,Y),not win(Y)\mathit{win}(X) \leftarrow \mathit{move}(X, Y), \mathit{not}\ \mathit{win}(Y) on a graph with a cycle: the ground atoms on the cycle depend negatively on each other. The well-founded semantics leaves them undefined.

  • Agreement of the semantics. For a stratified program, the standard model is the unique stable model (Gelfond and Lifschitz 1988) and the well-founded model, which is then total (Van Gelder, Ross and Schlipf 1991). It is also a model of the completion, but the completion can have other models, as {p←p}\{p \leftarrow p\} shows.
  • Positive and definite programs. A program without negation is stratified with one stratum, and its standard model is the least model.
  • Splitting. The strata form a chain of splitting sets, so the splitting set theorem reduces the stable models of a stratified program to one least model per layer.
  • Stratified Datalog. Restricted to function-free programs with a finite database, this is the stratified negation of Datalog, evaluated in the order of a topological sort of the components.

References

  1. Krzysztof R. Apt, Howard A. Blair and Adrian Walker, Towards a theory of declarative knowledge, in Jack Minker (ed.), Foundations of Deductive Databases and Logic Programming, Morgan Kaufmann, 89 to 148 (1988), the definition of stratification and the standard model, and its independence of the stratification
  2. 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 result that a stratified program has exactly one stable model, its standard model
  3. Allen Van Gelder, Kenneth A. Ross and John S. Schlipf, The well-founded semantics for general logic programs, Journal of the ACM 38(3), 620 to 650 (1991), the result that the well-founded model of a stratified program is total and equals its standard model
  4. Krzysztof R. Apt and Roland N. Bol, Logic programming and negation: a survey, Journal of Logic Programming 19/20, 9 to 71 (1994), the sections on stratified and locally stratified programs

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