Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Similar documents
Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular expressions, Finite Automata, transition graphs are all the same!!

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Finite-State Automata: Recap

Java II Finite Automata I

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Minimal DFA. minimal DFA for L starting from any other

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Non-deterministic Finite Automata

Fundamentals of Computer Science

Lecture 9: LTL and Büchi Automata

Deterministic Finite Automata

Theory of Computation Regular Languages

CMSC 330: Organization of Programming Languages

Harvard University Computer Science 121 Midterm October 23, 2012

Designing finite automata II

Non-deterministic Finite Automata

3 Regular expressions

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

NFAs continued, Closure Properties of Regular Languages

Formal languages, automata, and theory of computation

Lecture 08: Feb. 08, 2019

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

1 Nondeterministic Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Lexical Analysis Finite Automate

Finite Automata-cont d

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CISC 4090 Theory of Computation

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Formal Language and Automata Theory (CS21004)

CHAPTER 1 Regular Languages. Contents

Chapter 2 Finite Automata

NFAs continued, Closure Properties of Regular Languages

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Convert the NFA into DFA

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

FABER Formal Languages, Automata and Models of Computation

Nondeterminism and Nodeterministic Automata

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

CS 267: Automated Verification. Lecture 8: Automata Theoretic Model Checking. Instructor: Tevfik Bultan

First Midterm Examination

Formal Methods in Software Engineering

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Formal Languages and Automata

ɛ-closure, Kleene s Theorem,

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Introduction to ω-autamata

Worked out examples Finite Automata

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

On Determinisation of History-Deterministic Automata.

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

More on automata. Michael George. March 24 April 7, 2014

First Midterm Examination

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Let's start with an example:

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Software Engineering using Formal Methods

Coalgebra, Lecture 15: Equations for Deterministic Automata

State Minimization for DFAs

Closure Properties of Regular Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

CS375: Logic and Theory of Computing

Thoery of Automata CS402

Tutorial Automata and formal Languages

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CS375: Logic and Theory of Computing

Closure Properties of Regular Languages

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

1.3 Regular Expressions

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

Lecture 09: Myhill-Nerode Theorem

1 From NFA to regular expression

1.4 Nonregular Languages

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

More general families of infinite graphs

Lexical Analysis Part III

CSC 311 Theory of Computation

Context-Free Grammars and Languages

CS 275 Automata and Formal Language Theory

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Nondeterministic Biautomata and Their Descriptional Complexity

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

GNFA GNFA GNFA GNFA GNFA

Languages & Automata

Deterministic Finite-State Automata

Homework 3 Solutions

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

Transcription:

Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent lecture on Automtentheorie nd Formle Sprchen. Introduction Session 1 2006 Rlf Huuck 4 Session 1 2006 Rlf Huuck 3 1

Bsics Why words? Bsic ojects in mthemtics numer (numer theory, nlysis) shpes (geometry) sets nd trnsformtion on such ojects Bsic ojects in computer science words stet of words (lnguge) nd their trnsformtions defining nd descriing words Every IT system is out dt nd trnsformtion of dt 10101010100000101010111110 word from lphet {0,1} progrm is lso just finite word every terminting execution is finite word progrmming lnguge is the set of ll permissile words (i.e., ccepted progrms) Automt nd Grmmrs re ll out ccepting/generting words nd defining lnguge. Session 1 2006 Rlf Huuck 5 Session 1 2006 Rlf Huuck 6 Automton s o s 1 finl/ccepting stte Finite Automt defines lnguge of ll words over lphet {,} with n odd numer of s. Session 1 2006 Rlf Huuck 8 Session 1 2006 Rlf Huuck 7 2

Words & Lnguges Opertions on Words An lphet is non-empty set of symols/letters. Σ = {0,1} Σ lt = {, z,a,,z} A word is sequence of symols from n lphet 01111010 Σ * hello Σ * lt A lnguge is the set of ll possile words Σ * (ll finite Boolen words) Σ * lt (ll finite words of ltin chrcters) A grmmr/utomton restricts to meningful lnguges Conctention of words: u= 1 m nd v= 1 n (m,n 0) u v = 1 m 1 n Note: empty word, word of length 0, ut not u = u= u We often write uv insted of u v. ll 8-it words ll English words Session 1 2006 Rlf Huuck 9 Session 1 2006 Rlf Huuck 10 Opertions on Lnguges Kleene Str Conctention of lnguges K nd L: K L = {uv Σ * u K, v L} Exmple: K={follow, me} L={follow, you} K L= {followfollow, meyou, followyou} Iterting lnguge L L 0 ={} L 1 =L L 2 =L L L n+1 =L n L Kleene str: L * =U n 0 L n Exmple: {,} * = {,,,,,,,, } ll finite sequences over {,}. Session 1 2006 Rlf Huuck 11 Session 1 2006 Rlf Huuck 12 3

Deterministic vs Non-Deterministic Definition DFA, A DFA is of the form Deterministic Finite Automton (DFA) from every stte every symol leds to unique stte To model lgorithms. Non-deterministic Finite Automton (NFA) from stte the sme symol might led t o different sttes or no stte To model systems or environment. A=(S,Σ,s 0,δ,F) where S finite set of sttes Σ lphet s 0 initil stte δ : S Σ S trnsition function F S set of finl sttes Session 1 2006 Rlf Huuck 13 Session 1 2006 Rlf Huuck 14 Accepting Run of DFA Lnguge of DFA A run over word w= 0,, n (n 0) of n DFA is sequence of sttes q 0,, q n+1 such tht q 0 = s 0 nd δ (q i, i )=q i+1 (0 i n) The lnguge ccepted y DAF A is L(A) = {w Σ * δ (s 0,w) F } A lnguge K is clled DFA ccepting if there is DFA such tht L(A)=K. We lso write δ (q 0,w)=q n+1. Two DFAs A nd B re equivlent of L(A)=L(B). A run is ccepting iff q n+1 F. Session 1 2006 Rlf Huuck 15 Session 1 2006 Rlf Huuck 16 4

Definition NFA Accepting Run of NFA A NFA is of the form A=(S,Σ,s 0,Δ,F) where S finite set of sttes Σ lphet s 0 initil stte Δ :S Σ S trnsition reltion F S set of finl sttes no longer function, A run over word w= 0,, n (n 0) of n NFA is sequence of sttes, q 0,, q n+1 such tht s q 0 = s 0 nd 0 s 1 (q i, i,q i+1 ) Δ (0 i n) We lso write q 0 w q n+1. A run is ccepting iff q n+1 F. Session 1 2006 Rlf Huuck 17 Session 1 2006 Rlf Huuck 18 Lnguge of NFA Question The lnguge ccepted y NFA A is L(A) = {w Σ * s 0 w s nd s F } A lnguge K is clled NFA ccepting if there is NFA such tht L(A)=K. Is there lnguge tht is either DFA or n NFA ccepting, ut not oth? Two NFAs A nd B re equivlent of L(A)=L(B). Session 1 2006 Rlf Huuck 19 Session 1 2006 Rlf Huuck 20 5

Answer: No Ide: NFA to DFA Clim: L DFA ccepting L NFA ccepting, NFA DFA Proof: L DFA ccepting L NFA ccepting esy: every DFA is in prticulr n NFA, just relx δ to e reltion L NFA ccepting L DFA ccepting slightly hrder, ide see next slide Power set construction {s 0 } {s 0, s 1 } stte spce power set keep initil stte for every symol nd stte hve trnsition to the exct rechle suset ll sttes which contin finl stte re finl sttes {s 1 } {}, Session 1 2006 Rlf Huuck 21 Session 1 2006 Rlf Huuck 22 Definition Power Set Automton Proof NFA DFA Given NFA A=(S,Σ,s 0,Δ,F). Define power set DFA A =(S,Σ,s 0,δ,F ) s follows: S := 2 S s 0 := {s o } δ (P,) ={q S there is p P : (p,,q) Δ} F := {P S P F } Lemm: We show A nd A re equivlent y showing A: s 0 w s iff s δ({s 0 },w) Proof: A: s 0 w s iff s Rech A (w) iff s δ({s 0 },w). rechle sttes for w This implies: A: s 0 w s with s F iff s δ({s 0 },w) F Hence: A is w ccepting iff A is w ccepting. Session 1 2006 Rlf Huuck 23 Session 1 2006 Rlf Huuck 24 6

Another Wy of Defining Lnguge Regulr Expression Exmple ll words strting with 1 or 3 s followed y possile sequence of s followed y t lest 1 Regulr Expression ( + ) ( ) * * Brckets nd conctention symols re sometimes omitted when cler from the context. Session 1 2006 Rlf Huuck 25 Session 1 2006 Rlf Huuck 26 RE Syntx RE Semntics Definition: The set of regulr expressions RE Σ over Σ = { 1,, n } is defined inductively y: Bse elements:,, 1,, n Constructors: if r nd s re regulr expression so re (r+s), (r s), nd r * Alterntively this cn e defined in terms of BNF grmmr. We define lnguge L(r) Σ * (set of words) for every regulr expression r RE Σ s follows: L : RE Σ 2Σ is defined inductively: 1. L( )=, L()={}, L( i )={ i } 2. L(r+s) = L(r) + L(s) L(r s) = L(r) L(s) L(r * ) =(L(r)) * A lnguge is regulr if it is definle y regulr expression. Session 1 2006 Rlf Huuck 27 Session 1 2006 Rlf Huuck 28 7

Regulr Expressions in UNIX Question [ 1, 2,, n ] insted of 1 + 2 + + n. insted of Σ (ny letter) insted of + r? insted of + r r+ insted of r * r r{4} insted of rrrr Is there lnguge tht cn e expressed either y n NFA/DFA or n RE ut not oth? Session 1 2006 Rlf Huuck 29 Session 1 2006 Rlf Huuck 30 Answer RE to NFA: Thompson Construction Kleene s Theorem who lso rught us the Kleene lger, the Kleene str, Kleene's recursion theorem nd the Kleene fixpoint theorem For every RE there is n equivlent NFA nd for every NFA there is n equivlent RE. Induction Bse cse r= : define A r s cse r=: define A r s We give the proof (sketch) y ) presenting n inductive construction from RE to NFA nd ) the ide of trnsformtion lgorithm from NFA to RE cse r= ( Σ): define A r s Session 1 2006 Rlf Huuck 31 Session 1 2006 Rlf Huuck 32 8

RE to NFA: Thompson Construction Ide: NFA to RE Induction Step cse r+s: define A r + A s s cse r s: define A r A s s A r A r A s A s Clim: For every NFA we cn construct n equivlent RE. Proof (ide): Crete RE from trnsition lels of NFA. There is grph trnsformtion lgorithm tht does exctly this. It is know s the elimintion lgorithm. cse r * : define A r* s A r Session 1 2006 Rlf Huuck 33 Session 1 2006 Rlf Huuck 34 Exmple Closure Properties, Product Automton Strt trnsform to + + (+) * If K,L Σ * regulr then K L, K L nd K comp := Σ * \Kregulr. E.g.:K L cn e otined y synchronous product utomton A : For NFA A k =(S k,σ,s 0k,Δ k,f k ) for K nd A L =(S L,Σ,s 0L,Δ L,F L ) for L we define: A := (S k S L,Σ,(s 0k,s 0L ),Δ,F) where ((s k,s l ),,(s k,s l )) Δ iff (s k,,s k ) Δ k nd (s L,,s L ) Δ L F := F k F L Ide: Run A k, A L in prllel nd only ccept if oth ccept. Session 1 2006 Rlf Huuck 35 Session 1 2006 Rlf Huuck 36 9

Exmple Synchronized Product A synchronized product on NFAs A 1 =(S 1,Σ 0 Σ 1,s 01,Δ 1,F 1 ), A 2 =(S 2,Σ 0 Σ 2,s 02,Δ,F 2 2 ) with disjoint Σ 0, Σ 1, Σ 2 is defined y: A sync := (S 1 S 2,Σ,(s 01,s 02 ),Δ,F) where ((s 1,s 2 ),,(s 1,s 2 )) Δ iff Σ 1, (s 1,,s 1 ) Δ 1, s 2 =s 2 or Σ 2, (s 2,,s 2 ) Δ 2, s 1 =s 1 or Σ 0, (s 1,,s 1 ) Δ 1 nd (s 2,,s 2 ) Δ 2 F := F 1 F 2 Mens: A 1, A 2 cn move independently on Σ 1, Σ 2, ut must synchronize on Σ 0 Session 1 2006 Rlf Huuck 37 Session 1 2006 Rlf Huuck 38 Exmple Good To Knows For ny NFAs A,B: emptiness prolem: L(A)=? infinity prolem: Is L(A) infinite? inclusion prolem: L(A) L(B)? equivlence prolem: L(A)=L(B)? re ll decidle. Session 1 2006 Rlf Huuck 39 Session 1 2006 Rlf Huuck 40 10

Model Checking s Inclusion Prolem Model Checking s Inclusion Prolem Model Checking Prolem: M ² φ? System stisfies property? Specil cse: NFA A stisfies RE B Solving y: Trnsform RE B in NFA nd check if L(A) L(B) which is checking: L(A) (Σ * \ L(B))= Session 1 2006 Rlf Huuck 41 Model Checking Prolem: M ² φ? System stisfies property? Typicl: Model checking is not only concerned out finite runs ut lso infinite, e.g., for non-terminting processes. This requires more powerful frmeworks: ω Automt insted of NFAs, temporl logic insted of RE. Session 1 2006 Rlf Huuck 42 Something to Rememer Progrmmer Regulr expressions powerful for pttern mtching Implement regulr expressions with finite stte mchines. exmple: lexer ω Automt Theoreticin Regulr expression is compct description of set DFA is n strct mchine tht solves pttern mtch equivlence DFA/NFA nd regulr expressions model checking s inclusion prolem Session 1 2006 Rlf Huuck 44 Session 1 2006 Rlf Huuck 43 11

From Finite to Infinite Systems Buchi Automt So fr: DFA/NFA nd regulr expressions define finite systems terminting progrms, lgorithms etc. Now: infinite systems, i.e., systems with infinite runs non-terminting progrms, operting systems, etc. Infinite words re clled ω words nd the utomt generting them ω utomt. A (non-deterministic) Buchi utomton Σ, S, s 0, Δ,F Σ is finite lphet S is finite set of sttes s 0 Q is suset of initil sttes Δ: Q Σ Q is trnsition reltion F S is suset of ccepting sttes For n infinite run r let Inf(r) = { s s=s i for infinitely mny i }. A run r of Buchi utomton is ccepting iff Inf(r) F, i.e., some finl stte occurs infinitely often. Session 1 2006 Rlf Huuck 45 Session 1 2006 Rlf Huuck 46 Exmple ω regulr Lnguges c s 2 An ω word hs finite prefix from s 0 to s nd then revisits s infinitely often. r 1 = s 2 s 2 s 2 s 2 r 2 = s 2 s 1 s 2 s 1 r 3 = s 2 s 1 s 1 s 1 ACCEPTED ACCEPTED REJECTED For utomton A, if U s is the regulr set of ll finite words s 0 to s nd V s the regulr set of ll finite revisits. An ω word is α=uv 0 v 1 where u U s, v i V s, i 0 We write α U s V ω s. The ω regulr lnguge of A is L ω (A)=U s F U s V ω s. A lnguge is ω regulr iff Buchi recognizle. Session 1 2006 Rlf Huuck 47 Session 1 2006 Rlf Huuck 48 12

Other ω Automt Equivlence There re different types of ω-utomt. They typiclly only differ in their cceptnce conditions. Buchi: Inf(r) F, Muller: F F Inf(r)=F for F 2 S (must mtch one set) Rin: n i=1 (Inf(r) E i = nd Inf(r) F i ) for E i,f i S nd cceptnce set {(E 1,F 1 ),,(E n,f n )}, i.e., ll sttes of E i only visited finitely often, ut some sttes of F i infinitely Street: n i=1 (Inf(r) E i nd Inf(r) F i = ) for E i,f i S nd cceptnce set {(E 1,F 1 ),,(E n,f n )} (dul to Rin) For non-deterministic ω-utomt the following re equivlent (recognize the sme lnguge): Buchi Muller Rin Street Session 1 2006 Rlf Huuck 49 Session 1 2006 Rlf Huuck 50 McNughton s Theorem Conclusion McNughton s Theorem: Buchi cn e trnsformed into equivlent deterministic Muller. From its proof (Sfr s construction) follows: non-deterministic Buchi Muller (deterministic/non-deterministic) Street (deterministic/non-deterministic) Rin (deterministic/non-deterministic) deterministic Muller, deterministic Rin, deterministic Street nd non-deterministic Buchi Session 1 2006 Rlf Huuck 51 Session 1 2006 Rlf Huuck 52 13

Product of Buchi Automt Product of Buchi Automt A 1 A 2 A 1 A 2 r 1 r 2 s 1 s 2 r 1 r 2 s 1 s 2 L(A 1 )={ ω } L(A 2 )={ ω } L(A 1 )={ ω } L(A 2 )={ ω } The product using the sme construction s for NFAs: The product A 1 A 2 A 1 A 2 Copy 0 Copy 1 Copy 2 (r 1,s 1 ) (r 2,s 1 ) (r 1,s 2 ) (r 2,s 2 ) Does not work! As oviously L(A 1 A 2 )= L(A 1 )=L(A 1 )= { ω } (r 1,s 1 ) (r 2,s 1 ) (r 1,s 2 ) (r 2,s 2 ) (r 1,s 1 ) (r 2,s 1 ) (r 1,s 2 ) (r 2,s 2 ) (r 1,s 1 ) (r 2,s 1 ) (r 1,s 2 ) (r 2,s 2 ) Session 1 2006 Rlf Huuck 53 Session 1 2006 Rlf Huuck 54 Product of Buchi Automt Product of Buchi Automt A 1 A 2 A 1 A 2 r 1 r 2 s 1 s 2 r 1 r 2 s 1 s 2 L(A 1 )={ ω } L(A 2 )={ ω } L(A 1 )={ ω } L(A 2 )={ ω } The product A 1 A 2 The product A 1 A 2 Copy 0 Copy 1 Copy 2 (r 1,s 1 ) (r 2,s 1 ) (r 1,s 1 ) (r 2,s 1 ) (r 1,s 1 ) (r 2,s 1 ) (r 1,s 1 ) (r 1,s 1 ) (r 1,s 2 ) (r 2,s 2 ) (r 1,s 2 ) (r 2,s 2 ) (r 1,s 2 ) (r 2,s 2 ) (r 2,s 2 ) (r 2,s 2 ) Session 1 2006 Rlf Huuck 55 Session 1 2006 Rlf Huuck 56 14

Product of Buchi Automt Lessons Lerned Strtegy multiply the product utomton y 3 (S = S 1 S 2 {0,1,2} ) 0 copy initil sttes, 2 copy finl sttes trnsition reltion like norml product utomton, ut redirect rcs such tht trnsition to the 1 copy if in 0 copy nd visiting finl stte from A 1 trnsition to the 2 copy if in 1 copy nd visiting finl stte from A 2, ll trnsitions from 2 copy led to 0 copy DFA vsnfa regulr vs DFA/NFA product of NFAs (intersection of lnguges) ω utomt product of ω utomt The product of A 1, A 2 gives us the intersection of their two lnguges. Session 1 2006 Rlf Huuck 57 Session 1 2006 Rlf Huuck 58 Next Lecture Model Checking Prolem: M ² φ? System stisfies property? Hve nice lnguge to specify φ: use temporl logic. Session 1 2006 Rlf Huuck 59 15