Die Präsentation wird geladen. Bitte warten

# Three-Valued Models of Program Completion

## Präsentation zum Thema: "Three-Valued Models of Program Completion"—  Präsentation transkript:

Three-Valued Models of Program Completion

Three-Valued Interpretation
To any partial interpretation I (in 2-valued logic), there corresponds the obvious 3-valued interpretation, in which atoms missing from I are assigned the truth value .

Example: Problems with Completion in 2-Valued Logic
p  p, q. Completion: p(pq) q. Program has no 2-valued model. p  p, q. p  p. Completion: p(pq)p. q. Program has 2-valued model I={q,p}

Truth Tables for 3-Valued Logic (Extensions Only!)
A A 1 A  B B A 1 A  B B A 1 AB B A 1 AB B A Attention:: AB  BA no longer holds!

Example: Completion and 3-Valued Logic
p  p, q. Completion: p(pq) q. Program has 3-valued model for p= , I={q} p  p, q. p  p. Completion: p(pq)p. q. Program has 3-valued model for p=, I={q} I={q,p}

p  p, q. q  r q  s r  r s  s Completion: p(pq) qrs rr
Uniqueness p  p, q. q  r q  s r  r s  s Completion: p(pq) qrs rr ss 2-Valued Models {p,q,r,s} {p,q,r,s} {p,q,r,s} 3-Valued Model {} Not comparable

Undefined Definition Literal q is called undefined in I, denoted by , if neither q nor its complement is in I. A conjunction of literals evaluates to undefined in I if no literal in the conjunction is false in I and at least one is undefined in I. (cmp. truth table).

Stratified Programs

Stratification (rep.) Definition (rep.) A normal program P is stratified, if all its predicate symbols have a level such that: no predicate symbol positively depends on a predicate symbol of a higher level no predicate symbol negatively depends on a predicate symbol of greater or equal level.

positively depends of an atom of greater level
Local Stratification Definition A normal program is stratified if each atom in BP can be assigned a countable ordinal level such that no atom positively depends of an atom of greater level negatively depends of an atom of equal or greater level.

Example for Local Stratification
even(s(X))  even(X). even(0). BP: {even(0)0, even(s(0))1, even(s(s(0)))2, even(…)3, …}

Perfect Model Definition Let P be a normal program and I a model. I is a perfect model for a given level of BP, if for every other model J, if a positive literal p is the atom of least level in one model, but not in the other, then p is in J. In other words, atoms of higher level are preferred for the perfect model. Przymusinski: All locally stratified programs have a perfect model, which is independent of the ranking system chosen.

Examples for Local Stratification
even(s(X))  even(X). even(0). even(0)  q(X). BP: J={q(0)0,even(0)1, even(s(s(0)))3, …} I={even(0)0, even(s(s(0)))2, …}

Well-Founded Semantics

Theorem: If a program P is locally stratified, then is has a well-founded model, which is identical to the perfect model.

Not all completed programs are consistent
Motivation Problems: Not all completed programs are consistent SLDNF is only complete if the refutation does not flounder. Stratification limits recursion. Technical Solution: 3-Valued Logic

Redefinition of „Interpretation“
Definition: Let P be a normal program. A partial interpretation I is a consistent set of literals whose atoms are in BP. A total interpretation I is a partial interpretation containing every atom in BP or its negation. A conjunction of ground literals is true in I, if all its literals are true in I. It is false, if any of its literals is false in I.

Satisfied / Falsified / Weakly Falsified
Definition: An ground clause is satisfied in a partial or complete interpretation I if the head is true in I or some subgoal is false in I. The clause is falsified if the head is false and all subgoal are true. If the head is false in I, but no subgoal is false in I then we say the clause is weakly falsified in I.

Partial / Total Model Definition: A total model of a program P is a total interpretation such that every instantiated clause of P is satisfied. A partial model of P is a partial interpretation that can be extended to a total model of P

Lemma: Let P be a normal program and I a partial interpretation
Lemma: Let P be a normal program and I a partial interpretation. If I weakly falsifies no clause from P, then I is a partial model of P. Proof: Normal programs have BP as a model. For each atom from BP, if its negation is not in I, add the atom to I.

(1) Some (positive or negative) subgoal q of the body is false in I.
Unfounded Sets Definition Let P be a normal program and I be a partial interpretation. We say A  BP is an unfounded set (of P) wrt I, if each atom p  A satisfies the following: For each instantiated clause R from P, whose head is p, (at least) one of the following holds: (1) Some (positive or negative) subgoal q of the body is false in I. (2) Some positive subgoal of the body occurs in A. A literal satisfying (1) or (2) is called a witness of unusability for clause R (wrt I)

Example For the instantiated normal program P: p(a)  p(c),  p(b).
p(b)   p(a). p(e)   p(d). p(c). p(d)  q(a),  q(b). p(d)  q(b),  q(c). q(a)  p(d). q(b)  q(a). (2): None of the heads can be derived first. the atoms {p(d), q(a), q(b), q(c)} are an unfounded set wrt I=Ø. There exists no definition for q(c). Thus (1) is satisfied.

Example For the instantiated normal program P: p(a)  p(c),  p(b).
p(b)   p(a). p(e)   p(d). p(c). p(d)  q(a),  q(b). p(d)  q(b),  q(c). q(a)  p(d). q(b)  q(a). Neither (1) nor (2) are satisfied. the atoms {p(a), p(b)} are no unfounded set wrt I=Ø!

Notation: Let S be a set of literals. Then we write S for {p : pS}

Union of Unfounded Sets
Definition The greatest unfounded set (of P) wrt I, denoted UP(I), is the union of all sets that are unfounded wrt I.

Union of Unfounded Sets
Definition The greatest unfounded set (of P) wrt I, denoted UP(I), is the union of all sets that are unfounded wrt I. Lemma Let R be a set of literals, and let A be an unfounded set of P wrt R. For any subset S  A we have that A - S is unfounded wrt R S. Lemma Let I be a partial interpretation consisting of positive literals Q and negative literals S. If I does not weakly falsify any instantiated clause of program P, then S is an unfounded set wrt Q.

Well-Founded Partial Models

Transformations A transformation is a transformation between sets of literals, whose atoms are elements of the Herbrand-base of a program P. A transformation T is called monotonic, if T(I)  T(J), whenever I  J.

UP(I) is the greatest unfounded set of P wrt I.
Transformations Definition Let P be a normal program. Transformations TP, UP and WP are defined as follows: pTP(I) iff there is some instantiated clause R of P, such that R has head p, and each subgoal literal in the body of R is true in I. UP(I) is the greatest unfounded set of P wrt I. WP(I) = TP(I)    UP(I). Lemma TP, UP and WP are monotonic transformations.

For limit ordinal , Note that 0 is a limit ordinal, and I0 = .
I and I Definition The sets I ( ranges over all countable ordinals) and I, whose elements are literals in the Herbrand-base of a program P, are defined recursively by: For limit ordinal , Note that 0 is a limit ordinal, and I0 = . For a successor ordinal  =  + 1, Finally, define

Lemma I is a monotonic sequence of partial interpretations.
Stufe Definition For any literal p in I, we define the stage of p to be the least ordinal  such that p  I. Lemma I is a monotonic sequence of partial interpretations. Proof Sketch Induction over 

Closure Ordinal Definition The closure ordinal for the sequence I is the least ordinal  such that: I = I.

Well-Founded Semantics
Definition The well-founded semantics of a program P is the “meaning” represented by the least fixed point of WP or the limit I. Every positive literal denotes that its atom is true. Every negative literal denotes that its atom is false. Missing atoms have no truth value assigned by the semantics.

UP(I0)={p(d),q(a),q(b),q(c)} WP(I0)={p(c),p(d),q(a), q(b), q(c)}
Example p(a)  p(c), p(b). p(b)  p(a). p(e)  p(d). p(c). p(d)  q(a), q(b). p(d)  q(b), q(c). q(a)  p(d). q(b)  q(a). I0=Ø TP(I0)={p(c)} UP(I0)={p(d),q(a),q(b),q(c)} WP(I0)={p(c),p(d),q(a), q(b), q(c)} TP(I1)={p(e),p(c)} UP(I1)={p(d),q(a),q(b),q(c)} WP(I1)={p(e),p(c),p(d), q(a),q(b),q(c)} TP(I2)={p(e),p(c)} …

Well-Founded Semantics
Lemma Let I be defined as above. Then I does not weakly falsify any instantiated clause R of P. Proof Sketch The definition of WP only makes the head L of R false, which was unfounded in previous iterations. Hence either the body of R was false or some atom of R was in the unfounded set. In both cases the body of R is now wrong. The monotony of WP is important for this lemma.

Well-Founded (Partial) Model
Theorem For every countable ordinal , I in the sequence described above is a partial model of P. Proof Using the first and the previous lemma.

Well-Founded (Partial) Model
Definition Suppose that for each pBP, I contains either p or p, i.e. I is a total interpretation. Then by the above theorem I is a total model and we call this the well-founded model; Otherwise, we call I the well founded partial model.

Minimal Model Theorem Every Horn program has a well-founded model I, which is the minimum model in the sense of Van Emden and Kowalski, that is, its positive literals are contained in every Herbrand model.

Theorem: If a program P is locally stratified, then is has a well-founded model, which is identical to the perfect model.

Example: Suppose all Valid Moves From one Position to an other are in the EDB
winning(X)  move(X,Y), not winning(Y). F F player 1 moves T T player 2 moves player 2 moves T T F F F T player 1 loses player 1 loses player 1 zieht F F F F player 2 loses (a) (b) (c)

Example The program is not locally stratified, because the Herbrand-instantiation contains a clause, in which winning negatively depends on itself: winning(a)  move(a,a), not winning(a). This destroys the perfect model, even if move(a,a) is not contained in the EDB.

Computational Complexity
The set of statements derivable shall be “reasonably computable”. We need to show that the data-complexity of well-founded semantics is polynomial. Well-founded semantics is competitive with other methods, such as stratified semantics and fitting model. For logic programs without functions the Herbrand-universe is finite and its construction effective. (Class Datalog).

Computational Complexity
Limit the discussion to logic programs without function symbols. The Herbrand universe of a program is the set of constants appearing in the program. Consider a fixed IDB PI consisting of a set inference rules, which might be applied to various EDBs or sets of facts.

Computational Complexity
Predicates that appear as subgoals in PI, but not in the head of any rule, constitute the EDB predicates. The EDB PE is a set of positive ground literals ranging over the EDB predicates. (The constants in PE may or may not appear in PI.) given an EDB PE: P(PE) = PI PE is a Logic program and its well-founded partial model is denoted by I(PE). PI defines the transformation from PE to I(PE).

Data Complexity Definition: The data complexity of an IDB is defined as the computational complexity of deciding the answer to a ground atomic query as a function of the size of the EDB. In the context of well-founded semantics, this means deciding whether the ground atom is positive in the well-founded partial model.

Data Complexity Since the IDB is fixed, the predicates in the well- founded model have fixed number and arity. The Herbrand-base has a size that is polynomial in the size of the EDB. Also since the IDB is fixed, the size of the Herbrand instantiation of the program is polynomial in the size of the EDB.

Data Complexity Theorem: The data complexity of the well-founded semantics for function-free programs is polynomial time. Comments: The Fitting model has polynomial data complexity for function free programs. Determining whether P has a stable model is NP- complete for general propositional logic programs.

Nachteile der wohl-fundierten Semantik
ausgeblendet Die wohl-fundierte Semantik hat folgenden Nachteil: Sie ist unfähig, Folgerungen zu behandeln, die nur durch Methoden wie „Factoring“ oder ähnliche Techniken (z.B. „ancestor resolution“) erreichbar sind. Beispiel: a  not b, b  not a, p  a, p  b.

The well-founded semantics for normal programs extends earlier proposals and has advantages over them in that it is applicable to all logic programs compared to other methods a larger part of the Herbrand base tends to be classified as either true or false truth values are assigned in a reasonably predictable and intuitively satisfying way.

Vergleiche mit Fittings Modell und mit Stable Models
ausgeblendet Vergleiche mit Fittings Modell und mit Stable Models

Die Transformation NP(I)
Definition NP(I) wird definiert als die Transformation, die für eine dreiwertige Interpretation I die Menge der Atome p liefert, für die gilt, dass jede Klausel in der Herbrand-Instanz von P mit p als Kopf der Rumpf in I unwahr ist, d.h. irgendein Unterziel jeder Klausel mit Kopf p ist in I unwahr. Anmerkung: NP ist der Teil von UP, der durch die Bedingung (1) der Definition (von unfundierten Mengen) produziert wird.

Fitting Modell Theorem Eine dreiwertige Interpretation I ist genau dann ein dreiwertiges Modell des vollendeten Programms, wenn I = TP(I)    NP(I). Dies führt zu der Konstruktion eines Fixpunktes für dreiwertige Modelle und dazu, dass das Fitting Modell der kleinste Fixpunkt ist.

Theorem Sei I wie oben definiert, dann gilt:
I und Fitting Modell Theorem Sei I wie oben definiert, dann gilt: I = TP(I )    NP(I ). Folgerung Das Fitting Model ist eine Untermenge von I.

Benutzen die zweiwertige Logik.
Stabile Modelle Stabile Modelle: Reproduzieren sich in der Stabilitätstransformation, einer 3 Stufen Transformation. Werden einzigartige stabile Modelle genannt, wenn ein Programm nur ein stabiles Modell besitzt. Benutzen die zweiwertige Logik. Werden in der totalen oder zweiwertigen Interpretation als Menge von Grundatomen repräsentiert.

Minimales Modelle Ein „minimales“ Modell hat eine minimale Menge von positiven Literalen. (das ist die Übersetzung der früheren Verwendung von Interpretationen und Modellen in die Darstellung hier)

Monotone Transformation
Eine „monotone“ Transformation auf totalen Interpretationen ist eine Transformation, die monoton im Bezug auf positive Literale ist. (das ist die Übersetzung der früheren Verwendung von Interpretationen und Modellen in die Darstellung hier)

Notation für Mengen von positiven und negativen Atomen
Definition Für jede partielle Interpretation I sei Pos(I) die Menge von positiven Literalen in I und Neg(I) die Menge von Atomen, die die negativen Literalen in I repräsentiert. Also, I = Pos(I)    Neg(I).

Stabilitätstransformation
Definition Gegeben seien ein Normal Program P und seine Herbrand-Instanziierung PH sowie eine totale Interpretation I und die zugehörige Stabilitätstransformation S(I) (eine Transformation von totalen Interpretationen zu totalen Interpretationen). Die Stabilitätstransformation S(I) wird in den folgenden 3 Schritten definiert:

Stabilitätstransformation
Definition (Fortsetzung) Definiere: P‘ = T1 (PH, I), wobei T1 die folgende Transformation ist: Jede Regel-Instanz, die ein negatives Unterziel enthält, das mit I unkonsistent ist, wird gelöscht. Der Output dieser Transformation ist die Menge der Regel- Instanzen, die nicht gelöscht wurden.

Stabilitätstransformation
Definition (Fortsetzung) 2. Definiere: P‘‘ = T2(P‘), wobei T2 die Transformation ist, durch die alle negativen Unterziele aus den Regeln aus P‘ gelöscht werden (ein Hornprogramm hinterlassend). Wir nennen P‘‘ die Reduktion von P hinsichtlich I.

Stabilitätstransformation
Definition (Fortsetzung) 3. Da P‘‘ ein Hornprogramm ist, kann sein minimales (zweiwertiges) Modell nach der Standard Van Emden und Kowalski Semantik gebildet werden. In diesem Kontext bedeutet das Minimum, dass die Menge positiver Literalen minimiert wird und daher die Menge der negativen Literalen maximiert wird. Wir definieren S(I) als dieses minimale Modell von P‘‘.

„Schrumpfende“ Transformation
Lemma: Sei M ein totales Modell vom allgemeingültigen Logikprogramm P, dann ist Pos(S(M))  Pos(M).

Eindeutiges stabiles Modell (unique stable model)
Definition: Ein totales Modell M vom allgemeingültigen Logikprogramm P ist stabil, wenn es ein Fixpunkt von S ist (M = S(M)). Wenn das Programm P exakt ein stabiles Modell hat, wird dieses Modell als eindeutiges stabiles Modell von P bezeichnet.

Minimale stabile Modelle
Es ist unmittelbar, dass ein stabiles Modell minimal ist (im Bezug auf die Menge der positiven Literale); aber nicht jedes minimale Modell ist stabil. Beispiel: Sei P {a, b} und {b, a} sind stabile Modelle. Also hat P1 kein einzigartiges stabiles Modell. a  not b, b  not a.

Stabile Modelle und wohl-fundierte Modelle
Stabile Modelle und wohl-fundierte (partielle oder totale) Modelle stehen in folgender Beziehung zueinander: Behauptung: Wohl-fundierte totale Modelle sind einzigartige stabile Modelle. Aus dieser Behauptung folgt, dass das einzigartige stabile Modell direkt generiert werden kann.

Verhältnis zwischen S und UP sowie zwischen S und TP
Lemma: Sei M ein totales Modell eines Programms P, dann ist Neg(S(M)) = UP(M). Lemma: Sei M ein totales Modell eines Programms P, dann ist Pos(S(M))  TP(M).

Stabiles Modell und Fixpunkt von WP
Theorem: Sei M ein totales Modell von P. M ist genau dann stabil, wenn es ein Fixpunkt von WP ist.

Folgerungen Sei I eine totale Interpretation von P. Dann ist I ein Fixpunkt von S genau dann, wenn sie ein Fixpunkt von WP ist. Wenn zu P ein wohl-fundiertes totales Modell existiert, dann ist dieses Modell das einzigartige stabile Modell. (Die Umkehrung dieser Folgerung ist nicht notwendigerweise wahr) Das wohl-fundierte partielle Modell von P ist eine Untermenge von jedem stabilen Modell von P.

Ähnliche Präsentationen