Proving Properties of Constraint Logic Programs by Eliminating Existential Variables

1 / 26

# Proving Properties of Constraint Logic Programs by Eliminating Existential Variables - PowerPoint PPT Presentation

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Proving Properties of Constraint Logic Programs by Eliminating Existential Variables' - jaeger

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Proving Propertiesof Constraint Logic Programsby 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

1. Outline of the work
• Goal: proving first order properties of

Costraint Logic Programs (CLPs)

• Focus: CLPs on the domain of lists and

real numbers

• Technique: existential quantifiers elimination by means

of program transformation

2. Programs on lists of reals
• 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 | L

clauses 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) 

3. Proof by transformation
• 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 prop

is propositional

(by definition of lr-programs)

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 :
• First we transform the statement prop into a set of definitions D1…Dn
• By applying the Unfold/Fold rules we transform D1…Dn P into a

new program T such that the definition of prop ispropositional

r

q

p

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)

Step 1.

• not lr-clauses
• with existential
• variables
6. Unfold-Fold Transformation

Step 2.

The unfold/fold transformation is aimed at transforming the clauses

obtained after the Step 1 into lr-clauses.

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)

• by repeated applications of the
• unfold,
• fold and
• constraint replacement rules
• we obtain the final program T

T

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

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

6. Unfold-Fold Transformation

Step 2.

The unfold/fold transformation is aimed at transforming the clauses

obtained after the Step 1 into lr-clauses.

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)

• by repeated applications of the
• unfold,
• fold and
• constraint replacement rules
• we obtain the final program T

T

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

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

6. Unfold-Fold Transformation

Step 2.

The unfold/fold transformation is aimed at transforming the clauses

obtained after the Step 1 into lr-clauses.

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)

• by repeated applications of the
• unfold,
• fold and
• constraint replacement rules
• we obtain the final program T

T

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

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

6. Unfold-Fold Transformation

Step 2.

The unfold/fold transformation is aimed at transforming the clauses

obtained after the Step 1 into lr-clauses.

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)

prop 

• by repeated applications of the
• unfold,
• fold and
• constraint replacement rules
• we obtain the final program T

T

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

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

7. The Unfold-Fold Strategy

A general Unfold/Fold strategy

Input: an lr-program P and a hierarchy of clauses

Output: an lr-program T

for all D1,...,Dn :

Di

unfold+

replace-constraints*

no

yes

i > n

T

define-fold*

the final

program

yes

no

i := i + 1

NewDefs = 

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)

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
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)

we cannot fold

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

need for new

definitions

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

reduce the

occurrences of existential variables

U

U

U

X

Y

X > Y  X ≤ U X ≤ Y  Y ≤ U

X

Y

X ≤ U Y ≤ U

X

Y

10. Constraint Replacement

 : q1 (X,[Y|T])  X ≤ U Y ≤ U list (T)  r (T,U)

U

U

U

X

Y

X > Y  X ≤ U X ≤ Y  Y ≤ U

X

Y

X ≤ U Y ≤ U

X

Y

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

U

U

X

Y

X > Y  X ≤ U X ≤ Y  Y ≤ U

X

Y

X ≤ U Y ≤ U

X

Y

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)

which allow

for folding

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)

Constraint

Replace : p1 list(T) q1 (Y,T)

Fold : 8. p1 p1

project these

constraints out

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

13. Termination

A brief note on termination:

for all D1,...,Dn :

Di

unfold+

replace-constraints*

no

yes

i > n

T

define-fold*

the final

program

yes

no

i := i + 1

NewDefs = 

13. Termination

A brief note on termination:

The only source for nontermination is the possible

introduction of infinitely many new definitions

for all D1,...,Dn :

Di

unfold+

replace-constraints*

no

yes

i > n

T

define-fold*

the final

program

yes

no

i := i + 1

NewDefs = 

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
15. Future work
• identify some theories of interest for which this strategy succeeds
• experiment on different data structures (e.g. trees) and

domains with a linear order and closed under projection

• investigate phenomena that lead to nontermination
• generalization techniques that allow for folding