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

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Automata Theory Part 1: Introduction & NFA November 2002.
Language and Automata Theory
4b Lexical analysis Finite Automata
Chapter 5 Pushdown Automata
Lecture 24 MAS 714 Hartmut Klauck
CPSC Compiler Tutorial 4 Midterm Review. Deterministic Finite Automata (DFA) Q: finite set of states Σ: finite set of “letters” (input alphabet)
Theory Of Automata By Dr. MM Alam
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
CS5371 Theory of Computation
Representation of Kleene Algebra with Tests Dexter Kozen Cornell University.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Functional Design and Programming Lecture 10: Regular expressions and finite state machines.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski.
Regular Expression (EXTRA)
Transparency No. P2C1-1 Formal Language and Automata Theory Part II Pushdown Automata and Context-Free Languages.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Topics Automata Theory Grammars and Languages Complexities
Lattice and Boolean Algebra
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Scanner Front End The purpose of the front end is to deal with the input language Perform a membership test: code  source language? Is the.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Math 3121 Abstract Algebra I Lecture 3 Sections 2-4: Binary Operations, Definition of Group.
Systems of Linear Equation and Matrices
Finite-State Machines with No Output Longin Jan Latecki Temple University Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch Costas Busch.
Finite-State Machines with No Output
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Boolean Algebra and Digital Circuits
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
THEORY OF COMPUTATION 08 KLEENE’S THEOREM.
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Introduction to CS Theory
Lexical Analysis Constructing a Scanner from Regular Expressions.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
 Regular Grammar and Regular Language [Def 3.1] Regular Grammar(use to in lexical analysis) Type 3 grammar(regular grammar, RG) Type 3 grammar(regular.
CHAPTER 1 Regular Languages
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
CS 203: Introduction to Formal Languages and Automata
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Modeling Computation: Finite State Machines without Output
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Deterministic Finite Automata Nondeterministic Finite Automata.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
CIS Automata and Formal Languages – Pei Wang
Formal Methods in software development
REGULAR LANGUAGES AND REGULAR GRAMMARS
Hierarchy of languages
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Non-Deterministic Finite Automata
Nondeterministic Finite Automata
Formal Methods in software development
Finite-State Machines with No Output
Presentation 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, 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}

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

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

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}

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

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)

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

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

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  T P,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 ddd d d d ccc c {cd,cd}

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. (  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}

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 )} |

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,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!

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)

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

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

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} {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

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

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 y y n, where y i is a product of a m and (a 1...a k )*. Example (((ab)*c)* + d)* = d* + (ab)*c*cd*

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

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.

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.

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

Previously known for Reg(N n ) [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)* 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,...}

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 :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

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) ·

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 {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)*

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  x f(x)axb + x f(x)ab + x f(0)1 f(f(0))*  f(0)(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)  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)

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 = 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

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

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

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

How bad can N be?

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