Representation of Kleene Algebra with Tests Dexter Kozen Cornell University.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Language and Automata Theory
Lecture 24 MAS 714 Hartmut Klauck
Equivalence of Extended Symbolic Finite Transducers Presented By: Loris D’Antoni Joint work with: Margus Veanes.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Predicate Transformers
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.
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
Discrete Mathematics Lecture 4 Harper Langston New York University.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Logic in Computer Science Transparency No Chapter 3 Propositional Logic 3.6. Propositional Resolution 3.7. Natural Deduction.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
מבנה המחשב + מבוא למחשבים ספרתיים תרגול 1#
Regular Expression (EXTRA)
CMSC 250 Discrete Structures Number Theory. 20 June 2007Number Theory2 Exactly one car in the plant has color H( a ) := “ a has color”  x  Cars –H(
Discrete Structures Chapter 2 Part B Mathematical Induction
1 Lecture 5 Topics –Closure Properties for REC Proofs –2 examples Applications.
CSE-221 Digital Logic Design (DLD)
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Preliminaries/ Chapter 1: Introduction. Definitions: from Abstract to Linear Algebra.
3-4 Algebra Properties Used in Geometry The properties of operations of real numbers that you used in arithmetic and algebra can be applied in geometry.
Boolean Algebra Computer Organization 1 © McQuain Boolean Algebra A Boolean algebra is a set B of values together with: -two binary operations,
Chapter 2 Languages.
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
Linear Algebra Chapter 4 Vector Spaces.
Inequalities and Proof
Intro. to Logic CS402 Fall Propositional Calculus - Semantics (2/3) Propositional Calculus - Semantics (2/3) Moonzoo Kim CS Division of EECS Dept.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
Kleene Algebra with Tests (Part 3: Theoretical Results) Dexter Kozen Cornell University Workshop on Logic & Computation Nelson, NZ, January 2004.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CSC-2259 Discrete Structures
Rational Numbers and Fields
Formal Semantics of Programming Languages 虞慧群 Topic 1: Introduction.
Laws of concurrent design Tony Hoare Microsoft ResearchCambridge FMCAD October.
Boolean Algebras Lecture 27 Section 5.3 Wed, Mar 7, 2007.
CS6133 Software Specification and Verification
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Great Theoretical Ideas in Computer Science.
CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.
Linear Algebra Chapter 2 Matrices.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Symbolic Logic The Following slide were written using materials from the Book: The Following slide were written using materials from the Book: Discrete.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Introduction to the Theory of Computation
Spring 2017 Program Analysis and Verification
Boolean Algebra A Boolean algebra is a set B of values together with:
Boolean Algebra A Boolean algebra is a set B of values together with:
Y. Davis Geometry Notes Chapter 2.
Propositional Calculus: Boolean Algebra and Simplification
Information Technology Department
CSE 370 – Winter Combinational Logic - 1
Denotational Semantics (Denotational Semantics)
Sungho Kang Yonsei University
MA/CSSE 474 More Math Review Theory of Computation
Finite-Trace Linear Temporal Logic: Coinductive Completeness
Formal Methods in software development
Predicate Transformers
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Program correctness Axiomatic semantics
Presentation transcript:

Representation of Kleene Algebra with Tests Dexter Kozen Cornell University

pq + qp p*q {pq,qp} {q,pq,p 2 q,p 3 q, …} (p + q)* = (p*q)*p* (pq)*p = p(qp)* {all strings over p,q} {p,pqp,pqpqp,  } (0 + 1(01*0)*1)* {multiples of 3 in binary} Kleene Algebra (KA) is the algebra of regular expressions p p q q p,q p q p q

Standard Interpretation Regular sets over  A+B= A  B AB= {xy | x  A, y  B} A*= U n  0 A n = A 0  A 1  A 2 ... 1= {  } 0=  p   interpreted as {p}

Binary Relations R, S binary relations on a set X R+S= R  S RS= R ° S = {(u,v) |  w (u,w)  R, (w,v)  S} R*= reflexive transitive closure of R = U n  0 R n = 1  R  R 2  R 3   1= identity relation = {(u,u) | u  X} 0= 

Applications Automata and formal languages regular expressions Relational algebra Program logic and verification Dynamic Logic program analysis optimization Design and analysis of algorithms shortest paths connectivity

Conway’s Definition A Kleene algebra is any structure (K, +, ·, *, 0, 1) satisfying the same equations as the regular sets established the equational theory as the primary theory of interest—not necessarily the best choice

Fundamental Questions Can we axiomatize the valid equations? YES [Salomaa 66] —but not equationally [Redko 64] Can we decide if expressions are equivalent? YES, PSPACE complete [(Stock+1)Meyer 74]

Axioms of KA K is an idempotent semiring under +, ·, 0, 1 (p + q) + r = p + (q + r) (pq)r = p(qr) p + q = q + pp1 = 1p = p p + p = pp0 = 0p = 0 p + 0 = p p(q + r) = pq + pr (p + q)r = pr + qr p*q = least x such that q + px  x qp* = least x such that q + xp  x def x  y  x + y = y

This is a universal Horn axiomatization p*q = least x such that q + px  x q + p(p*q)  p*q q + px  x  p*q  x qp* = least x such that q + xp  x q + p(qp*)  qp* q + px  x  qp*  x Every system of linear inequalities a 11 x a n1 x n + b 1  x 1. a n1 x a nn x n + b n  x n has a unique least solution

Alternative Characterizations of * Complete semirings (quantales)  i  I p i = supremum of {p i | i  I} with respect to  *-continuity pq*r = sup pq n r infinitary same equational theory Eq(KA) = Eq(KA*) n  0

1 + pp* = 1 + p*p = p* p*p* = p** = p* (pq)*p = p(qp)* sliding (p*q)*p* = (p + q)* denesting px = xq  p*x = xq*bisimulation qp = 0  (p + q)* = p*q*loop distribution Some Useful Properties

Proof of the Sliding Rule (ab)*a  a(ba)* a + aba(ba)*= a(1 + ba(ba)*)distributivity = a(ba)*1 + pp* = p*. a + aba(ba)*  a(ba)* (ab)*a  a(ba)*q + px  x  p*q  x The reverse inequality  is symmetric.

Equational Completeness [K91] Reg , the KA regular sets over , is the free KA on generators  p  q as regular sets  p = q is a consequence of the KA axioms KA is complete over relational models Eq(REL) = Eq(KA) = Eq(Reg  )

Matrices over a KA a b c d a+e b+f c+g d+h e f g h + = def a b c d ae+bg af+bh ce+dg cf+dh e f g h · = def = def = a b c d (a+bd*c)* (a+bd*c)*bd* (d+ca*b)*ca* (d+ca*b)* * = def

Matrices over a KA a b c d (a+bd*c)* (a+bd*c)*bd* (d+ca*b)*ca* (d+ca*b)* * = def a d c b

Representation of finite automata Construction of regular expressions Solution of linear equations over a KA Connectivity and shortest path algorithms Matrices over a KA

Solution of Linear Inequalities a 11 x a n1 x n + b 1  x 1. a n1 x a nn x n + b n  x n a a n1.. + . a n1... a nn b1...bnb1...bn x1...xnx1...xn x1...xnx1...xn

Shortest Paths The min,+ algebra R +  {  } r + s= min r,s rs= r + s r*= 0 0=  1= 0  =   0.9    0.9   0 * =

Other Models Convex polyhedra [Iwano & Steiglitz 90] AB = {ax + by | x  A, y  B} A* = convex hull of A A B

(K, B, +, ·, *, ¯, 0, 1) (K, +, ·, *, 0, 1) is a Kleene algebra (B, +, ·, ¯, 0, 1) is a Boolean algebra B  K p,q,r,  range over K a,b,c,  range over B Kleene Algebra with Tests (KAT)

+, ·, 0, 1 serve double duty applied to programs, denote choice, composition, fail, and skip, resp. applied to tests, denote disjunction, conjunction, falsity, and truth, resp. these usages do not conflict! bc = b  c b + c = b  c Kleene Algebra with Tests (KAT)

Models Relational models K = binary relations on a set X B = subsets of the identity relation Trace models K = sets of traces u 0 p 0 u 1 p 1 u 2 … u n-1 p n-1 u n B = sets of traces of length 0 Language-theoretic models K = regular sets of guarded strings over  B = atoms of a finite free Boolean algebra

Guarded Strings [Kaplan 69] P atomic programsB atomic tests , ,  atoms (minimal nonzero elements) of the free Boolean algebra on generators B e.g. if B = {b 1,...,b 6 }, then b 1 b 2 b 3 b 4 b 5 b 6 is an atom guarded strings  0 p 0  1 p 1  2 p 2  3   n-1 p n-1  n A+B= A  B AB= {x  y | x   A,  y  B} A*= U n  0 A n 1= {atoms} 0= 

Theorem [Kozen & Smith 96] The family of regular sets of guarded strings over P,B is the free KAT on generators P,B. Corollary KAT is complete over relational models. Eq(GS) = Eq(KAT) = Eq(KAT*) = Eq(REL)

Matrices over a KAT The n x n matrices over a KAT (K,B) forms a KAT (K’,B’) B’ = diagonal matrices over B

Modeling Programs [Fischer & Ladner 79] p;q  pq if b then p else q  bp + bq while b do p  (bp)*b

Hoare Logic [C. A. R. Hoare 69] {b}p{c}partial correctness assertion ‘‘If b holds in the current state, and if p is executed starting in the current state, then if p halts, c will be true of the halting state.’’

{b}p{c}, {c}q{d} {b}pq{d} composition rule {bc}p{d}, {bc}q{d} {c}if b then p else q{d} conditional rule {bc}p{c} {c}while b do p{bc} while rule {b[x/e]} x:=e {b} assignment rule b’  b, {b}p{c}, c  c’ {b’}p{c’} weakening rule Rules of Hoare Logic

KAT subsumes PHL {b}p{c} modeled by bp = bpc or bpc = 0

{b}p{c}, {c}q{d} {b}pq{d} composition rule {bc}p{d}, {bc}q{d} {c}if b then p else q{d} conditional rule {bc}p{c} {c}while b do p{bc} while rule

{b}p{c}, {c}q{d} {b}pq{d} composition rule {bc}p{d}, {bc}q{d} {c}if b then p else q{d} conditional rule {bc}p{c} {c}while b do p{bc} while rule  bpc = 0  cqd = 0  bpqd = 0  bcpd = 0  bcqd = 0  c(bp+bq)d = 0  bcpc = 0  c(bp)*b bc = 0

Theorem These are all theorems of KAT Completeness Theorem [K 99] All relationally valid rules of the form are derivable in KAT (not so for PHL) {b 1 }p 1 {c 1 },..., {b n }p n {c n } {b}p{c}

Counterexample {c}if b then p else p{c} {c}p{c} is trivially unprovable in Hoare Logic, but c(bp + bp)c = 0  cpc = 0 is easily provable in KAT

Hoare formulas p 1 = 0  p 2 = 0 ...  p n = 0  q = r Theorem KAT is complete for the Hoare theory of relational algebras... not for the Horn theory! Counterexample: p  1  p 2 = p

Complexity of KAT and PHL Theorem [Cohen 94] The Hoare theory of KA (Horn formulas with premises p = 0) is PSPACE-complete Theorem [Cohen, Kozen & Smith 96] The Hoare theory of KAT is PSPACE-complete Theorem PHL is PSPACE-complete