Presentation is loading. Please wait.

Presentation is loading. Please wait.

Proving Properties of Constraint Logic Programs by Eliminating Existential Variables Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti.

Similar presentations


Presentation on theme: "Proving Properties of Constraint Logic Programs by Eliminating Existential Variables Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti."— Presentation transcript:

1 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

2 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 1. Outline of the work

3 Polynomialsp ::= a | X | p 1 + p 2 | a X where a   and X  Var  Constraintsc ::= p 1 = p 2 | p 1 < p 2 | p 1 ≤ p 2 | c 1  c 2 LR-programs head termsh ::= X | [ ] | [X|L] where X  Var  and L  Var L body termsb ::= p | L clausescl ::= r 1 (h 1,…,h n )  c | r 1 (h 1,…,h n )  c  r 2 (b 1,…,b n ) | r 1 (h 1,…,h n )  c   r 2 (b 1,…,b n ) Goal: given a program P and a property , verify whether or not M(P)  2. Programs on lists of reals

4 start from the pair transform the statement prop   into a (stratified, finite) set of definitions D 1 …D n add each of the D 1 …D n 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) 3. Proof by transformation

5 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 D 1 …D n 2.By applying the Unfold/Fold rules we transform D 1 …D n  P into a new program T such that the definition of prop  is propositional

6 5. Clause-Form Transformation  :  L  U  X ( X  L  X ≤ U ) prop   L  U  X ( X  L  X > U ) D 4 : prop   p D 3 : p  list (L)   q (L) D 2 : q (L)  list (L)   r (L,U) D 1 : r (L,U)  X > U  list(L)  member (X,L) p q r not lr-clauses with existential variables Step 1.

7 6. Unfold-Fold Transformation D 4 : prop   p D 3 : p  p 1 p 1  p 1 D 2 : q ([])  q ([X|T])  q 1 (X,T) q 1 (X,[Y|T])  X > Y  q 1 (X, L) q 1 (X,[Y|T])  X ≤ Y  q 1 (Y, L) D 1 : 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 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 (p 1, q 1 ) The unfold/fold transformation is aimed at transforming the clauses obtained after the Step 1 into lr-clauses.

8 6. Unfold-Fold Transformation D 4 : prop   p D 3 : p  p 1 p 1  p 1 D 2 : q ([])  q ([X|T])  q 1 (X,T) q 1 (X,[Y|T])  X > Y  q 1 (X, L) q 1 (X,[Y|T])  X ≤ Y  q 1 (Y, L) D 1 : 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 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 (p 1, q 1 ) The unfold/fold transformation is aimed at transforming the clauses obtained after the Step 1 into lr-clauses.

9 6. Unfold-Fold Transformation D 4 : prop   p D 3 : p  p 1 p 1  p 1 D 2 : q ([])  q ([X|T])  q 1 (X,T) q 1 (X,[Y|T])  X > Y  q 1 (X, L) q 1 (X,[Y|T])  X ≤ Y  q 1 (Y, L) D 1 : 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 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 (p 1, q 1 ) The unfold/fold transformation is aimed at transforming the clauses obtained after the Step 1 into lr-clauses.

10 6. Unfold-Fold Transformation D 4 : prop   p D 3 : p  p 1 p 1  p 1 D 2 : q ([])  q ([X|T])  q 1 (X,T) q 1 (X,[Y|T])  X > Y  q 1 (X, L) q 1 (X,[Y|T])  X ≤ Y  q 1 (Y, L) D 1 : 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 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 (p 1, q 1 ) The unfold/fold transformation is aimed at transforming the clauses obtained after the Step 1 into lr-clauses. prop 

11 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 unfold + replace-constraints * define-fold * for all D 1,...,D n :DiDi NewDefs =  i > n noyes no yes T the final program i := i + 1

12 8. The Unfold-Fold Strategy at work start from clause D 1 : 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)

13 8. The Unfold-Fold Strategy at work start from clause D 1 : 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 D 2, D 3, and D 4 lr-clauses without existential variables

14 9. Introduction of new Definitions we cannot fold clause D 2 : q (L)  list (L)   r (L,U) Unfold : q ([ ])  q ([X|T])  X ≤ U  list (T)   r (T,U)

15 9. Introduction of new Definitions clause D 2 : q (L)  list (L)   r (L,U) Unfold : q ([ ])  q ([X|T])  X ≤ U  list (T)   r (T,U) Define : q 1 (X,T)  X ≤ U  list (T)   r (T,U) Fold :3. q ([ ])  4. q ([X|T])  q 1 (X,T) Continue to apply the transformation rules to the new definition Unfold : q 1 (X,[ ])  q 1 (X,[Y|T])  X ≤ U  Y ≤ U  list (T)   r (T,U) we cannot fold

16 9. Introduction of new Definitions need for new definitions reduce the occurrences of existential variables clause D 2 : q (L)  list (L)   r (L,U) Unfold : q ([ ])  q ([X|T])  X ≤ U  list (T)   r (T,U) Define : q 1 (X,T)  X ≤ U  list (T)   r (T,U) Fold :3. q ([ ])  4. q ([X|T])  q 1 (X,T) Continue to apply the transformation rules to the new definition Unfold : q 1 (X,[ ])  q 1 (X,[Y|T])  X ≤ U  Y ≤ U  list (T)   r (T,U) we cannot fold

17 10. Constraint Replacement  : q 1 (X,[Y|T])  X ≤ U  Y ≤ U  list (T)   r (T,U) U XY X ≤ U  Y ≤ U  U X Y U Y X  X > Y  X ≤ U  X ≤ Y  Y ≤ U

18 10. Constraint Replacement  : q 1 (X,[Y|T])  X ≤ U  Y ≤ U  list (T)   r (T,U) We substitute the clause  for  and    : q 1 (X,[Y|T])  X > Y  X ≤ U  list (T)   r (T,U)   : q 1 (X,[Y|T])  X ≤ Y  Y ≤ U  list (T)   r (T,U) U XY X ≤ U  Y ≤ U  U X Y U Y X  X > Y  X ≤ U  X ≤ Y  Y ≤ U

19 10. Constraint Replacement  : q 1 (X,[Y|T])  X ≤ U  Y ≤ U  list (T)   r (T,U) We substitute the clause  for  and    : q 1 (X,[Y|T])  X > Y  X ≤ U  list (T)   r (T,U)   : q 1 (X,[Y|T])  X ≤ Y  Y ≤ U  list (T)   r (T,U) after folding we obtain : 5. q 1 (X,[Y|T])  X > Y  q 1 (X,T) 6. q 1 (X,[Y|T])  X ≤ Y  q 1 (Y,T) U XY X ≤ U  Y ≤ U  U X Y U Y X  X > Y  X ≤ U  X ≤ Y  Y ≤ U which allow for folding

20 11. Last part of the Trasformation clause D 3 : p  list (L)   q (L) Unfold : p  list(T)   q 1 (X,T) Define : p 1  list(T)   q 1 (X,T) Fold : 7. p  p 1 Unfold : p 1  X > Y  list(T)   q 1 (X,T) p 1  X ≤ Y  list(T)   q 1 (Y,T) Constraint Replace : p 1  list(T)   q 1 (Y,T) Fold : 8. p 1  p 1 project these constraints out

21 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. q 1 (X,[Y|T])  X > Y  q 1 (X,T) 6. q 1 (X,[Y|T])  X ≤ Y  q 1 (Y,T) 7. p  p 1 8. p 1  p 1 9. prop   p T : By simple inspection of the program T we can decide that the property prop is true

22 13. Termination A brief note on termination: unfold + replace-constraints * define-fold * for all D 1,...,D n :DiDi NewDefs =  i > n noyes no yes T the final program i := i + 1

23 13. Termination A brief note on termination: The only source for nontermination is the possible introduction of infinitely many new definitions unfold + replace-constraints * define-fold * for all D 1,...,D n :DiDi NewDefs =  i > n noyes no yes T the final program i := i + 1

24 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 PropertyTime  L  U  Y ( Y  L  Y  U ) 140 ms  L  Y ( (sumlist(L,Y)  Y > 0)   X ( X  L  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

25 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

26


Download ppt "Proving Properties of Constraint Logic Programs by Eliminating Existential Variables Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti."

Similar presentations


Ads by Google