Title: Kleene Algebra with Tests (Part 3: Theoretical Results)
1Kleene Algebra with Tests(Part 3 Theoretical
Results)
- Dexter Kozen
- Cornell University
- Workshop on Logic Computation
- Nelson, NZ, January 2004
2These Lectures
- Tutorial on KA and KAT
- model theory
- complexity, deductive completeness
- relation to Hoare logic
- Practical applications
- compiler optimization
- scheme equivalence
- static analysis
- Theoretical applications
- automata on guarded strings BDDs
- algebraic version of Parikhs theorem
- representation
- dynamic model theory
3Kripke 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
4Traces
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,ui1) ? mK(pi) u0p0u1
un-1pn-1un unpnun1 um-1pm-1um u0p0u1
pn-1unpn um-1pm-1um TracesK traces in
K ?,?,... denote traces
5Trace Algebras
A,B ? TracesK C ? K AB A ? B AB ?? ?
? A, ? ? B A Un?0 An 1 K 0
? C K - C pK upv (u,v)
? mK(p) , p ? P bK mK(b), b ?
B extends to KAT homomorphism K TP,B ?
2Traces(K) TrK pK p ? TP,B
regular trace algebra of K
6Guarded Strings over P,B Kaplan 69
AtomsB atoms of free BA on B ?, ?,? denote
atoms guarded strings ?0p0?1p1?2p2?3 ?
?n-1pn-1?n 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
7Relation Algebras
A,B ? K x K C ? idK (u,u) u ? K AB A
? B AB A ? B A Un?0 An 1 idK
0 ? C idK - C pK mK(p) ,
p ? P bK (u,u) u ? mK(b), b ?
B extends to KAT homomorphism K TP,B ? 2K
x K RelK pK p ? TP,B regular
relation algebra of K
8Traces and Relations
RelK is a homomorphic image of TrK Ext(A)
(first(?),last(?) ? ? A Ext 2Traces(K) ? 2K
x K Ext TrK ? RelK Ext(pK) pK TrK is
isomorphic to a relation algebra on
TracesK Rel(A) (?,??) ? ? TracesK, ? ?
A Thus Eq(REL) Eq(TR)
9Traces 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(pG) pK Thus
TrG is universal for relational and trace algebras
10Automata 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 ?0p0?1 ? ?n-1pn-1?n
11Automata 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
12Kleenes Theorem for AGS
A set of guarded strings is accepted by some AGS
over P,B iff it is pG for some p ? TP,B
13Determinization of AGS
- An AGS is deterministic if
- there is exactly one start state
- each state is either an action state (has exiting
action transitions) or a test state (has exiting
test transitions) but not both - every action state has exactly one exiting action
transition for each p ? P (exactly one enabled) - the exiting test transitions of a test state are
pairwise exclusive and exhaustive (exactly one
enabled) - every cycle contains at least one action
transition - all accept states are action states
14Determinization of AGS
Theorem Every nondeterministic AGS is
equivalent to a deterministic AGS Proof Subset
construction
15State Minimization
Theorem If all possible tests are allowed, then
minimal unique deterministic AGSs exist
16State Minimization
If only B and B b b ? B are allowed as
tests, then minimal deterministic AGSs are not
unique
cd,cd
17State 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
18Myhill-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 (xz ? A ?
yz ? A) Theorem A is regular iff ?A has
finitely many classes. The ?A-classes give the
minimal deterministic ordered AGS
19Representation
Under what conditions is a given abstract KAT
(K,B) guaranteed to be isomorphic to a relational
KAT?
20Representation
- Under what conditions is a given abstract KAT
(K,B) guaranteed to be isomorphic to a relational
KAT? - (?b?c bqc 0 ? bpc 0) ? p ? q
- 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
21Dynamic 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,ux/u(e)) u Var ? A
- mA(R(e1,...,en)) u u R(e1,...,en)
22Dynamic 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)
23Dynamic 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
24Dynamic 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 - pU qU iff pA qA for all
models A of T - Note that U itself is not Tarskian in general!
25Dynamic Model Theory
Not true for RelU ! P(c) ? P(d) x cU
P(c) ? P(d) x dU 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)
26Dynamic 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., pU qU iff p and q are
observationally equivalent over all models of T
27Complexity 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
28Parikhs 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
29Examples 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
30Parikh 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 A is letter equivalent to B ? ?(A)
?(B)
def
31Parikhs Theorem (Parikh's version) Every
context-free language is letter equivalent to a
regular set.
32Parikhs Theorem (Parikh's version) Every
context-free language is letter equivalent to a
regular set. Parikhs Theorem (our
version) Every commutative Kleene algebra is
uniformly algebraically closed.
33Commutative Kleene Algebra (CKA) xy yx A
theorem of CKA but not KA (pq) pq (?) 1
(pq)pq 1 ppqqpq 1
ppqpqq ? pq ? (pq) ? pq
34Using (pq) pq 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)ccd
35Standard Model
Reg(Nn) regular sets of Parikh vectors in Nn A
B A ? B AB x y x ? A, y ? B A Un?0
An A0 ? A1 ? A2 ? ... 1 (0,...,0) 0
? This is the free CKA on n generators
36Algebraic 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.
37Uniform 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.
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
- anbn 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(Nn) Pilling 73
- commutative ?-continuous semirings Kuich 87
40- Approach
- differential operators ?/?x on polynomials
- Taylors theorem f(xd) f(x) f?(xd)d
- closed form solution for n inequalities in n
unknowns involving the Jacobian matrix
41Polynomials Kx,y,... (ax by) 1 (axb)
bx cy a xy(bxy) a,b,... ? K x,y,...
variables Kx,y,... is a CKA
42Polynomials Kx,y,... (ax by) 1 (axb)
bx cy a xy(bxy) a,b,... ? K x,y,...
variables Kx,y,... is a CKA
Kx,y,... is the direct sum (coproduct) of K and
the free CKA on x,y,...
43- Differential Operators
- A map DK ? K is called a differential operator
if for all x,y ? K, - D(xy) Dx Dy
- D(xy) xDy yDx
- D(x) xDx
- D0 D1 0
44- Differential Operators
- A map DK ? K is called a differential operator
if for all x,y ? K, - D(xy) Dx Dy
- D(xy) xDy yDx
- D(x) xDx
- D0 D1 0
45? ?x
Differential Operators Kx,... ?
Kx,..., where Examples
46Chain Rule For f, e ? Kx, or in more
conventional notation, f(e(x))? f?(e(x)) ?
e?(x)
47Taylors Theorem For f, d ? Kx, f(xd)
f(x) f?(xd) ? d In particular, evaluating at
x 0, f(d) f(0) f?(d) ? d
48Theorem Let K be a CKA and let f(x) ? Kx. The
least solution of f(x) ? x is f?(f(0)) ? f(0).
49Theorem Let K be a CKA and let f(x) ? Kx. The
least solution of f(x) ? x is f?(f(0)) ?
f(0). Example anbn n ? 0 f(x) ? x axb 1
? x f(x) axb 1 f?(x) ab f(0) 1 f?(f(0))
? f(0) (ab)
50Theorem Let K be a CKA and let f(x) ? Kx. The
least solution of f(x) ? x is f?(f(0)) ?
f(0). Example balanced parentheses f(x) ?
x axb x2 1 ? x f(x) axb x2 1
f?(x) ab x f(0) 1 f?(f(0)) ? f(0) (ab
1) (ab)
51Theorem Let K be a CKA and let f(x) ? Kx. The
least solution of f(x) ? x is f?(f(0)) ?
f(0). Example palindromes f(x) ? x axa
bxb a b 1 ? x f(x) axa bxb a b 1
f?(x) a2 b2 f(0) a b 1 f?(f(0)) ?
f(0) (a2 b2) (a b 1) (a2 ) (b2)
(a b 1)
52The 2 x 2 Case f(x,y) ? x g(x,y) ?
y Viewing Kx,y as Kxy, solve g(x,y) ? y
over Kx. 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 ().
()
53The 2 x 2 Case f(x,y) ? x g(x,y) ?
y Viewing Kx,y as Kxy, solve g(x,y) ? y
over Kx. 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
()
54Multivariate Taylor Theorem For x
x1,...,xn, f f1,...,fm ? Kx, and e
e1,...,en,
55Multivariate Taylor Theorem For x
x1,...,xn, f f1,...,fm ? Kx, and e
e1,...,en,
Jacobian matrix
56Multivariate Chain Rule For x x1,...,xn, f
f1,...,fm ? Kx, and e e1,...,en,
57Theorem Let x x1,...,xn and f f1,...,fn ?
Kx. Consider the n x n system f(x) ? x
() Define For sufficiently large
finite N, aN is the least solution to ().
a0 f(0) ak1 (ak) ak
? f ? x
58How bad can N be?
59How bad can N be? N(n) ? (7 3n - 5) / 2