+ All Categories
Home > Documents > Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

Date post: 24-Jan-2016
Category:
Upload: jaeger
View: 34 times
Download: 0 times
Share this document with a friend
Description:
Proving Properties of Constraint Logic Programs by Eliminating Existential Variables. Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti (IASI-CNR, Roma), Valerio Senni (Università di Roma “Tor Vergata”). CILC2006 – DIB – Università di Bari. 26-27 June 2006. - PowerPoint PPT Presentation
Popular Tags:
26
Proving Properties of Constraint Logic Programs by Eliminating Existential Variables Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti (IASI-CNR, Roma), Valerio Senni (Università di Roma “Tor Vergata”) CILC2006 – DIB – Università di Bari 26-27 June 2006
Transcript
Page 1: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

Proving Propertiesof Constraint Logic Programs

by Eliminating Existential Variables

Alberto Pettorossi (Università di Roma “Tor

Vergata”),

Maurizio Proietti (IASI-CNR, Roma),

Valerio Senni (Università di Roma “Tor

Vergata”)CILC2006 – DIB – Università di Bari 26-27 June 2006

Page 2: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

• Goal: proving first order properties ofCostraint Logic Programs (CLPs)

• Focus: CLPs on the domain of lists andreal numbers

• Technique: existential quantifiers elimination by meansof program transformation

1. Outline of the work

Page 3: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

• Polynomials p ::= a | X | p1 + p2 | a X where a and X Var

• Constraints c ::= p1 = p2 | p1 < p2 | p1 ≤ p2 | c1 c2

• LR-programs

head terms h ::= X | [ ] | [X|L] where X Var and L VarL

body terms b ::= p | Lclauses cl ::= r1(h1,…,hn) c |

r1 (h1,…,hn) c r2 (b1,…,bn) |

r1 (h1,…,hn) c r2 (b1,…,bn)

Goal: given a program P and a property , verify whether or not

M(P)

2. Programs on lists of reals

Page 4: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

• start from the pair < P, prop >

• transform the statement prop into a (stratified, finite) set of definitions D1…Dn

• add each of the D1…Dn to the inital program P obtaining at each step a new lr-program without existential variables

• If the transformation process terminates, then the definition of propis propositional(by definition of lr-programs)

3. Proof by transformation

Page 5: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

4. An example

• Initial program P

member (X,[Y|L]) X=Y member (X,[Y|L]) member (X,L)

• Property : L U X ( X L X ≤ U )

we want to show that any list of reals has an upper bound

• Two steps :

1. First we transform the statement prop into a set of definitions

D1…Dn

2. By applying the Unfold/Fold rules we transform D1…Dn P into a

new program T such that the definition of prop is propositional

Page 6: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

5. Clause-Form Transformation

: L U X ( X L X ≤ U )

prop L U X ( X L X > U )

D4: prop p

D3: p list (L) q (L)

D2: q (L) list (L) r (L,U)

D1: r (L,U) X > U list(L) member (X,L)

p

q

r

• not lr-clauses

• with existential variables

Step 1.

Page 7: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

6. Unfold-Fold Transformation

D4 : prop p

D3 : p p1

p1 p1

D2 : q ([]) q ([X|T]) q1(X,T)

q1 (X,[Y|T]) X > Y q1 (X , L)

q1 (X,[Y|T]) X ≤ Y q1 (Y , L)

D1 : r ([X|T],U) X > U list (L) r ([X|T],U) r (T,U)

Step 2.

by repeated applications of the

• unfold, • fold and• constraint replacement

ruleswe obtain the final program

TT

For each initial predicate we have obtained a new definition, made of lr-clauses.

Possibly with the use of some auxiliary predicate (p1, q1)

The unfold/fold transformation is aimed at transforming the clausesobtained after the Step 1 into lr-clauses.

Page 8: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

6. Unfold-Fold Transformation

D4 : prop p

D3 : p p1

p1 p1

D2 : q ([]) q ([X|T]) q1(X,T)

q1 (X,[Y|T]) X > Y q1 (X , L)

q1 (X,[Y|T]) X ≤ Y q1 (Y , L)

D1 : r ([X|T],U) X > U list (L) r ([X|T],U) r (T,U)

Step 2.

by repeated applications of the

• unfold, • fold and• constraint replacement

ruleswe obtain the final program

TT

For each initial predicate we have obtained a new definition, made of lr-clauses.

Possibly with the use of some auxiliary predicate (p1, q1)

The unfold/fold transformation is aimed at transforming the clausesobtained after the Step 1 into lr-clauses.

Page 9: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

6. Unfold-Fold Transformation

D4 : prop p

D3 : p p1

p1 p1

D2 : q ([]) q ([X|T]) q1(X,T)

q1 (X,[Y|T]) X > Y q1 (X , L)

q1 (X,[Y|T]) X ≤ Y q1 (Y , L)

D1 : r ([X|T],U) X > U list (L) r ([X|T],U) r (T,U)

Step 2.

by repeated applications of the

• unfold, • fold and• constraint replacement

ruleswe obtain the final program

TT

For each initial predicate we have obtained a new definition, made of lr-clauses.

Possibly with the use of some auxiliary predicate (p1, q1)

The unfold/fold transformation is aimed at transforming the clausesobtained after the Step 1 into lr-clauses.

Page 10: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

6. Unfold-Fold Transformation

D4 : prop p

D3 : p p1

p1 p1

D2 : q ([]) q ([X|T]) q1(X,T)

q1 (X,[Y|T]) X > Y q1 (X , L)

q1 (X,[Y|T]) X ≤ Y q1 (Y , L)

D1 : r ([X|T],U) X > U list (L) r ([X|T],U) r (T,U)

Step 2.

by repeated applications of the

• unfold, • fold and• constraint replacement

ruleswe obtain the final program

TT

For each initial predicate we have obtained a new definition, made of lr-clauses.

Possibly with the use of some auxiliary predicate (p1, q1)

The unfold/fold transformation is aimed at transforming the clausesobtained after the Step 1 into lr-clauses.

prop

Page 11: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

7. The Unfold-Fold Strategy

A general Unfold/Fold strategy

Input: an lr-program P and a hierarchy <D1,...,Dn> of clauses

Output: an lr-program T

unfold +

replace-constraints *

define-fold *

for all D1,...,Dn :

Di

NewDefs =

i > n

noyes

no

yesT

the finalprogram

i := i + 1

Page 12: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

8. The Unfold-Fold Strategy at work

start from clause D1 :

r (L,U) X > U list(L) member (X,L)

Unfold : r ([X|T],U) X > U list(T) r ([X|T],U) Y > U list(T) member (Y,T)

Fold : 1. r ([X|T],U) X > U list(T)

2. r ([X|T],U) r (T,U)

Page 13: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

8. The Unfold-Fold Strategy at work

start from clause D1 :

r (L,U) X > U list(L) member (X,L)

Unfold : r ([X|T],U) X > U list(T) r ([X|T],U) Y > U list(T) member (Y,T)

Fold : 1. r ([X|T],U) X > U list(T)

2. r ([X|T],U) r (T,U)

We go on with the following definitions D2, D3, and D4

• lr-clauses

• without existential variables

Page 14: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

9. Introduction of new Definitions

we cannot fold

clause D2 :

q (L) list (L) r (L,U)

Unfold : q ([ ]) q ([X|T]) X ≤ U list (T) r (T,U)

Page 15: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

9. Introduction of new Definitions

clause D2 :

q (L) list (L) r (L,U)

Unfold : q ([ ]) q ([X|T]) X ≤ U list (T) r (T,U)

Define : q1(X,T) X ≤ U list (T) r (T,U)

Fold : 3. q ([ ]) 4. q ([X|T]) q1(X,T)

Continue to apply the transformation rules to the new definition

Unfold : q1(X,[ ])

q1(X,[Y|T]) X ≤ U Y ≤ U list (T) r (T,U)

we cannot fold

Page 16: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

9. Introduction of new Definitions

need for newdefinitions

reduce theoccurrences of existential variables

clause D2 :

q (L) list (L) r (L,U)

Unfold : q ([ ]) q ([X|T]) X ≤ U list (T) r (T,U)

Define : q1(X,T) X ≤ U list (T) r (T,U)

Fold : 3. q ([ ]) 4. q ([X|T]) q1(X,T)

Continue to apply the transformation rules to the new definition

Unfold : q1(X,[ ])

q1(X,[Y|T]) X ≤ U Y ≤ U list (T) r (T,U)

we cannot fold

Page 17: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

10. Constraint Replacement

: q1 (X,[Y|T]) X ≤ U Y ≤ U list (T) r (T,U)

U

X YX ≤ U Y ≤ U

U

X

Y

U

Y

X

X > Y X ≤ U X ≤ Y Y ≤ U

Page 18: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

10. Constraint Replacement

: q1 (X,[Y|T]) X ≤ U Y ≤ U list (T) r (T,U)

We substitute the clause for and

: q1 (X,[Y|T]) X > Y X ≤ U list (T) r (T,U)

: q1 (X,[Y|T]) X ≤ Y Y ≤ U list (T) r (T,U)

U

X YX ≤ U Y ≤ U

U

X

Y

U

Y

X

X > Y X ≤ U X ≤ Y Y ≤ U

Page 19: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

10. Constraint Replacement

: q1 (X,[Y|T]) X ≤ U Y ≤ U list (T) r (T,U)

We substitute the clause for and

: q1 (X,[Y|T]) X > Y X ≤ U list (T) r (T,U)

: q1 (X,[Y|T]) X ≤ Y Y ≤ U list (T) r (T,U)

after folding we obtain :

5. q1 (X,[Y|T]) X > Y q1 (X,T)

6. q1 (X,[Y|T]) X ≤ Y q1 (Y,T)

U

X YX ≤ U Y ≤ U

U

X

Y

U

Y

X

X > Y X ≤ U X ≤ Y Y ≤ U

which allowfor folding

Page 20: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

11. Last part of the Trasformation

clause D3 : p list (L) q (L)

Unfold : p list(T) q1 (X,T)

Define : p1 list(T) q1 (X,T)

Fold : 7. p p1

Unfold : p1 X > Y list(T) q1

(X,T) p1 X ≤ Y list(T) q1

(Y,T)

ConstraintReplace : p1 list(T) q1 (Y,T)

Fold : 8. p1 p1

project theseconstraints out

Page 21: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

12. Final Program

At the end of the transformation we obtain the following program:

1. r ([X|T],U) X > U list(T)

2. r ([X|T],U) r (T,U)3. q ([ ]) 4. q ([X|T]) newp1(X,T)

5. q1 (X,[Y|T]) X > Y q1 (X,T)

6. q1 (X,[Y|T]) X ≤ Y q1 (Y,T)

7. p p1

8. p1 p1

9. prop p

T :

By simple inspection of the program T we can decide that the property prop is true

Page 22: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

13. Termination

A brief note on termination:

unfold +

replace-constraints *

define-fold *

for all D1,...,Dn :

Di

NewDefs =

i > n

noyes

no

yesT

the finalprogram

i := i + 1

Page 23: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

13. Termination

A brief note on termination:

The only source for nontermination is the possibleintroduction of infinitely many new definitions

unfold +

replace-constraints *

define-fold *

for all D1,...,Dn :

Di

NewDefs =

i > n

noyes

no

yesT

the finalprogram

i := i + 1

Page 24: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

14. Experimental results

We have run some experiments on the MAP system that implements

the Unfold/Fold transformation strategy.

• constraints handling: clp(r) module of SICStus prolog(implementing a variant of the Fourier-Motzkin algorithm for existential variables elimination)

• theorems in the theory of linear orders, lists, and sum

Property Time

L U Y ( YL Y U ) 140 ms

L Y ( (sumlist(L,Y) Y > 0) X (XL X > 0) ) 170 ms

L M N ( (ord(L) ord(M) sumzip(L,M,N)) ord(N) ) 160 ms

L M X Y ( (leqlist(L,M) sumlist(L,X) sumlist(M,Y)) X Y )

50 ms

Page 25: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

15. Future work

• identify some theories of interest for which this strategy succeeds

• experiment on different data structures (e.g. trees) anddomains with a linear order and closed under projection

• investigate phenomena that lead to nontermination

• generalization techniques that allow for folding

Page 26: Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

Recommended