Presentation is loading. Please wait.

Presentation is loading. Please wait.

17 October 2006 Foundations of Logic and Constraint Programming 1 Declarative Semantics ­An overview Algebras (semantics for terms) Interpretations (semantics.

Similar presentations


Presentation on theme: "17 October 2006 Foundations of Logic and Constraint Programming 1 Declarative Semantics ­An overview Algebras (semantics for terms) Interpretations (semantics."— Presentation transcript:

1 17 October 2006 Foundations of Logic and Constraint Programming 1 Declarative Semantics ­An overview Algebras (semantics for terms) Interpretations (semantics for programs) Soundness of SLD-Resolution Completeness of SLD-Resolution Least Herbrand Models Computing least Herbrand Models

2 17 October 2006 Foundations of Logic and Constraint Programming 2 Algebras Informally, an algebra assigns values of constants and functions to elements of a certain domain (for example, the usual algebra for the natural numbers N, assigns to function +(3,1)) the value 4 ). More formally -Given a set of Variables V, and a ranked alphabet F of function symbols, An algebra J for F (or F-algebra or pre-interpretation for F) consists of: 1.domain :  non-empty set D 2.Assignment of a mapping f J : D n  D to every f  F (n) (with n  0) -State σ over D :  mapping σ : V  D -Extension of σ to TU F,V :  σ: TU F,V  D such that for every f  F (n) σ(f(t 1,..., t n )) = f J ( σ(t 1 ),..., σ(t n ))

3 17 October 2006 Foundations of Logic and Constraint Programming 3 Interpretations Informally, an interpretation assigns true or false to predicates over its arguments, which are elements of a domain (or terms pre-interpreted by an algebra). For example,  (+(3,1), 2) is true in the usual interpretation of  /2). More formally -Given a ranked alphabet F of function symbols, and a ranked alphabet  of predicate symbols -An interpretation I for F and  consists of: 1.Algebra J for F (with domain D) 2.Assignment of a relation p I  D  D ...  D to every p   (n) (with n  0) -Note: Given a predicate p with n arguments in D, this definition is equivalent to mapping the predicate into true if the n-tuple is a member of in the relation p I false if the n-tuple is not a member of the relation p I n

4 17 October 2006 Foundations of Logic and Constraint Programming 4 Interpretations Let P add be the” add-program” add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). I 1, I 2, I 3, I 4, I 5 and I 6 are all legitimate (if not all “conventional”) interpretations for the sets F = {0,s/1} and  = {add/3} -I 1 : D I1 = N, 0 I1 = 0, s I1 (n) = n+1 f.e. n  N add I1 = {(m,n,m+n) | m, n  N } Note: This is the usual interpretation where terms are interpreted to numbers and add is “addition” -I 2 : D I2 = N, 0 I2 = 0, s I2 (n) = n+1 f.e. n  N add I2 = {(m,n,m*n) | m, n  N } Note: In this interpretation, “addition is in fact multiplication”. -I 3 : D I3 = HU {s,0}, 0 I3 = 0, s I3 (t) = s(t) f.e. t  HU {s,0}, add I3 = {(s m (0), s n (0), s m+n (0),) | m, n  N } Note: This is the interpretation of addition in the Peano algebra for integers.

5 17 October 2006 Foundations of Logic and Constraint Programming 5 Interpretations Let P add be the” add-program” add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). -I 4 : D I4 = HU {s,0}, 0 I4 = 0, s I4 (t) = s(t) f.e. t  HU {s,0}, add I4 = { } Note: In this interpretation, “Peano numbers cannot be added”. -I 5 : D I5 = HU {s,0}, 0 I5 = 0, s I5 (t) = s(t) f.e. t  HU {s,0}, add I5 = (HU {s,0} ) 3 Note: In this interpretation, “anything goes”, since any triple of terms is in the model. -I 6 : D I6 = {0,1} 0 I6 = 0, s I6 (n) = n f.e. n  { 0,1} add I6 = {(m,n,n) | m, n  { 0,1} Note: in this interpretation for a boolean domain, s is the identity function, and add “selects of the second argument”.

6 17 October 2006 Foundations of Logic and Constraint Programming 6 Logical Truth (1) ­Expression E :  E is an atom, query, clause or resultant ­Given an expression E, an interpretation I and a state σ E true in I under σ, written I |= σ E :  By case analysis on E:  I |= σ p(t 1,..., t n ):  (σ(t 1 ),..., σ(t n ))  p I (atom)  I |= σ A 1,..., A n :  I |= σ A 1,..., I |= σ A n (query)  I |= σ A ← B :  if I |= σ B then I |= σ A(clause)  I |= σ A ← B :  if I |= σ B then I |= σ A(resultant)

7 17 October 2006 Foundations of Logic and Constraint Programming 7 Logical Truth (2) ­Given an expression E, and an interpretation I: Let x 1,..., x k be the variables occurring in E   x 1,  x k  E  :  Universal closure of E (abreviated  E    x 1,  x k  E  :  Existential closure of E (abreviated  E   I |=  E :  if I |= σ E for every state σ  I |=  E :  if I |= σ E for some state σ  When I |=  E we say that I is a model of E; or E is true in I.

8 17 October 2006 Foundations of Logic and Constraint Programming 8 Logical Truth (3) ­Given sets of expressions S and T, and an interpretation I:  I is a model of S (written I |= S ) :  I |= E for every E  S  T is a semantic (or logical) consequence of S, (written S |= T ) :  every model of S is a model of T ­Given a program P, a query Q 0 and a substitution    | var(Q 0 ) is a correct answer substitution of Q 0 :  P |= Q 0   Q 0  is a correct instance of Q 0 :  P |= Q 0 

9 17 October 2006 Foundations of Logic and Constraint Programming 9 Models (Example) Let P add be the” add-program” add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). -I 1 : D I1 = N, 0 I1 = 0, s I1 (n) = n+1 ; add I1 = {(m,n,m+n) | m, n  N } -I 1 |= P add as I 1 |= c for every clause c of P add and state σ : V  N. In fact (i) (σ(0), σ(x), σ(x))  add I1 ; and (ii) if (σ(M), σ(N), σ(K))  add I1 then (σ(M)+1, σ(N), σ(K)+1)  add I1 -I 2 : D I2 = N, 0 I2 = 0, s I2 (n) = n+1 ; add I2 = {(m,n,m*n) | m, n  N } -I 2 |  P add. To check this let σ(M) = 1. Then I 2 |  σ add(0,M,M) since (σ(0), σ(M), σ(M)) = (0,1,1)  add I2 (in other words, 0*1  1) -I 3 : D I3 = HU {s,0}, 0 I3 = 0, s I3 (t)=s(t) ; add I3 ={(s m (0),s n (0),s m+n (0),)|m,n  N } -I 3 |= P add like for I 1. Since the domain D is the Herbrand Universe of terms, this interpretation is a (least) Herbrand Model.

10 17 October 2006 Foundations of Logic and Constraint Programming 10 Models (Example) add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). -I 4 : D I4 = HU {s,0}, 0 I4 = 0, s I4 (t) = s(t) f.e. t  HU {s,0}, add I4 = { } -I 4 |  P add. To check this let σ(M) = 1. Then I 4 |  σ add(0,M,M) since (σ(0), σ(M), σ(M)) = (0,1,1)  add I4 = { }. -I 5 : D I5 = HU {s,0}, 0 I5 = 0, s I5 (t) = s(t) f.e. t  HU {s,0}, add I5 = (HU {s,0} ) 3 -I 5 |  P add as any triple, (σ(0), ỤỴ (M), σ(M)) or (s(σ(M)), σ(N)), s(σ(K)), belongs to add I5. Since D I5 is the Herbrand Universe, I 5 is a Herbrand Model. However, it is not a least model, since add I5 includes more triples than strictly necessary (add I2  add I5 ) -I6 : D I6 = {0,1} 0 I6 = 0, s I6 (n) = n; add I6 = {(m,n,n) | m, n  { 0,1} -I 6 |= P add. Like for I 1. (i) (σ(0), σ(x), σ(x))  add I6 ; and (ii) if (σ(M), σ(N), σ(K))  add I6 then (σ(M), σ(N), σ(K))  add I6

11 17 October 2006 Foundations of Logic and Constraint Programming 11 Semantic Consequences (Example) add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). -P add |= add(0,x,x) -For every interpretation I, if I |= P add then I |= P add since add(0,x,x)  P add. -P add |= add(s(0),x,s(x)) -For every interpretation I, if I |= P add then (i) I |= add(0,x,x) ; and (ii) I |= add(s(0),x,s(x)) ← add(0,x,x). -Hence, I |= add(s(0),x,s(x)). -P add |  add(x,0,x) -Consider interpretation I 6, (that selects the second element). Although I 6 |= P add as seen before, it is I 6 |  add(x,0,x) for state σ(x) = 1, as (σ(x),σ(0),σ(x)) = (1,0,1)  add I6 

12 17 October 2006 Foundations of Logic and Constraint Programming 12 Towards Soundness of SLD-Resolution (1) -Lemma 4.3 (i) -Let Q   c Q’  be an SLD-derivation step and Q  ← Q’ the resultant associated with it. Then c |= Q  ← Q’ Proof. -Let Q = A, B, C with selected atom B. Let H ← B be the input clause c, and Q’ = (A,B,C) . Then c |= H ← B (variant of c) impliesc |= H  ← B  (instance) impliesc |= B  ← B  (  unifies B and H) impliesc |= (A,B,C)  ← (A,B,C)  (unchanged “context” : A, C)

13 17 October 2006 Foundations of Logic and Constraint Programming 13 Towards Soundness of SLD-Resolution (2) Lemma 4.3 (ii) Let  be an SLD-derivation of P  {Q 0 }. For i  let R i be the resultant of level i of . Then P |= R i Proof. Let  = Q 0   1 Q 1... Q n   n+1  Q n+1. The proof is by induction on n. -i = 0: R 0 = Q 0 ← Q 0 = “true”. Hence, P |= R 0. -i = 1: R 1 = Q 0  1 ← Q 1. By Lemma 4.3(i) it is P |= R 1. -i ~> i+1: Assume that P |= R i and Q i  i+1  ← Q i+1 -Let Q i  i+1  ← Q i+1 and R i = Q 0  1   2   i  ← Q i ; Then - R i+1 = R i  i+1  = Q 0  1   2   i+1 ← Q i+1  -Hence, by Lemma 4.3 (i) and the induction hipothesis, it is P |= R i+1.

14 17 October 2006 Foundations of Logic and Constraint Programming 14 Soundness of SLD-Resolution Theorem 4.4 If there exists a successful SLD-derivation of P  {Q 0 } with CAS (computed answer substitution) , then P |= Q 0  Proof. Let  = Q 0   1 Q 1... Q n-1   n  □ be a successful SLD-derivation. Lemma 4.3(ii) applied to the resultant of level n of  implies P |= Q 0   1    n and Q 0   1    n = Q 0   1    n | Var(Q 0 ) ) = Q 0  -This theorem thus guarantees that the answers computed by a successful derivation are logical consequences of the program. -The converse result, is the object of the completeness theorem.

15 17 October 2006 Foundations of Logic and Constraint Programming 15 Intuitive Meaning of Queries -To prepare the addressing of completeness, the next corollary simply states that if an SLD-derivation exists, then the program implies the existential closure of the query (some instance of the query). Corollary 4.5 If there exists a successful SLD-derivation of P  {Q 0 } then P |=  Q 0. Proof. Theorem 4.4. implies P |= Q 0  for some CAS . Now, P |= Q 0 . -implies for every interpretation I: I |= P, then I |= Q 0  -implies for every interpretation I: I |= P, then I |=  (Q 0  ) -implies for every interpretation I: I |= P, then I |=  Q 0 -implies P |=  Q 0

16 17 October 2006 Foundations of Logic and Constraint Programming 16 Towards Completeness of SLD-Resolution -To assess completeness of SLD-Resolution it is convenient to characterise the set of sintactically derivable queries. For this purpose the concepts of term models and implication trees are defined. -The main idea is to interpret the set of functional symbols into “themselves”, rather, avoinding their mapping into a different domain. For example, instead of a mapping such as -“0”  0,”s(0)”  1, “s(s(0))”  2,... a term interpretation/model will adopt -“0”  0, “s(0)”  s(0), “s(s(0))”  s(s(0)),... -Formally, for an expression E, and a set of expressions S -inst(E) :  set of all instances of E -inst(S) :  set of all instances of all elements E  S -ground(E) :  set of all ground instances of E -ground(S) :  set of all ground instances of all elements E  S

17 17 October 2006 Foundations of Logic and Constraint Programming 17 Term Models For a set of variables V, function symbols F and predicate symbols  -The term algebra J for F is defined as follows: 1.Domain D = TU F,V 2.Mapping f J : (TU F,V ) n  TU F,V assigned to every f  F (n) with f J (t 1,..., t n ) :  f(t 1,..., t n ) A term interpretation I for F and  consists of: 1. A term algebra for F 2. I  TB ,F,V (set of atoms that are true; equivalently it can be seen as an assignment of a relation p I  (TU F,V ) n to every p   (n) ). A term model I of a set S of expressions :  a term interpretation I that is a model of S

18 17 October 2006 Foundations of Logic and Constraint Programming 18 Herbrand Models The Herbrand algebra J for F is defined for ground terms as follows: 1.Domain D = HU F 2.Mapping f J : (HU F ) n  HU F assigned to every f  F (n) with f J (t 1,..., t n ) :  f(t 1,..., t n ) A Herbrand interpretation I for F and  consists of: 1.Herbrand algebra for F 2. I  HB ,F (set of ground atoms that are true; equivalently it can be seen as an assignment of a relation p I  (HU F ) n to every p   (n) ). A Herbrand model I of a set S of expressions :  a Herbrand interpretation I that is a model of S A least Herbrand model I of a set S of expressions :  I is a Herbrand model of S and I  I’ for all Herbrand Models I’ of S

19 17 October 2006 Foundations of Logic and Constraint Programming 19 Implication Trees An implication tree T with respect to program P :  -T is a finite tree -The nodes of T are atoms -If A is a node with direct descendants B 1,..., B n then there must be some A ← B 1,..., B n  inst(P). -If A is a leaf, then A ←  inst(P). -B is a ground implication tree wrt. Program P :  B is an implication tree wrt P and all nodes are ground atoms.

20 17 October 2006 Foundations of Logic and Constraint Programming 20 Implication Trees (Example) Let P add be the” add-program”, add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). and n  N, V be a set of variables and t  TU {s,0},V. Let T = Then -T is an implication tree wrt. P add. -If additionally t  HU {s,0}, then T is a ground implication tree. add(s n (0), t, s n (t)) add(s n-1 (0), t, s n-1 (t)) add(s(0), t, s(t)) add(0, t, t)

21 17 October 2006 Foundations of Logic and Constraint Programming 21 Implication Trees (Example) Let P mult be the” multiply-program”, mult(0,X,0). mult(s(M),N, K):- mult(M,N,Z), add(Z,N,K). and n  N, V be a set of variables and t  TU {s,0},V.. Let T = Then -T is an implication tree wrt. P add. -T is also a ground implication tree. mult(s(s(0)),s(0),s(s(0))) mult(s(0),s(0),s(0)) add(s(0),s(0),s(s(0))) mult(0,s(0),0) add(0,s(0),s(0)) add(0,s(0),s(0))

22 17 October 2006 Foundations of Logic and Constraint Programming 22 Implication Trees and Term Models Lemma 4.7 Consider term interpretation I, atom A and program P I |= A iff inst (A)  I I |= A iff for every A ← B 1,..., B n  inst(P), {B 1,..., B n }  I implies A  I. Lemma 4.12 The term interpretation C (P) :  {A | A is the root of some implication tree wrt. P} is a model of P.

23 17 October 2006 Foundations of Logic and Constraint Programming 23 Ground Implication Trees and Herbrand Models Lemma 4.26 Consider Herbrand interpretation I, atom A and program P I |= A iff ground (A)  I I |= A iff for every A ← B 1,..., B n  ground(P), {B 1,..., B n }  I implies A  I. Lemma 4.28 The Herbrand interpretation M (P) :  {A | A is the root of some ground implication tree wrt. P} is a model of P.

24 17 October 2006 Foundations of Logic and Constraint Programming 24 Implication Trees (Example) Let P add be the” add-program” below and V a set of variables. add(0,M,M). add(s(M),N,s(K)):- add(M,N,K). The term interpretation C (P) = {add(s n (0), t, s n (t)) | n  N, t  TU {s,0},V } = {add(s n (0), s m (v), s m+n (v)) | n,m  N, v  V  {0} } is a model of P add. The Herbrand interpretation M (P) = {add(s n (0), t, s n (t)) | n  N, t  HU {s,0} } = {add(s n (0), s m (0), s m+n (0)) | n,m  N} is a model of P add.

25 17 October 2006 Foundations of Logic and Constraint Programming 25 Answer Substitutions Let P add be the” add-program” below and the query Q = add(s(0), u, s(u)) add(0,M1,M1). add(s(M2),N,s(K)):- add(M2,N,K).  {u / s(s(v))} is a correct answer substitution of Q, since P add |= Q  add(s(0), s(s(V)), s(s(s(V)))). -However, there is no SLD-derivation leading to Q . In fact, query Q leads to the following SLD-derivation of P add  {Q} add(s(0), u, s(u))   1 add(0, u, u )   2 □ where  1  {M2/0, N/u, K/u} and  2  {u/M1}. Hence,  =  1  2  | {u} = {u/M1} is the Computed Answer Substitution (CAS) of Q. -Hence, Q  is more general than  Q  since  =  {M1/s(s(v) ), and  CAS are more general than specific correct answer substitutions. Nevertheless, are there always CAS, possibly more general, for every correct answer? -The completeness result for SLD-resolution ensures this.

26 17 October 2006 Foundations of Logic and Constraint Programming 26 Completeness of SLD-Resolution (Implication Trees) First, a convenient lemma is obtained that relates SLD-resolution with implication trees. ­Query Q is n-deep  : every atom in Q is the root of an implication tree, and n is the total number of nodes in these trees. Lemma 4.15 Suppose Q  is n-deep for some n  0. Then for every selection rule R there exists a successful SLD-derivation of P  {Q} with CAS  such that Q  is more general than Q . Proof. By induction on n (see [Apt97], pg 84)

27 17 October 2006 Foundations of Logic and Constraint Programming 27 Completeness of SLD-Resolution (1) Theorem 4.13 Suppose  is a correct answer substitution of Q. Then for every selection rule R there exists a successful SLD-derivation of P  {Q} with CAS  such that Q  is more general than Q . Proof. Let Q = A 1,..., A m. Then  correct answer substitution of A 1,..., A m  P |= A 1 ,..., A m   for every interpretation I: if I |= P then I |= A 1 ,..., A m   C (P) |= A 1 ,..., A m  (since C (P) |= P, by Lemma 4.12)  inst(A i  C (P) for every i  1,..., m  A i  C (P) for every i  1,..., m  A 1 ,..., A m  is n-deep for some n  0 (by definition of C (P) ).  claim (by Lemma 4.15)

28 17 October 2006 Foundations of Logic and Constraint Programming 28 Completeness of SLD-Resolution (2) The completeness of SLD-resolution is often regarded as the guarantee of obtaining a successful SLD-derivation for any query whose existential closure is implied by the program. Corollary 4.16 Suppose P |=  Q. Then there exists a successful SLD-derivation of P  {Q}. Proof. P |=  Q  P |= Q  for some substitution   is a correct answer substitution of Q  Claim (by Theorem 4.13) -However, it is interesting to characterise, beforehand, the set of queries whose existential closure is implied by the program. This is the goal of the declarative semantics for logic programs.

29 17 October 2006 Foundations of Logic and Constraint Programming 29 Least Herbrand Models This set of queries is in fact the least Herbrand model of P. First we define it. Theorem 4.29 M (P) † is the least Herbrand model of P. Proof. Let I H be some Herbrand model of P and let A  M (P). We prove A  I H by induction on the number i of nodes in the ground implication tree wrt. P with root A. Then M (P)  I H. i = 1: A is a leaf  A ←  ground(P)  I H |= A (since I H |= P)  A  I H i ~> i+1: A has direct descendants B 1,..., B n (roots of subtrees)  A ← B 1,..., B n  ground(P) and B 1,..., B n  I (Herbrand Interpretation)  A ← B 1,..., B n  ground(P) and I H |= B 1,..., B n  I H |= A (since I H |= P)  A  I H †( M (P) as defined in slide 23)

30 17 October 2006 Foundations of Logic and Constraint Programming 30 Ground Equivalence Now we characterise the set of ground atoms implied by a program. Theorem 4.30 For every ground atom A : P |= A iff M (P) |= A Proof.  : P |= A and, from Lemma 4.28, M(P) |= P. Then it must be M(P) |= A.  : Show that for all A  M (P), every interpretation I: I |= P implies I |= A. Let us consider Herbrand interpretation I H = {A | A ground atom and I |= A}. Then, I |= P  I |= A ← B 1,..., B n for all A ← B 1,..., B n  ground(P)  if I |= B 1,..., B n then I |= A for all A ← B 1,..., B n  ground(P)  if B 1  I H,..., B n  I H, then A  I H, for all A ← B 1,..., B n  ground(P)  I H |= P (by Lemma 4.26; thus I H is a Herbrand model)  For all A  M (P), it is A  I H, (I H |= A) as M (P) is the least Herbrand Model.  Hence, I |= A (by definition of I H, A  I H implies A  I H ).

31 17 October 2006 Foundations of Logic and Constraint Programming 31 Complete Partial Orderings ­Once proven that the least Herbrand models are the set of ground atoms implied by logic programs, it is interesting to specify alternative forms of characterising these least Herbrand models. Let (A,  ) be a partial ordering (i.e. reflexive, antisimmetric and transitive) a is the least element of X  A  : a  X, a  x for all x  X a is the least upper bound of X  A (notation a = X )  : a  A, x  a for all x  X and a is the least such element of A (A,  ) is a complete partial ordering (cpo) contains a least element  : A contains a least element For every increasing sequence a o  a 1  a 2... of elements of A, the set X = { a 0, a 1, a 2,...} has a least upper bound.

32 17 October 2006 Foundations of Logic and Constraint Programming 32 Some Properties of Operators Let (A,  ) be a complete partial ordering  Operator T: A  A is monotonic  : I  J implies T(I)  T(J) Operator T: A  A is finitary  : for every infinite sequence I 0  I 1 ...  ∞ n=0 T (I n ) exists and T (  ∞ n=0 I n )  ∞ n=0 T(I n ) Operator T: A  A is continuous  : T is monotonic and finitary I is a pre-fixpoint of T  : T(I)  I I is a fixpoint of T  : T(I) = I

33 17 October 2006 Foundations of Logic and Constraint Programming 33 Iterating of Operators Let (A,  ) be a CPO, T: A  A and I  A T↑0(I)  : I T↑(n+1)(I)  : T(T↑n(I) ) T↑  (I)  :  ∞ n=0 (T↑n(I) ) T↑   : T↑  (  ) (for  = 0, 1, 2,...,  By the definition of a CPO: If the sequence T↑0(I), T↑1(I), T↑2(I),... is increasing, then T↑  (I) exists Theorem 4.22 If T is a continuous operator on a CPO, then T↑  exists and is the least pre- fixpoint of T and the least fixpoint of T.

34 17 October 2006 Foundations of Logic and Constraint Programming 34 Consequence Operator T P Consider CPO ({I | I Herbrand Interpretation},  Let P be a program and I a Herbrand interpretation. Then T P (I)  : {A | A ← B 1,..., B n  ground(P), B 1,..., B n  I} Lemma 4.33 (i) T P is finitary (i) T P is monotonic In “practice”, the Tp operator is useful to obtain (least) Herbrand Models with a bottom-up procedure.

35 17 October 2006 Foundations of Logic and Constraint Programming 35 Consequence Operator T P : Example (1) T P ↑0 =  T P ↑1 = {sunny, summer} T P ↑2 = {sunny, summer, warm} T P ↑3 = {sunny, summer, warm, happy}... T P ↑  = {sunny, summer, warm, happy} is the fixpoint happy ← summer, warm warm ← sunny sunny ← summer ←

36 17 October 2006 Foundations of Logic and Constraint Programming 36 Consequence Operator T P : Example (2) ­Notice that if I is some “incomplete model” of P, then the consequence operator adds new atoms to I. For example, let I = {summer, sunny} then J = T P (I) = {summer, sunny, warm} and T P (I)  happy ← summer, warm warm ← sunny sunny ← summer ←

37 17 October 2006 Foundations of Logic and Constraint Programming 37 Consequence Operator T P : Example (3) T P ↑0 =  T P ↑1 = {num(0)} % 0 is the 1 st number T P ↑2 = {num(s k (0))} 0  k < 2% 0, 1 are the first 2 numbers... where s 0 (0) = 0 T P ↑i = {num(s k (0))} 0  k < i% 0,..., i -1 are the first i numbers... TP↑  (I)= {num(s k (0))} 0  k% fixpoint num(0) ← num(s(x)) ← num(x).

38 17 October 2006 Foundations of Logic and Constraint Programming 38 Consequence Operator T P : Example (4) T P ↑0=  T P ↑1={num(0} T P ↑2={num(0}, num(s(0)),sum(0,0,0)} T P ↑3={num(s k (0)),sum(s i (0),s j (0),s i+j (0))} 0  k < 2, 0  i < 1, 0  j < i... T P ↑i={num(s k (0)),sum(s i (0),s j (0),s i+j (0))} 0  k < i, 0  i < i-1, 0  j< i... T P ↑w={num(s k (0)),sum(s i (0),s j (0),s i+j (0))} 0  k, 0  i, 0  j fixpoint num(0) ← num(s(x)) ← num(x). sum(0,z,z) ← num(z) sum(s(x),y,s(z)) ← sum(x,y,z).

39 17 October 2006 Foundations of Logic and Constraint Programming 39 T P characterization Lemma 4.32 A Herbrand Interpretation I is a model of P iff T P (I)  I Proof. I |= P iff for every A ← B 1,..., B n  ground(P) : {B 1,..., B n }  I implies A  I (by Lemma 4.26) iff for every ground atom A : A  T P (I) implies A  I iff T P (I)  I

40 17 October 2006 Foundations of Logic and Constraint Programming 40 Characterization Theorem Theorem 4.31 The following sets are equal M (P)(i) = least Herbrand model of P(ii) = least pre-fixpoint of P(iii) = least fixpoint of P(iv) = T P ↑  (v) = {A | A is a ground atom, P |= A}(vi)

41 17 October 2006 Foundations of Logic and Constraint Programming 41 Success Sets The success set of a program P  : {A | A is a ground atom,  sucessful SLD-derivation of P  {A} } Theorem 4.37 For a ground atom A, the following are equivalent   M (P) |= A(i) P |= A(ii)  Every SLD-tree for P  {A} is successful(iii)  A is in the success set of P(iv)


Download ppt "17 October 2006 Foundations of Logic and Constraint Programming 1 Declarative Semantics ­An overview Algebras (semantics for terms) Interpretations (semantics."

Similar presentations


Ads by Google