Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slide 1 A Class of Prolog Programs with Non-linear Outputs Inferable from Positive Data M.R.K. Krishna Rao King Fahd University of Petroleum and Minerals.

Similar presentations


Presentation on theme: "Slide 1 A Class of Prolog Programs with Non-linear Outputs Inferable from Positive Data M.R.K. Krishna Rao King Fahd University of Petroleum and Minerals."— Presentation transcript:

1 Slide 1 A Class of Prolog Programs with Non-linear Outputs Inferable from Positive Data M.R.K. Krishna Rao King Fahd University of Petroleum and Minerals Dhahran 31261, Saudi Arabia Presented by Eric Martin University of New South Wales Sydney, Australia

2 Slide 2 Outline l Learning from positive data l History and Motivation l Recursion bounded programs l Decidability of Recursion bounded programs l Infererability of Recursion bounded programs from positive data l Comparison and conclusions

3 Slide 3 Learnability from positive data l Gold (1967) proved that even simple classes of concepts like the class of regular languages cannot be inferred from positive examples alone. l Why study it? In practice, positive examples are easier to obtain than negative examples. l Starting with Angluin (1980), many results on learnability from positive data are published.

4 Slide 4 Learnability from positive data l Shinohara (1991): the class of linear Prolog programs learniable from positive examples alone. Size of terms in the body are bounded by the size of terms in the head for all instantiations. Hence, do not allow local variables. Serious limitation!

5 Slide 5 Learnability from positive data l Arimura and Shinohara (1994): the class of linearly covering programs inferable from positive data. Uses moding annotations on predicates Allows local variables But, views local variables as point-to-point communication channels Hence many natural programs are beyond this class. The class of linearly covering programs does not include all linear programs – a technical limitation.

6 Slide 6 Learnability from positive data l Krishna Rao (1996): the class of linearly moded programs inferable from positive data. Uses moding annotations, linear inequalities on predicates, and views local variables as broadcasting communication channels The class of linearly moded programs include all linear and linearly covering programs. Many natural programs are within this class, and automatic verification whether a given program is linear- moded or not is straightforward. But does not allow nonlinear input-output relations – a technical limitation.

7 Slide 7 Learnability from positive data l Martin and Sharma (1999): the class of safe programs inferable from positive data. Allows local variables and nonlinear input-output relations Uses bound kits Automatic verification whether a given program is safe or not clear For a technical reason, a natural program for nth- power is not a member of this class.

8 Slide 8 Motivation l In this paper, we present a class of programs inferable from positive data Can handle non-linear input-output relationships Automatic verification whether a given program is in this class or not is straightforward Includes all the (terminating) linearly-moded programs.

9 Slide 9 Preliminaries A concept defining framework is a triple (U, E,  ) of a universe U of objects, a set E of expressions and a semantic mapping . A class of concepts C = {  1,  2,… } is an indexed family of recursive concepts if there exists an algorithm that decides whether w   i for any object w and natural number i. A semantic mapping  is monotonic if R  R' implies  (R)   (R'). A formal system R is reduced w.r.t. S  U if S   (R) and for any proper subset R' of R,  (R')  S.

10 Slide 10 Preliminaries A concept defining framework C = (U, E,  ) has bounded finite thickness if is monotonic and for any finite set S  U and any m  0, the set {  (R) | R is reduced w.r.t.S and |R|  m} is finite. l Theorem from Shinohara (1991): If a concept defining framework C = (U, E,  ) has bounded finite thickness, then the class C m = {  (R) | R  E and |R|  m} of concepts is inferable from positive data for every m  1.

11 Slide 11 Recursion-bounded programs l The notion of recursion-bounded programs is based on moding information, parametric size and linear inequalities. Moding information: for each predicate, some of its positions are designated ‘ input ’, while the others are designated ‘ output ’ positions. l We denote by p(s; t), an atom with s as the sequence of input terms, and with t as the sequence of output terms.

12 Slide 12 Recursion-bounded programs l The parametric size [t] of a term t is defined as if t is a variable x, then [t] is a linear expression x, if t is a constant, then [t] is zero, if t=f(t 1, …, t n ), then [t] is a linear expression 1 + [t 1 ] + … + [t n ]. l The parametric size of a sequence t 1, …, t n of terms is the sum [t 1 ] + … + [t n ]. l Example: The parametric sizes of terms a, [ ], [X], [a], [a,b,c], [ [ ], [ ], [ ] ], [ [a], [b], [c] ] are 0, 0, X+1, 1, 3, 3, 6 respectively.

13 Slide 13 Recursion-bounded programs … l Let P be a moded program and, I and O be mappings such that I(p) is a subset of the input positions and O(p) is a subset of the output positions for each predicate p in P. l For an atom A = p(s; t), we denote the linear inequality by LI(A, I, O).

14 Slide 14 Recursion-bounded programs… A moded program P is recursion bounded w.r.t. I and O if each clause p 0 (s 0 ; t 0 )  p 1 (s 1 ; t 1 ), …, p k (s k ; t k ) in it satisfies the following 1.LI(A 1, I, O), …, LI(A j-1, I, O) together imply [Iterms(A 0, I)] > [Iterms(A j, I)] for each j such that p j is in mutual recursion with p 0 (or p j =p 0 ), 2.LI(A 1, I, O), …, LI(A k, I, O) together imply LI(A 0, I, O), and A moded program P is recursion bounded if it is recursion bounded w.r.t. some I and O.

15 Slide 15 Recursion-bounded programs - reverse Example: Consider the following reverse program with moding info app(in,in, out) and rev(in, out). app([ ], Ys, Ys)  app([X|Xs], Ys, [X|Zs])  app(Xs,Ys, Zs) rev([ ], [ ])  rev([X|Xs], Zs)  rev(Xs, Ys), app(Ys, [X], Zs) The first clause satisfies the requirements of the above definition as LI( app([ ], Ys, Ys), I, O) is Ys  Ys, which obviously holds. l The first clause is recursion bounded.

16 Slide 16 Recursion-bounded programs - reverse… Now consider the second clause app([X|Xs], Ys, [X|Zs])  app(Xs,Ys, Zs) LI( app(Xs, Ys, Zs), I, O) is Xs + Ys  Zs(1) LI( app([X|Xs], Ys, [X|Zs]), I, O) is 1+X+ Xs + Ys  1+X+ Zs(2) l It’s easy to see that (1) imples (2) satisfying the requirement 2 of the above definition. l The requirement 1 of the above definition obviously holds as 1 + X + Xs + Ys > Xs + Ys. l Therefore, the second clause is recursion bounded.

17 Slide 17 Recursion-bounded programs - reverse… Now consider the fourth clause rev([X|Xs], Zs)  rev(Xs, Ys), app(Ys, [X], Zs) LI( rev(Xs, Ys), I, O) is Xs  Ys(3) LI( app(Ys, [X], Zs), I, O) is Ys + 1 + X  Zs(4) For the head, LI( rev([X|Xs], Zs), I, O) is 1 + X + Xs  Zs(5) l It’s easy to see that (3) and (4) together imply (5) satisfying the requirement 2 of the above definition.

18 Slide 18 Recursion-bounded programs - reverse… The fourth clause rev([X|Xs], Zs)  rev(Xs, Ys), app(Ys, [X], Zs) satisfies the requirement 1 of the above definition on the recursive atom rev(Xs, Ys) as 1 + X + Xs > Xs. l Therefore, the fourth clause is recursion bounded. l The third clause is recursion bounded as well. The reverse program is recursion bounded.

19 Slide 19 Recursion-bounded programs - quicksort Example: Consider the following quick-sort program with moding info app(in,in, out), part(in, in, out, out) and qs(in, out). app([ ], Ys, Ys)  app([X|Xs], Ys, [X|Zs])  app(Xs,Ys, Zs) part([ ],H,[ ],[ ])  part([X|Xs],H,[X|Ls],Bs)  H  X, part(Xs,H,Ls,Bs) part([X|Xs],H,Ls,[X|Bs])  X > H, part(Xs,H,Ls,Bs) qs([ ], [ ])  qs([H|L],S)  part(L,H,A,B), qs(A,A1), qs(B,B1), app(A1,[H|B1],S)

20 Slide 20 Recursion-bounded programs - quicksort We prove that quick-sort program is recursion bounded w.r.t. I and O such that I(p) = in(p) and O(p) = out(p) for each predicate except that I( part ) = {1}. l We consider the last clause, other clauses are easier to handle. qs([H|L],S)  part(L,H,A,B), qs(A,A1), qs(B,B1), app(A1,[H|B1],S) It may be noted that quick-sort program is not recursion bounded w.r.t. I and O if I( part ) = in( part ).

21 Slide 21 Recursion-bounded programs - quicksort l We consider the last clause, other clauses are easier to handle. qs([H|L],S)  part(L,H,A,B), qs(A,A1), qs(B,B1), app(A1,[H|B1],S) LI( part(L,H,A,B), I, O) is L  A + B(1) LI( qs(A,A1) }, I, O) is A  A1(2) LI( qs(B,B1) }, I, O) is B  B1(3) LI( app(A1,[H|B1],S), I, O) is A1 +1 +H +B1  S (4) For the head, LI( qs([H|L],S) ), I, O) is 1 + H + L  S(5) l It is easy to see that inequalities (1) to (4) together imply (5) satisfying the requirement 2 of the above definition. For the recursive atoms qs(A,A1) and qs(B,B1), the requirement 1 is implied by the inequality (1).

22 Slide 22 Recursion-bounded programs l The above two examples illustrate the main characteristics of recursion bounded programs. l The linear inequalities capture the semantics of the programs (they capture model information used in acceptable programs). l The size of output terms in positions O is bounded by the size of input terms in positions I.

23 Slide 23 Recursion-bounded programs l The above two programs have linear relationship between inputs and outputs. l However, the class of recursion bounded programs is rich enough to include predicates with non linear relationships (as multiplication in the next example). l The trick is to choose appropriate I and O!

24 Slide 24 Recursion-bounded programs - multiply Example: Consider the following multiplication program with moding info add(in,in, out) and mult(in, in, out). add(0, Y, Y)  add(s(X), Y, s(Z))  add(X, Y, Z) mult(0, Y, 0)  mult(s(X), Y, Z)  mult(X, Y, Z1), add(Y, Z1, Z) This program is recursion bounded w.r.t. I and O such that I(add) = in(add), O(add) = out(add), I(mult) = in(mult) and O(mult) = .

25 Slide 25 Recursion-bounded programs - multiply l We consider the last clause, other clauses are easier to handle. mult(s(X), Y, Z)  mult(X, Y, Z1), add(Y, Z1, Z) LI( mult(X, Y, Z1 ), I, O) is X+Y  0(1) LI( add(Y, Z1, Z ) }, I, O) is Y+Z1  Z(2) For the head, LI( mult(s(X), Y, Z ), I, O) is 1 + X+Y  0(3) l It is easy to see that inequalities (1) and (2) together imply (3) satisfying the requirement 2 of the above definition. For the recursive atom mult(X, Y, Z1), the requirement 1 holds as 1 + X + Y > X + Y. The multiplication program is recursion bounded.

26 Slide 26 Recursion-bounded programs - decidability l Theorem: It is decidable whether a given moded program P is recursion bounded w.r.t. a given pair of mappings I and O or not. Proof : Follows from the fact that this problem can be reduced to the satisfiability problem of linear inequalities. l Theorem: It is decidable whether a given moded program P is recursion bounded or not. Proof : Follows from the fact that there are only finitely many choices for I and O.

27 Slide 27 Recursion-bounded programs – semantics by LI Theorem: Let P be a recursion bounded program w.r.t. a pair of mappings I and O. If there is an SLD-refutation for query  A with computed answer substitution , then LI(A , I, O) is valid. l This theorem essentially establishes that the linear inequalities capture the semantic information.

28 Slide 28 Recursion-bounded programs – properties Theorem: Let P be a recursion bounded program w.r.t. a pair of mappings I and O. If B is an atom in an SLD-derivation starting with query  A with partial computed answer substitution , such that the predicates of A and B are the same or in mutual recursion, then the sum of sizes of input terms of B (in positions I) is less than the sum of sizes of input terms of A (in positions I). l This theorem ensures finiteness of SLD- derivations of recursion bounded programs.

29 Slide 29 Recursion-bounded programs – inferability from positive data Theorem: For any recursion bounded program P and ground atom A, it is decidable whether A is in the least Herbrand model M(P) or not. Definition: Let RB k be the set of all recursion bounded clauses of size at most k and M c be a semantic mapping such that M c (P) is the set of all atoms of the target predicate c in the least Herbrand model of P. The concept defining framework is denoted by RB k.

30 Slide 30 Recursion-bounded programs – inferability from positive data Theorem: For every k  1, the class of least Herbrand models of programs in RB k is an indexed family of recursive concepts. Theorem: For every k  1, the concept defining framework RB k has bounded finite thickness. Theorem: For every m  1, the class RB k m = {M c (P) | P  RB k and |P|  m} of concepts is inferable from positive presentations of the target predicate c.

31 Slide 31 Related works l The classes of recursion bounded and linear moded programs are incomparable. Multiplication program is recursion bounded but not linear moded. Merge-sort program is linear moded but not recursion bounded. l The classes of recursion bounded and safe programs are incomparable. The standard program for nth power is recursion bounded but not safe. Merge-sort program is safe but not recursion bounded.

32 Slide 32 Conclusions l The class of recursion bounded programs is learnable from positive data. l The class of recursion bounded programs is rich enough to include many natural programs. l It is decidable whether a given logic program is recursion bounded or not. l The notion of recursion bounded programs uses very simple concepts like moding and linear inequalities.


Download ppt "Slide 1 A Class of Prolog Programs with Non-linear Outputs Inferable from Positive Data M.R.K. Krishna Rao King Fahd University of Petroleum and Minerals."

Similar presentations


Ads by Google