New techniques for Termination Analysis of Logic Programs - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

New techniques for Termination Analysis of Logic Programs

Description:

... for Termination Analysis of Logic Programs. Manh Thang Nguyen ... Logic: What the problem is: ... Practically, most termination problems for LP and ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 30
Provided by: csKule
Category:

less

Transcript and Presenter's Notes

Title: New techniques for Termination Analysis of Logic Programs


1
New techniques for Termination Analysis of Logic
Programs
  • Manh Thang Nguyen
  • Supervisor Danny De Schreye

2
(No Transcript)
3
Logic Programming Term Rewriting
  • Algorithm Logic Control Kowalski,1979
  • Logic What the problem is predefined
    specification
  • Control How the problem should be solved find
    all solutions in finite time
  • Formal termination proofs are required
  • Generally, the termination problem for LP and TRS
    is undecidable
  • Practically, most termination problems for LP and
    TRS can be proved
  • Mapping terms to a well founded ordered set
  • Proving a decrease in mapped values in every
    computational step

4
Overview
  • PART I
  • Logic Programming
  • Termination Analysis of Logic Programming
  • Term Rewriting Systems
  • Introduction to Term Rewriting Systems
  • Termination Analysis of Term Rewriting Systems
  • Porting termination techniques of TRSs into LPs
  • General Framework
  • PART II
  • Polynomial Interpretations in Logic Programming
  • Polynomial Interpretation
  • Rigidity
  • Applying to rigid order acceptability

5
Termination Analysis of LP
  • Two approaches
  • Assigning atoms to natural numbers De Schreye,
    1992
  • Finding a well founded order in the set of atoms
    De Schreye Serebrenik, 2001

6
Termination of LP First Approach
PROGRAM permute(,). permute(L,ET)-
delete(E,L,L1),permute(L1,T). delete(X,XT,T).
delete(X,HT,HT1)- delete(X,T,T1). QUERY ?-
permute(1,2,3,L).
Acceptability Termination is equivalent to the
existence of a level mapping such that the size
of each call to the head of the recursive clause
w.r.t the level mapping is greater than the size
of the corresponding call to the recursive body
subgoal substituted by any computed answer of
previous atoms w.r.t it.
7
Termination of LP First Approach
  • Norms Level Mappings
  • To map terms and atoms to natural numbers Bezem,
    1989
  • (Semi) linear norms level mapping Bossi,1991
  • Rigidity of a term (or atom) w.r.t a norm (or
    level mapping)
  • The size of an atom w.r.t a norm doesnt change
    under substitutions
  • (Semi) linear norm rigidity ? no relevant
    occurrence of any variable
  • (Valid) interargument relation for a predicate
  • RP ? All logical consequences for p w.r.t the
    program
  • Rigid Acceptability
  • A sufficient condition verifies termination at
    the clause level
  • Condition on computed answer substitution is
    replaced by one on RP
  • Level mapping is rigid on all calls to the heads
    of any recursive clause

8
Termination of LP Second Approach
PROGRAM permute(,). permute(L,ET)-
delete(E,L,L1),permute(L1,T). delete(X,XT,T).
delete(X,HT,HT1)- delete(X,T,T1). QUERY ?-
permute(1,2,3,L).
  • Order-acceptability
  • Applying a general ordering directly
  • Ordering is well-founded
  • Rigid order-acceptability
  • Verifying termination at the clause level
  • Rigidity of all calls to the heads w.r.t the
    ordering
  • Computed answer is replaced by one on valid
    interargument relations

9
Overview
  • PART I
  • Logic Programming
  • Introduction to Logic Programming
  • Termination Analysis of Logic Programming
  • Term Rewriting Systems
  • Introduction to Term Rewriting Systems
  • Termination Analysis of Term Rewriting Systems
  • Porting termination techniques of TRS into LP
  • General Framework
  • PART II
  • Polynomial Interpretations in Logic Programming
  • Polynomial Interpretation
  • Rigidity
  • Applying to rigid order acceptability

10
Term Rewriting Systems
A Term Rewriting System (?,R)
(R1) d(x) ? 1, (R2) d(y) ? 0, (R3)
d(UV) ? d(U) d(V), (R4) d(UV) ? (Ud(V))
(d(U)V).
11
Term Rewriting Systems
TRS reductions
d(xx)
Termination
Confluence
12
Termination Analysis of TRS
  • Termination The existence of a well founded
    order gt on term set such that
  • the order gt is a reduction order
  • gt is closed under any substitution u gt v ?u? gt
    v?
  • Closed under contexts u gt v ? CuP gt CvP
  • (CuP replacing the subterm of C at position p
    by the term u)
  • the order gt is compatible with the TRS
  • For any rewrite rule l ?r in TRS, lgtr

Input C CuP lt CvP C Output
u l? lt r? v
13
Termination Analysis of TRS
Suppose gt is a reduction order such
that (R1) d(x) gt 1, (R2) d(y) gt
0, (R3) d(UV) gt d(U) d(V), (R4) d(UV) gt
(Ud(V)) (d(U)V).
gt
gt
gt
14
Termination Analysis of TRS
  • Interpretation Methods
  • Finding a weight function that maps terms to well
    founded ordered set (i.e. natural numbers).
  • Polynomial interpretations, simplification
    polynomial interpretation,
  • Syntactical Methods
  • Finding a well founded order directly on the set
    of terms defined by induction on the structure of
    the terms
  • Simplification orders, recursive path orders,
    Knuth-Bendix Orders
  • Tranformational Methods
  • Transforming a TRS to another while preserving
    termination property and verifying it for the
    target system

15
Termination Analysis of TRSInterpretation
Approach
  • A well founded monotone algebra (A,?A,gt) consists
    of
  • a domain A
  • a well founded order gt on the domain A
  • a signature ?A such that for every function
    symbol f??, there exists a monotone fA??A such
    that
  • The TRS terminates if
  • there exists such an algebra and
  • the order gtA defined by
  • is compatible with the TRS

Implying a compatible well founded order on the
term set
fA(a1,,a,,an)ltfA(a1,,b,,an) if altb (for a, b,
ai, bi ?A)
16
Termination Analysis of TRSInterpretation
Approach
  • Polynomial interpretation
  • A well founded monotone algebra (A,?A,gt) where
  • A is a domain of natural numbers
  • ?A is a set of monotone polynomials over natural
    numbers
  • The order gt is the normal order on natural
    numbers
  • A TRS terminates if the polynomial interpretation
    is compatible

Reduction order
Polynomial Interpretation A N\0,1 P1 P0
Px Py 2 P(U,V) U V, P(U,V) U V,
Pd(U) U2 ?sA(d(x)) sA(x2) 4 gt
sA(1) 2 sA(d(Y)) sA(y2) 4 gt
sA(0) 2 sA(d(UV)) sA(UV)2
gtsA(U2V2) sA(d(U)d(V)) sA(d(UV))
sA(U2V2)gt sA (UV2U2V )
sA(Ud(V)d(U)V)
Term Rewriting System (R1) d(x) ? 1, (R2)
d(y) ? 0, (R3) d(UV) ? d(U) d(V), (R4)
d(UV) ? (Ud(V)) (d(U)V).
Define a polynomial interpretation
Thus, termination
Compatible
17
Termination Analysis of TRSInterpretation
Approach
  • A simple monotone algebra (A,?A,gt) consists of
  • a domain A
  • a partial order gt on the domain A
  • a signature ?A such that for every function
    symbol f??, there exists a monotone fA??A such
    that
  • The TRS terminates if
  • there exists a such algebra and
  • the order gtA defined by
  • is compatible with the TRS

fA(a1,,a,,an)ltfA(a1,,b,,an) if altb and
fA(a1,,a,,an) gt a (for a, b, ai, bi ?A)
ltA is called a simplification order, that is
indeed a reduction order!
18
Termination Analysis of TRSInterpretation
Approach
  • Simplification polynomial interpretation
  • A simple monotone algebra (A,?A,gt) where
  • A is a domain of real numbers
  • ?A is a set of monotone polynomials over real
    numbers that have the subterm property
  • The order gt is the normal order on real numbers
  • A TRS terminates if the interpretation is
    compatible with it
  • Automatic systems for termination analysis of TRS
  • For both polynomial interpretation and
    simplification polynomial interpretation
    techniques, there is a number of heuristics for
    generating appropriate polynomials that have been
    developed in recent years
  • The genetic algorithm finding polynomial orders
    Giesl, J. et al, 1995
  • The Tyrolean Termination Tools (TTT), the
    university of Innsbruck
  • .

19
Overview
  • PART I
  • Logic Programming
  • Introduction to Logic Programming
  • Termination Analysis of Logic Programming
  • Term Rewriting Systems
  • Introduction to Term Rewriting Systems
  • Termination Analysis of Term Rewriting Systems
  • Porting termination techniques of TRSs into LPs
  • General Framework
  • PART II
  • Polynomial Interpretations in Logic Programming
  • Polynomial Interpretation
  • Rigidity
  • Applying to rigid order acceptability

20
Porting termination techniques from TRS to LP
General Framework
Logic Programming
Term Rewriting Systems
Directly porting
Techniques for Termination Analysis of LP
Techniques for Termination Analysis of TRS
Termination!
General orders on Terms Serebrenik and DeScheye
Reduction orders on Terms
21
Overview
  • PART I
  • Logic Programming
  • Introduction to Logic Programming
  • Termination Analysis of Logic Programming
  • Term Rewriting Systems
  • Introduction to Term Rewriting Systems
  • Termination Analysis of Term Rewriting Systems
  • Porting termination techniques of TRSs into LPs
  • General Framework
  • PART II
  • Polynomial Interpretations in Logic Programming
  • Polynomial Interpretation
  • Rigidity
  • Applying to rigid order acceptability

22
Polynomial Interpretation in LP
  • A polynomial Interpretation I in LP consists of
  • a well founded domain D of natural numbers
  • a mapping that maps each function symbol to a
    polynomial
  • a mapping that maps each predicate symbol to a
    polynomial
  • A polynomial norm .J and level mapping .I are
    mappings
  • XJ X, f(t1,,tn)J Pf(tf1J ,,tfmJ )
  • p(t1,,tn)I Pp(tf1J ,,tfmJ )

The atom A dist(U(XY),V) is assigned
to U(XY1) (the polynomial interpretation of A)
? Terms atoms can be mapped to instances of
polynomials!
dist(x,x). dist(xx,xx). dist(XY,UV) -
dist(X,U), dist(Y,V). dist(X(YZ),T) - dist(XY
XZ, T). dist((XY)Z,T) - dist(XZ YZ,T).
Polynomial Interpretation A domain D N A
mapping that maps P X1X2, P X1X21,
Pxcx, A mapping that maps Pdist X, (first
argument position)
23
Polynomial Interpretation in LP Order
Acceptability
Proposition If there exists a polynomial
interpretation such that such that the
interpretation of each call to the head of the
recursive clause is greater than the
interpretation of the corresponding call to the
recursive body subgoal, the program is order
acceptable ? Termination is reduced to verifying
orders on the polynomial interpretation! Example
The following program terminates with any query
dist(t1,t2) where t1 is a ground term and t2 is a
free variable.
Polynomial Interpretation A domain D N\0,1 A
mapping that maps P X1X2, P X1X21,
Pxcx, A mapping that maps Pdist X, (first
argument position) Example Consider clause
(4) A dist(tx(tytz),T), we have PA
Ptx(PtvPtz1) B dist(txtytxtz),T), we have
PB PtxPtyPtxPtz 1 Therefore PAgtPB Prove
simlarly for clauses (3),(5) implies termination
of P
1. dist(x,x). 2. dist(xx,xx). 3. dist(XY,UV)
- dist(X,U), dist(Y,V). 4. dist(X(YZ),T) -
dist(XY XZ, T). 5. dist((XY)Z,T) -
dist(XZ YZ,T).
24
Polynomial Interpretation in LP Rigidity
  • A polynomial interpretation is call monotone if
  • It associates each function (and predicate)
    symbol with a monotone polynomial
  • An occurrence X(i) of a variable X in t is
    called relevant if
  • There exists a term s such that the
    interpretation of t changes where we replace X(i)
    by s in t
  • Proposition
  • A term is rigid w.r.t. a monotone polynomial
    interpretation iff the set of all relevant
    occurrences is empty
  • An extension of the proposition on rigidity w.r.t
    (semi) linear norm in Bossi et al, 1991
  • Allow to check the rigidity property of terms
    (and atoms) syntactically
  • Necessary when we want to reduce acceptability to
    the clause level

25
Polynomial Interpretation in LP Rigid Order
Acceptability
  • Redefine termination conditions to conditions on
    polynomial interpretation and at the clause level
  • Verifying rigidity of atoms (or terms) and valid
    interargument relations by checking its
    interpretation
  • The order between the call to the head of the
    recursive clause and the corresponding call to
    the recursive body subgoal is verified by
    checking the order on the interpretation
  • Polynomial Interpretation I
  • A domain D N\0,1
  • A mapping that maps P X1X2, P X1X21,
    Pxcx,
  • A mapping that maps Pdist X, (first argument
    position)
  • Example
  • - Consider clause (4)
  • A dist(X(YX),T), we have PA
    X(YZ1)
  • B dist(XYXZ),T), we have PB
    XYXZ 1
  • Therefore PAgtPB
  • - Verify simlarly clauses (3),(5)
  • Since the call set is rigid w.r.t. I and
  • the interargument relation is valid, the program
    terminates

1. dist(x,x). 2. dist(xx,xx). 3. dist(XY,UV)
- dist(X,U), dist(Y,V). 4. dist(X(YZ),T) -
dist(XY XZ, T). 5. dist((XY)Z,T) -
dist(XZ YZ,T).
26
Towards an automated termination proof
  • Reformulate all sufficient termination conditions
    in term of a constraint set of polynomials
  • Find a constraint solver to solve the
    inequalities
  • Restrict polynomials to simple-mixed
    polynomials (i.e. X2 2XYX1)
  • Find some heuristics to automatically generate
    polynomials
  • A number of techniques have been proposed in TRS

27
Conclusion and Future Works
  • I have introduced some previous works on
  • LP and techniques for termination analysis of LP
  • TRS and techniques for termination analysis of
    TRS
  • A general framework for porting termination
    techniques from TRS to LP
  • Introducing new technique for termination
    analysis in LP polynomial interpretation
  • Future Works
  • Doing more researches on simplification
    polynomial interpretation and porting it from TRS
    to LP
  • Studying tools for automated termination proof in
    TRS and applying it to LP

28
Logic Programming
Based on First Order Theory
permute(,). permute(L,ET)-
delete(E,L,L1),permute(L1,T). delete(X,XT,T).
delete(X,HT,HT1)- delete(X,T,T1).
29
Logic Programming
SLD-Resolution
permute(1,2,L)
Write a Comment
User Comments (0)
About PowerShow.com