Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004.

Similar presentations


Presentation on theme: "Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004."— Presentation transcript:

1 Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004

2 These Lectures 1.Tutorial on KA and KAT model theory complexity, deductive completeness relation to Hoare logic 2.Practical applications compiler optimization scheme equivalence static analysis 3.Theoretical applications automata on guarded strings & BDDs algebraic version of Parikh’s theorem representation dynamic model theory

3 Kripke Frames over P,B K = (K, m K ) m K : P  2 K  K P = atomic programs m K : B  2 K B = atomic tests m K specifies a canonical interpretation for P,B T P,B = {KAT terms over P,B}

4 Traces K = (K, m K ) m K : P  2 K  K P = atomic programs m K : B  2 K B = atomic tests A trace in K is a sequence x = u 0 p 0 u 1 p 1 u 2 … u n-1 p n-1 u n, n  0, (u i,u i+1 )  m K (p i ) u 0 p 0 u 1 … u n-1 p n-1 u n · u n p n u n+1 … u m-1 p m-1 u m = u 0 p 0 u 1 … p n-1 u n p n … u m-1 p m-1 u m Traces K = {traces in K} , ,... denote traces

5 Trace Algebras A,B  Traces K C  K A+B = A  BAB = {  |   A,   B} A* = U n  0 A n 1 = K 0 =  C = K − C [[p]] K = {upv | (u,v)  m K (p) }, p  P [[b]] K = m K (b), b  B extends to KAT homomorphism [[ ]] K : T P,B  2 Traces(K) Tr K = { [[p]] K | p  T P,B } regular trace algebra of K

6 Guarded Strings over P,B [Kaplan 69] Atoms B = {atoms of free BA on B} , ,  denote atoms guarded strings  0 p 0  1 p 1  2 p 2  3   n-1 p n-1  n join-irreducible elements of the free KAT on P,B traces in Kripke frame G = (Atoms B,m G ) m G (p) = Atoms B x Atoms B m G (b) = {  |   b} Tr G = {regular sets of guarded strings}

7 Relation Algebras A,B  K x KC  id K = {(u,u) | u  K} A+B = A  BAB = A  B A* = U n  0 A n 1 = id K 0 =  C = id K − C [p] K = m K (p), p  P [b] K = {(u,u) | u  m K (b)}, b  B extends to KAT homomorphism [ ] K : T P,B  2 K x K Rel K = { [p] K | p  T P,B } regular relation algebra of K

8 Traces and Relations Rel K is a homomorphic image of Tr K Ext(A) = {(first(  ),last(  ) |   A} Ext : 2 Traces(K)  2 K x K Ext : Tr K  Rel K Ext([[p]] K ) = [p] K Tr K is isomorphic to a relation algebra on Traces K Rel(A) = {( ,  ) |   Traces K,   A} Thus Eq(REL) = Eq(TR)

9 Traces and Relations g : K  Atoms B g(u) = unique  such that u  [[  ]] K g : Traces K  Traces G g(u 0 p 0 u 1 … u n-1 p n-1 u n ) = g(u 0 )p 0 g(u 1 ) … g(u n-1 )p n-1 g(u n ) g −1 : 2 Traces(G)  2 Traces(K) g −1 (A) = {x | g(x)  A} g −1 : Tr G  Tr K g −1 ([[p]] G ) = [[p]] K Thus Tr G is universal for relational and trace algebras

10 Automata on Guarded Strings ordinary finite automaton on alphabet P  T B transitions labeled p  P are action transitions transitions labeled b  T B are test transitions inputs are guarded strings  0 p 0  1   n-1 p n-1  n

11 Automata on Guarded Strings read head always points to an atom, initially  0 an action transition with label p is enabled if p is the next action symbol in x; advance the head past p a test transition with label b is enabled if   b, where  is the current atom in x; do not advance the head accept if occupying an accept state while scanning  n ordinary NFA with  -transitions is an AGS with B = {0,1}

12 Kleene’s Theorem for AGS A set of guarded strings is accepted by some AGS over P,B iff it is [[p]] G for some p  T P,B

13 Determinization of AGS An AGS is deterministic if 1.there is exactly one start state 2.each state is either an action state (has exiting action transitions) or a test state (has exiting test transitions) but not both 3.every action state has exactly one exiting action transition for each p  P (exactly one enabled) 4.the exiting test transitions of a test state are pairwise exclusive and exhaustive (exactly one enabled) 5.every cycle contains at least one action transition 6.all accept states are action states

14 Determinization of AGS Theorem Every nondeterministic AGS is equivalent to a deterministic AGS Proof Subset construction

15 State Minimization Theorem If all possible tests are allowed, then minimal unique deterministic AGSs exist

16 State Minimization If only B and B = {b | b  B} are allowed as tests, then minimal deterministic AGSs are not unique c c ddd d d d ccc c {cd,cd}

17 State Minimization Theorem If only B and B = {b | b  B} are allowed as tests, and if the elements of B and B must be tested in some fixed order, then unique minimal deterministic AGSs exist Special case unique minimal ordered BDDs

18 Myhill-Nerode Theorem for AGS One can define an overlay operation ^ on prefixes of guarded strings Given a set A of guarded strings, define x  A y   z (x^z  A  y^z  A) Theorem A is regular iff  A has finitely many classes. The  A -classes give the minimal deterministic ordered AGS

19 Representation Under what conditions is a given abstract KAT (K,B) guaranteed to be isomorphic to a relational KAT?

20 Representation Under what conditions is a given abstract KAT (K,B) guaranteed to be isomorphic to a relational KAT? 1. (  b  c bqc = 0  bpc = 0)  p  q 2. pq = 0   b pb = 0  bq = 0 Theorem These conditions, together with *-continuity, are sufficient for nonstandard representation Proof states = ultrafilters of B p’ = {(u,v) |  b  u  c  v bpc  0}

21 Dynamic Model Theory Consider 1 st -order KAT over a fixed signature atomic actions = assignments x := e atomic tests = atomic formulas R(e 1,...,e n ) A Kripke frame is Tarskian if it arises from a first-order structure A states = valuations of variables over A m A (x := e) = { (u,u[x/u(e)]) | u : Var  A} m A (R(e 1,...,e n )) = {u | u = R(e 1,...,e n )} |

22 Dynamic Model Theory Obs The equational theories of relation and trace algebras of Tarskian frames do not coincide x := 1; y := 2 and y := 2; x := 1 are equivalent in the relation algebra but not in the trace algebra Question Can we find algebras that are universal for the Tarskian trace and relation algebras? (i.e., that play the same role as the regular sets of guarded strings for KAT)

23 Dynamic Model Theory Let T be a first-order theory A quantifier-free type (qf-type) is a maximal consistent set of quantifier-free formulas A qf-type of T is a qf-type consistent with T qf-types correspond to atoms in the guarded string model

24 Dynamic Model Theory Define the frame (U,m U ) U = {qf-types of T} m U (x := e) = {( ,{  |  [x/e]   }) |   U} m U (P(e 1,...,e n )) = {   U | P(e 1,...,e n )   } Theorem Tr U is universal for the equational theory of Tarskian trace algebras over models of T: [[p]] U = [[q]] U iff [[p]] A = [[q]] A for all models A of T Note that U itself is not Tarskian in general!

25 Dynamic Model Theory Not true for Rel U ! [P(c)  P(d) ; x := c] U = [P(c)  P(d) ; x := d] U but these two programs are not equivalent in any Tarskian frame in which c  d However they are observationally equivalent (indistinguishable by any formulas in the language)

26 Dynamic Model Theory Theorem Rel U is universal for the equational theory of relation algebras of Tarskian frames over models of T modulo observational equivalence; i.e., [p] U = [q] U iff p and q are observationally equivalent over all models of T

27 Complexity of Scheme Halting and Equivalence Theorem Let T be a recursive qf-theory. The scheme halting and scheme equivalence problem over models of T are  1 and  1 complete, respectively Corollary There is no relatively complete deductive system for scheme equivalence (or inequivalence) 0 0

28 Parikh’s Theorem [Parikh 66] Every context-free language is letter equivalent to a regular set Letter equivalence: just count occurrences of letters in strings, ignore order

29 Examples {ababca}  {aaabbc, cbbaaa} {a n b n | n  0}  (ab)* A is letter equivalent to B  every string in A has an anagram in B and vice versa

30 Parikh Map  #a(x) = number of occurrences of a in x  (x) = (#a 1 (x),...,#a n (x)) Parikh vector  (A) = {  (x) | x  A} commutative image Examples  ({ababca, cbbaaa}) = {(3,2,1)}  ({a n b n | n  0}) =  ((ab)*) = {(n,n) | n  0} A is letter equivalent to B   (A) =  (B) def

31 Parikh’s Theorem (Parikh's version) Every context-free language is letter equivalent to a regular set.

32 Parikh’s Theorem (Parikh's version) Every context-free language is letter equivalent to a regular set. Parikh’s Theorem (our version) Every commutative Kleene algebra is uniformly algebraically closed.

33 Commutative Kleene Algebra (CKA) xy = yx A theorem of CKA but not KA (p+q)* = p*q* (  ) 1 + (p+q)p*q*= 1 + pp*q*+qp*q* = 1 + pp*q*+p*qq*  p*q*  (p+q)*  p*q*

34 Using (p+q)* = p*q* can show Normal Form [Pilling 73] Every expression is equivalent to y 1 +... + y n, where y i is a product of a m and (a 1...a k )*. Example (((ab)*c)* + d)* = d* + (ab)*c*cd*

35 Standard Model Reg(N n ) = regular sets of Parikh vectors in N n A + B = A  B AB = {x + y | x  A, y  B} A* = U n  0 A n = A 0  A 1  A 2 ... 1 = {(0,...,0)} 0 =  This is the free CKA on n generators

36 Algebraic Closure Every system of polynomial inequalities f 1 (x 1,...,x n )  x 1. f n (x 1,...,x n )  x n over a CKA K has a unique least solution in K n.

37 Uniform Algebraic Closure Every system of polynomial inequalities f 1 (x 1,...,x n )  x 1. f n (x 1,...,x n )  x n over a CKA K has a unique least solution in K n. The components of the solution are given by polynomials in the coefficients of the f i.

38 A context-free grammar is just a system of polynomial inequalities over the KA  (  *) The associated context-free language is its least solution in  (  *) Commutativity models letter equivalence Examples {a n b n | n  0}S  aSb |  axb + 1  x {balanced parens}S  (S) | SS |  (x) + xx + 1  x {palindromes}S  aSa | bSb | a | b |  axa + bxb + a + b + 1  x

39 Previously known for Reg(N n ) [Pilling 73] commutative  -continuous semirings [Kuich 87]

40 Approach differential operators  /  x on polynomials Taylor’s theorem f(x+d) = f(x) + f(x+d)d closed form solution for n inequalities in n unknowns involving the Jacobian matrix

41 Polynomials K[x,y,...] (ax + by)* 1 + (ax*b*)* + bx + cy a + xy(bxy)* a,b,...  K x,y,... variables K[x,y,...] is a CKA

42 Polynomials K[x,y,...] (ax + by)* 1 + (ax*b*)* + bx + cy a + xy(bxy)* a,b,...  K x,y,... variables K[x,y,...] is a CKA K K[x,y,...] {x,y,...} L eval K[x,y,...] is the direct sum (coproduct) of K and the free CKA on {x,y,...}

43 Differential Operators A map D:K  K is called a differential operator if for all x,y  K, D(x+y) = Dx + Dy D(xy) = xDy + yDx D(x*) = x*Dx D0 = D1 = 0

44 Differential Operators A map D:K  K is called a differential operator if for all x,y  K, D(x+y) = Dx + Dy D(xy) = xDy + yDx D(x*) = x*Dx D0 = D1 = 0 K K[x,y,...] {x,y,...} K[x,y,...]

45 Differential Operators :K[x,...]  K[x,...], where Examples xx xx (y) = 0, y  x xx (a) = 0, a  K xx (x) = 1 xx (ax 2 y + bxy 2 + (ax)* + 1) = axy + by 2 + a(ax)* yy (ax 2 y + bxy 2 + (ax)* + 1) = ax 2 + bxy xx

46 Chain Rule For f, e  K[x], or in more conventional notation, f(e(x)) = f(e(x))  e(x)  f  x  e  x   x (f(e)) = (e) ·

47 Taylor’s Theorem For f, d  K[x], f(x+d) = f(x) + f(x+d)  d In particular, evaluating at x = 0, f(d) = f(0) + f(d)  d

48 Theorem Let K be a CKA and let f(x)  K[x]. The least solution of f(x)  x is f(f(0))*  f(0).

49 Theorem Let K be a CKA and let f(x)  K[x]. The least solution of f(x)  x is f(f(0))*  f(0). Example {a n b n | n  0} f(x)  xaxb + 1  x f(x)axb + 1 f(x)ab f(0)1 f(f(0))*  f(0)(ab)*

50 Theorem Let K be a CKA and let f(x)  K[x]. The least solution of f(x)  x is f(f(0))*  f(0). Example {balanced parentheses} f(x)  xaxb + x 2 + 1  x f(x)axb + x 2 + 1 f(x)ab + x f(0)1 f(f(0))*  f(0)(ab + 1)* = (ab)*

51 Theorem Let K be a CKA and let f(x)  K[x]. The least solution of f(x)  x is f(f(0))*  f(0). Example {palindromes} f(x)  xaxa + bxb + a + b + 1  x f(x)axa + bxb + a + b + 1 f(x)a 2 + b 2 f(0)a + b + 1 f(f(0))*  f(0)(a 2 + b 2 )* (a + b + 1) = (a 2 )* (b 2 )* (a + b + 1)

52 The 2 x 2 Case f(x,y)  x g(x,y)  y Viewing K[x,y] as K[x][y], solve g(x,y)  y over K[x]. Say the solution is h(x). Then solve f(x,h(x))  x over K. Say the solution is a. Then (a,h(a)) is the least solution of (*). (*)

53 The 2 x 2 Case f(x,y)  x g(x,y)  y Viewing K[x,y] as K[x][y], solve g(x,y)  y over K[x]. Say the solution is h(x). Then solve f(x,h(x))  x over K. Say the solution is a. Then (a,h(a)) is the least solution of (*). Need uniformity: the expression f(f(0))*  f(0) gives the least solution uniformly in all homomorphic images (*)

54 Multivariate Taylor Theorem For x = x 1,...,x n, f = f 1,...,f m  K[ x ], and e = e 1,...,e n, f ( e )= f ( 0 ) + ( e ) · e  f x f x

55 Multivariate Taylor Theorem For x = x 1,...,x n, f = f 1,...,f m  K[ x ], and e = e 1,...,e n, f ( e )= f ( 0 ) + ( e ) · e  f x f x  f x f x  f i  x j ( e ) ij = ( e ) Jacobian matrix

56 Multivariate Chain Rule For x = x 1,...,x n, f = f 1,...,f m  K[ x ], and e = e 1,...,e n, ( f ( e ))= ( e ) ·  f x f x   z  e  z

57 Theorem Let x = x 1,...,x n and f = f 1,...,f n  K[ x ]. Consider the n x n system f ( x )  x (**) Define For sufficiently large finite N, a N is the least solution to (**). a 0 = f ( 0 ) a k+1 = ( a k )* · a k  f x f x

58 How bad can N be?

59 N(n)  (7 ·3 n - 5) / 2


Download ppt "Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004."

Similar presentations


Ads by Google