Title: A Class of Prolog Programs with Nonlinear Outputs Inferable from Positive Data
1A 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
2Outline
- Learning from positive data
- History and Motivation
- Recursion bounded programs
- Decidability of Recursion bounded programs
- Infererability of Recursion bounded programs from
positive data - Comparison and conclusions
3Learnability from positive data
- Gold (1967) proved that even simple classes of
concepts like the class of regular languages
cannot be inferred from positive examples alone. - Why study it?
- In practice, positive examples are easier to
obtain than negative examples. - Starting with Angluin (1980), many results on
learnability from positive data are published.
4Learnability from positive data
- 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!
5Learnability from positive data
- 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.
6Learnability from positive data
- 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.
7Learnability from positive data
- 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.
8Motivation
- 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.
9Preliminaries
- A concept defining framework is a triple (U, E,
f) of a universe U of objects, a set E of
expressions and a semantic mapping f. - A class of concepts C G1, G2, is an indexed
family of recursive concepts if there exists an
algorithm that decides whether w ? Gi for any
object w and natural number i. - A semantic mapping f is monotonic if R ? R'
implies f(R) ? f(R'). - A formal system R is reduced w.r.t. S ? U if S ?
f(R) and for any proper subset R' of R, f(R') ? S.
10Preliminaries
- A concept defining framework C (U, E, f) has
bounded finite thickness if - is monotonic and
- for any finite set S ? U and any m ? 0, the set
- f(R) R is reduced w.r.t.S and R ? m
- is finite.
- Theorem from Shinohara (1991)
- If a concept defining framework C (U, E, f) has
bounded finite thickness, then the class - Cm f(R) R ? E and R ? m
- of concepts is inferable from positive data for
every m ? 1.
11Recursion-bounded programs
- 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. - 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.
12Recursion-bounded programs
- 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 tf(t1, , tn), then t is a linear
expression 1 t1 tn. - The parametric size of a sequence t1, , tn of
terms is the sum t1 tn. - Example
- The parametric sizes of terms a, , X, a,
a,b,c, , , , a, b, c are
0, 0, X1, 1, 3, 3, 6 respectively.
13Recursion-bounded programs
- 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. - For an atom A p(s t), we denote the linear
inequality - by LI(A, I, O).
14Recursion-bounded programs
- A moded program P is recursion bounded w.r.t. I
and O if each clause p0(s0 t0) ? p1(s1 t1), ,
pk(sk tk) - in it satisfies the following
- LI(A1, I, O), , LI(Aj-1, I, O) together imply
Iterms(A0, I) gt Iterms(Aj, I) for each j such
that pj is in mutual recursion with p0 (or pjp0
), - LI(A1, I, O), , LI(Ak, I, O) together imply
LI(A0, I, O), and - A moded program P is recursion bounded if it is
recursion bounded w.r.t. some I and O.
15Recursion-bounded programs - reverse
- Example Consider the following reverse program
with moding info - app(in,in, out) and rev(in, out).
- app( , Ys, Ys) ?
- app(XXs, Ys, XZs) ? app(Xs,Ys, Zs)
- rev( , ) ?
- rev(XXs, 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. - The first clause is recursion bounded.
16Recursion-bounded programs - reverse
- Now consider the second clause
- app(XXs, Ys, XZs) ? app(Xs,Ys, Zs)
- LI(app(Xs, Ys, Zs), I, O) is
- Xs Ys ? Zs (1)
- LI(app(XXs, Ys, XZs), I, O) is
- 1X Xs Ys ? 1X Zs (2)
- Its easy to see that (1) imples (2) satisfying
the requirement 2 of the above definition. - The requirement 1 of the above definition
obviously holds as 1 X Xs Ys gt Xs Ys. - Therefore, the second clause is recursion bounded.
17Recursion-bounded programs - reverse
- Now consider the fourth clause
- rev(XXs, 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(XXs, Zs), I, O) is
- 1 X Xs ? Zs (5)
- Its easy to see that (3) and (4) together imply
(5) satisfying the requirement 2 of the above
definition.
18Recursion-bounded programs - reverse
- The fourth clause
- rev(XXs, 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 gt Xs.
- Therefore, the fourth clause is recursion
bounded. - The third clause is recursion bounded as well.
- The reverse program is recursion bounded.
19Recursion-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(XXs, Ys, XZs) ? app(Xs,Ys, Zs)
- part( ,H, , ) ?
- part(XXs,H,XLs,Bs) ? H ? X,
part(Xs,H,Ls,Bs) - part(XXs,H,Ls,XBs) ? X gt H,
part(Xs,H,Ls,Bs) - qs( , ) ?
- qs(HL,S) ? part(L,H,A,B), qs(A,A1), qs(B,B1),
- app(A1,HB1,S)
20Recursion-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. - We consider the last clause, other clauses are
easier to handle. - qs(HL,S) ? part(L,H,A,B), qs(A,A1),
- qs(B,B1), app(A1,HB1,S)
- It may be noted that quick-sort program is not
recursion bounded w.r.t. I and O if I(part)
in(part).
21Recursion-bounded programs - quicksort
- We consider the last clause, other clauses are
easier to handle. - qs(HL,S) ? part(L,H,A,B), qs(A,A1), qs(B,B1),
- app(A1,HB1,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,HB1,S), I, O) is A1 1 H B1 ? S
(4) - For the head, LI(qs(HL,S)), I, O) is 1 H
L ? S (5) - 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).
22Recursion-bounded programs
- The above two examples illustrate the main
characteristics of recursion bounded programs. - The linear inequalities capture the semantics of
the programs (they capture model information used
in acceptable programs). - The size of output terms in positions O is
bounded by the size of input terms in positions I.
23Recursion-bounded programs
- The above two programs have linear relationship
between inputs and outputs. - However, the class of recursion bounded programs
is rich enough to include predicates with non
linear relationships (as multiplication in the
next example). - The trick is to choose appropriate I and O!
24Recursion-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) f.
25Recursion-bounded programs - multiply
- 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 XY ? 0 (1)
- LI(add(Y, Z1, Z), I, O) is YZ1 ? Z (2)
- For the head, LI(mult(s(X), Y, Z), I, O) is 1
XY ? 0 (3) - 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 gt X Y. - The multiplication program is recursion bounded.
26Recursion-bounded programs - decidability
- 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. - 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.
27Recursion-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 s, then LI(As, I, O) is valid. - This theorem essentially establishes that the
linear inequalities capture the semantic
information.
28Recursion-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 s, 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). - This theorem ensures finiteness of
SLD-derivations of recursion bounded programs.
29Recursion-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 RBk be the set of all recursion
bounded clauses of size at most k and Mc be a
semantic mapping such that Mc(P) is the set of
all atoms of the target predicate c in the least
Herbrand model of P. - The concept defining framework ltB(c), RBk, Mcgt is
denoted by RBk.
30Recursion-bounded programs inferability from
positive data
- Theorem For every k ?1, the class of least
Herbrand models of programs in RBk is an indexed
family of recursive concepts. - Theorem For every k ?1, the concept defining
framework RBk has bounded finite thickness. - Theorem For every m ?1, the class RBkm Mc(P)
P ? RBk and P ? m of concepts is inferable
from positive presentations of the target
predicate c.
31Related works
- 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. - 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.
32Conclusions
- The class of recursion bounded programs is
learnable from positive data. - The class of recursion bounded programs is rich
enough to include many natural programs. - It is decidable whether a given logic program is
recursion bounded or not. - The notion of recursion bounded programs uses
very simple concepts like moding and linear
inequalities.