* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download lecture 3
Survey
Document related concepts
Transcript
Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004 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 Kripke Frames over P,B K = (K, mK) mK : P 2K K P = atomic programs mK : B 2K B = atomic tests mK specifies a canonical interpretation for P,B TP,B = {KAT terms over P,B} Traces K = (K, mK) mK : P 2K K P = atomic programs mK : B 2K B = atomic tests A trace in K is a sequence x = u0p0u1p1u2 … un-1pn-1un, n 0, (ui,ui+1) mK(pi) u0p0u1 … un-1pn-1un · unpnun+1 … um-1pm-1um = u0p0u1 … pn-1unpn … um-1pm-1um TracesK = {traces in K} ,,... denote traces Trace Algebras A,B TracesK CK A+B = A B AB = { | A, B} A* = Un0 An 1 = K 0 = C = K−C [[p]]K = {upv | (u,v) mK(p) }, p P [[b]]K = mK(b), b B extends to KAT homomorphism [[ ]]K : TP,B 2Traces(K) TrK = { [[p]]K | p TP,B} regular trace algebra of K Guarded Strings over P,B [Kaplan 69] AtomsB = {atoms of free BA on B} , , denote atoms guarded strings 0p01p12p23 n-1pn-1n join-irreducible elements of the free KAT on P,B traces in Kripke frame G = (AtomsB,mG) mG(p) = AtomsB x AtomsB mG(b) = { | b} TrG = {regular sets of guarded strings} Relation Algebras A,B K x K C idK = {(u,u) | u K} A+B = A B AB = A B A* = Un0 An 1 = idK 0 = C = idK − C [p]K = mK(p) , p P [b]K = {(u,u) | u mK(b)}, b B extends to KAT homomorphism [ ]K : TP,B 2K x K RelK = { [p]K | p TP,B} regular relation algebra of K Traces and Relations RelK is a homomorphic image of TrK Ext(A) = {(first(),last() | A} Ext : 2Traces(K) 2K x K Ext : TrK RelK Ext([[p]]K) = [p]K TrK is isomorphic to a relation algebra on TracesK Rel(A) = {(,) | TracesK, A} Thus Eq(REL) = Eq(TR) Traces and Relations g : K AtomsB g(u) = unique such that u [[]]K g : TracesK TracesG g(u0p0u1 … un-1pn-1un) = g(u0)p0g(u1) … g(un-1)pn-1g(un) g−1 : 2Traces(G) 2Traces(K) g−1(A) = {x | g(x) A} g−1 : TrG TrK g−1([[p]]G) = [[p]]K Thus TrG is universal for relational and trace algebras Automata on Guarded Strings • ordinary finite automaton on alphabet P TB • transitions labeled p P are action transitions • transitions labeled b TB are test transitions • inputs are guarded strings 0p01 n-1pn-1n 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} 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 TP,B 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 Determinization of AGS Theorem Every nondeterministic AGS is equivalent to a deterministic AGS Proof Subset construction State Minimization Theorem If all possible tests are allowed, then minimal unique deterministic AGSs exist State Minimization If only B and B = {b | b B} are allowed as tests, then minimal deterministic AGSs are not unique c c d {cd,cd} dd d d d c cc c 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 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 Representation Under what conditions is a given abstract KAT (K,B) guaranteed to be isomorphic to a relational KAT? Representation Under what conditions is a given abstract KAT (K,B) guaranteed to be isomorphic to a relational KAT? 1. (bc 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} Dynamic Model Theory Consider 1st-order KAT over a fixed signature • atomic actions = assignments x := e • atomic tests = atomic formulas R(e1,...,en) A Kripke frame is Tarskian if it arises from a first-order structure A • states = valuations of variables over A • mA(x := e) = { (u,u[x/u(e)]) | u : Var A} • mA(R(e1,...,en)) = {u | u |= R(e1,...,en)} 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) 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 Dynamic Model Theory Define the frame (U,mU) • U = {qf-types of T} • mU(x := e) = {(,{ | [x/e] }) | U} • mU (P(e1,...,en)) = { U | P(e1,...,en) } Theorem TrU 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! Dynamic Model Theory Not true for RelU ! [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) Dynamic Model Theory Theorem RelU 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 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 01 and 10 complete, respectively Corollary There is no relatively complete deductive system for scheme equivalence (or inequivalence) 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 Examples {ababca} {aaabbc, cbbaaa} {anbn | n 0} (ab)* A is letter equivalent to B every string in A has an anagram in B and vice versa Parikh Map #a(x) = number of occurrences of a in x (x) = (#a1(x),...,#an(x)) Parikh vector (A) = {(x) | x A} commutative image Examples ({ababca, cbbaaa}) = {(3,2,1)} ({anbn | n 0}) = ((ab)*) = {(n,n) | n 0} def A is letter equivalent to B (A) = (B) Parikh’s Theorem (Parikh's version) Every context-free language is letter equivalent to a regular set. 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. 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* Using (p+q)* = p*q* can show Normal Form [Pilling 73] Every expression is equivalent to y1+ ... + yn, where yi is a product of am and (a1...ak)*. Example (((ab)*c)* + d)* = d* + (ab)*c*cd* Standard Model Reg(Nn) = regular sets of Parikh vectors in Nn A+B=AB AB = {x + y | x A, y B} A* = Un0 An = A0 A1 A2 1 = {(0,...,0)} 0= ... This is the free CKA on n generators Algebraic Closure Every system of polynomial inequalities f1(x1,...,xn) x1 . . . fn(x1,...,xn) xn over a CKA K has a unique least solution in Kn. Uniform Algebraic Closure Every system of polynomial inequalities f1(x1,...,xn) x1 . . . fn(x1,...,xn) xn over a CKA K has a unique least solution in Kn. The components of the solution are given by polynomials in the coefficients of the fi. • 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 {anbn | n 0} S aSb | {balanced parens} S (S) | SS | {palindromes} axb + 1 x (x) + xx + 1 x S aSa | bSb | a | b | axa + bxb + a + b + 1 x Previously known for • Reg(Nn) [Pilling 73] • commutative -continuous semirings [Kuich 87] 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 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 Polynomials K[x,y,...] (ax + by)* 1 + (ax*b*)* + bx + cy a + xy(bxy)* K a,b,... K x,y,... variables K[x,y,...] K[x,y,...] is a CKA {x,y,...} eval K[x,y,...] is the direct sum (coproduct) of K and the free CKA on {x,y,...} L 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 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,...] Differential Operators x :K[x,...] K[x,...], where x (x) = 1 x (y) = 0, y x x (a) = 0, a K x Examples (ax2y + bxy2 + (ax)* + 1) = axy + by2 + a(ax)* x (ax2y + bxy2 + (ax)* + 1) = ax2 + bxy y Chain Rule For f, e K[x], (f(e)) = x f e (e) · x x or in more conventional notation, f(e(x)) = f(e(x)) e(x) 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 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). 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 {anbn | n 0} f(x) x f(x) f(x) f(0) f(f(0))* f(0) axb + 1 x axb + 1 ab 1 (ab)* 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) x f(x) f(x) f(0) f(f(0))* f(0) axb + x2 + 1 x axb + x2 + 1 ab + x 1 (ab + 1)* = (ab)* 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) x f(x) f(x) f(0) f(f(0))* f(0) axa + bxb + a + b + 1 x axa + bxb + a + b + 1 a2 + b2 a+b+1 (a2 + b2)* (a + b + 1) = (a2 )* (b2)* (a + b + 1) 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 (*). 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 Multivariate Taylor Theorem For x = x1,...,xn, f = f1,...,fm K[x], and e = e1,...,en, f(e) = f(0) + f (e) ·e x Multivariate Taylor Theorem For x = x1,...,xn, f = f1,...,fm K[x], and e = e1,...,en, f(e) = f(0) + f (e) ·e x Jacobian matrix f (e)ij = x fi (e) xj Multivariate Chain Rule For x = x1,...,xn, f = f1,...,fm K[x], and e = e1,...,en, (f(e)) = z e f (e) · z x Theorem Let x = x1,...,xn and f = f1,...,fn K[x]. Consider the n x n system f(x) x (**) Define a0 = ak+1 = f(0) f (ak)* ·ak x For sufficiently large finite N, aN is the least solution to (**). How bad can N be? How bad can N be? N(n) (7 ·3n - 5) / 2