Presentation is loading. Please wait.

Presentation is loading. Please wait.

13/07/20151 A Goal-Independent Suspension Analysis for Logic Programs with Dynamic Scheduling Samir Genaim Universita’ degli Studi di Verona Italy Andy.

Similar presentations


Presentation on theme: "13/07/20151 A Goal-Independent Suspension Analysis for Logic Programs with Dynamic Scheduling Samir Genaim Universita’ degli Studi di Verona Italy Andy."— Presentation transcript:

1 13/07/20151 A Goal-Independent Suspension Analysis for Logic Programs with Dynamic Scheduling Samir Genaim Universita’ degli Studi di Verona Italy Andy King Computing Laboratory University of Kent The idea: The talk will describe an analysis for ccp programs or a logic program with delay. The analysis does not verify that an input goal will not generate suspending sub-goals (standard approach) but rather infers a class of goals that do not lead to suspending sub-goals (new approach).

2 13/07/20152 Forward versus backward suspension analysis Suspension analysis traditionally verifies that a class of goals will not lead to suspension These analyses use local fixpoints [Codognet90] or star-abstractions [Codish94] to avoid the state-space explosion that arises from goal interleaving One advantage of backward suspension analysis is that the programmer need not rerun the analysis for different (abstract) queries.

3 13/07/20153 Example analysis for inorder (Prolog with delay and ccp style) inorder(nil,[]). inorder(tree(L,V,R),I) :- app(LI,[V|RI],I), inorder(L,LI), inorder(R,RI). :- block app(-, ?, -). app([], X, X). app([X|Xs], Ys, [X|Zs]) :- app(Xs,Ys,Zs). inorder(T, I) :- true : T = nil, I = [] : true. inorder(T, I) :- true : T = tree(L,V,R), A = [V|RI] : app(LI,A,I), inorder(L,LI), inorder(R,RI). app(L, Ys, A) :- nonvar(L)  nonvar(A): L = [], A = Ys : true. app(L, Ys, A) :- nonvar(L)  nonvar(A): L = [X|Xs], A = [X|Zs] : app(Xs,Ys,Zs).

4 13/07/20154 Pos abstraction inorder(T, I) :- true : T  I. inorder(T, I) :- true : T  (L  V  R), A  (V  RI) : app(LI, A, I), inorder(L, LI), inorder(R, RI). app(L, Ys, A) :- L  A : L  (A  Ys) : true. app(L, Ys, A) :- L  A : L  (X  Xs), A  (X  Zs) : app(Xs,Ys,Zs). Note that asks are abstracted from below whereas tells are abstracted from above app(L, Ys, A) :- nonvar(L)  nonvar(A): L = [], A = Ys : true. app(L, Ys, A) :- nonvar(L)  nonvar(A): L = [X|Xs], A = [X|Zs] : app(Xs,Ys,Zs).

5 13/07/20155 lfp calculation The success patterns of the ccp program (and thus the Prolog with delay program) are described by the lfp of the abstract Pos program A success pattern is an atom with distinct variables for arguments paired with a Pos formula over those variables The lfp of the Pos program can be computed in T P -style to give F = { inorder(x 1, x 2 ) :- x 1  x 2, app(x 1, x 2, x 3 ) :- (x 1  x 2 )  x 3 } Observe that F faithfully describes the grounding behaviour of inorder and app

6 13/07/20156 gfp calculation A gfp is computed to characterise the call patterns of the program; a call pattern has the same syntactic form as a success pattern Iteration commences with D 0 = top and incrementally strengthens the call pattern formulae until they describe queries that do not violate the ask constraints: D 1 = { inorder(x 1, x 2 ):- true, app(x 1, x 2, x 3 ) :- x 1  x 3 } D 2 = { inorder(x 1, x 2 ):- x 1  x 2, app(x 1, x 2, x 3 ) :- x 1  x 3 } D 3 = D 2

7 13/07/20157 gfp calculation (under the microscope, part I) D i+1 is computed from D i by considering each clause p(x) :- d : f : p 1 (x 1 ),…, p n (x n ) in the abstract program and calculating a formula that (possibly) strengthens the call pattern Specifically, let f i denote the success pattern formula for p i (x i ) in F and let d i denote the call pattern formula for p i (x i ) in D i Compute e =  i = 1 n (d i  f i ) which captures the grounding behaviour of the compound goal p 1 (x 1 ),… p n (x n )

8 13/07/20158 gfp calculation (under the microscope, part II) Also e' =  i = 1 n d i is a groundness property sufficient for scheduling the compound goal without suspension The formula e  e' =  { f | f  e  e’} is the weakest grounding property which, if satisfied when the compound goal is called, ensures the goal can be scheduled without suspension

9 13/07/20159 gfp calculation (under the microscope, part III) Likewise g = d  (f  (e  e')) is the weakest grounding property which ensures the ask is satisfied and the body can be scheduled without suspension Variables not present in p(x), Y = {y 1,…,y n } say, are then eliminated by g' =  Y1 (...  Yn (g)) In fact  x (f) = f’ if f’ is positive else  x (f) = false where f’ = f[x  true]  f[x  false] For example  x (x  y) = y A safe calling mode for this clause is then given by g’ because  x (f)  f, hence g'  g

10 13/07/201510 Experimental work Analysis takes less than 1 second on each of the Super Monaco benchmarks with a 500MHz Pentium III Unexpected call patterns reveal buggy synchronisation The analysis appears to be practical and scalable and the analyser is available at http://www.sci.univr.it/~genaim/susweb


Download ppt "13/07/20151 A Goal-Independent Suspension Analysis for Logic Programs with Dynamic Scheduling Samir Genaim Universita’ degli Studi di Verona Italy Andy."

Similar presentations


Ads by Google