isweb - information systems & semantic web steffen staab [email protected] foundations of...
TRANSCRIPT
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming1 of 48
<is web>
Three-Valued Models of Program Completion
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming2 of 48
<is web>
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 .
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming3 of 48
<is web>
Example: Problems with Completion in 2-Valued Logic
p p, q.
Completion:p(pq)q.
Program has no 2-valued model.
p p, q.p p.
Completion:p(pq)p.q.
Program has 2-valued model I={q,p}
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming4 of 48
<is web>
Truth Tables for 3-Valued Logic (Extensions Only!)
11
0
ABBA
1
00
A BBA
10
1
1
11
0
ABBA
1
1
0
A BBA
AA
Attention::AB BA
no longer holds!
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming5 of 48
<is web>
Example: Completion and 3-Valued Logic
p p, q.
Completion:p(pq)q.
Program has 3-valued model for p=I={q}
p p, q.p p.
Completion:p(pq)p.q.
Program has 3-valued model forp= I={q} I={q,p}
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming6 of 48
<is web>
Uniqueness
p p, q.q rq sr rs s
Completion:p(pq)qrsrrss
2-Valued Models{p,q,r,s}{p,q,r,s}{p,q,r,s}
3-Valued Model{}
Not comparable
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming7 of 48
<is web>
Undefined
DefinitionLiteral 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).
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming8 of 48
<is web>
Stratified Programs
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming9 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming10 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming11 of 48
<is web>
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, …}
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming12 of 48
<is web>
Perfect Model
Definition Let P be a normal program and I a model. I is a perfect model for a given level of BP, iffor 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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming13 of 48
<is web>
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, …}
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming14 of 48
<is web>
Well-Founded Semantics
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming15 of 48
<is web>
Theorem:If a program P is locally stratified, then is has a well-founded model, which is identical to the perfect model.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming16 of 48
<is web>
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
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming17 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming18 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming19 of 48
<is web>
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
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming20 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming21 of 48
<is web>Unfounded Sets
DefinitionLet 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)
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming22 of 48
<is web>
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).
the atoms {p(d), q(a), q(b), q(c)} are an unfounded set wrt I=Ø.
For the instantiated normal program P:
(2):
None of the heads can be derived first.
There exists no definition for q(c). Thus (1) is satisfied.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming23 of 48
<is web>
Example
the atoms {p(a), p(b)} are no unfounded set wrt I=Ø!
Neither (1) nor (2) are satisfied.
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).
For the instantiated normal program P:
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming24 of 48
<is web>
Notation: Let S be a set of literals. Then we write S for {p : pS}
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming25 of 48
<is web>
Union of Unfounded Sets
DefinitionThe greatest unfounded set (of P) wrt I, denoted UP(I), is the union of all sets that are unfounded wrt I.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming27 of 48
<is web>
Well-Founded Partial Models
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming28 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming29 of 48
<is web>
Transformations
DefinitionLet P be a normal program.Transformations TP, UP and WP are defined as follows:
– pTP(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).
LemmaTP, UP and WP are monotonic transformations.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming30 of 48
<is web>I and I
DefinitionThe 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:(1) For limit ordinal ,
Note that 0 is a limit ordinal, and I0 = .(2) For a successor ordinal = + 1,
(3) Finally, define
II
II PW1
II
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming31 of 48
<is web>
Stufe
DefinitionFor any literal p in I, we define the stage of p to be the least ordinal such that p I.
LemmaI is a monotonic sequence of partial interpretations.
Proof SketchInduction over
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming32 of 48
<is web>
Closure Ordinal
DefinitionThe closure ordinal for the sequence I is the least ordinal such that: I = I.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming33 of 48
<is web>
Well-Founded Semantics
DefinitionThe 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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming34 of 48
<is web>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)} …
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming35 of 48
<is web>
Well-Founded Semantics
LemmaLet I be defined as above. Then I does not weakly falsify any instantiated clause R of P.
Proof SketchThe 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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming36 of 48
<is web>
Well-Founded (Partial) Model
TheoremFor every countable ordinal , I in the sequence described above is a partial model of P.
ProofUsing the first and the previous lemma.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming37 of 48
<is web>
Well-Founded (Partial) Model
DefinitionSuppose that for each pBP,
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming38 of 48
<is web>
Minimal Model
TheoremEvery 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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming39 of 48
<is web>
Theorem:If a program P is locally stratified, then is has a well-founded model, which is identical to the perfect model.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming40 of 48
<is web>Example: Suppose all Valid Moves From one
Position to an other are in the EDB
F
T
F F F
T
F
T
F
T
T
F
F F
(a) (b) (c)
winning(X) move(X,Y), not winning(Y).
player 1 moves
player 2 moves
player 1loses
player 1loses player 1 zieht
player 2loses
player 2 moves
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming41 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming42 of 48
<is web>
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).
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming43 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming44 of 48
<is web>
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).
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming45 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming46 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming47 of 48
<is web>
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.
ISWeb - Information Systems & Semantic Web
Steffen [email protected]
Foundations of Logic Programming49 of 48
<is web>
Advantages of Well-Founded Semantics
The well-founded semantics for normal programs extends earlier proposals and has advantages over them in that(1)it is applicable to all logic programs(2)compared to other methods a larger
part of the Herbrand base tends to be classified as either true or false
(3)truth values are assigned in a reasonably predictable and intuitively satisfying way.