Finite State Automata

Similar documents
Formal Language and Automata Theory (CS21004)

Finite Automata and Regular Languages

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

3515ICT: Theory of Computation. Regular languages

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Computational Models - Lecture 3 1

UNIT-III REGULAR LANGUAGES

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

Finite Automata and Languages

COMP4141 Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

DM17. Beregnelighed. Jacob Aae Mikkelsen

Computational Models - Lecture 4

CS 154, Lecture 3: DFA NFA, Regular Expressions

What we have done so far

DD2371 Automata Theory

Warshall s algorithm

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar

Introduction to Kleene Algebra Lecture 9 CS786 Spring 2004 February 23, 2004

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Finite Automata and Regular languages

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Computational Models - Lecture 3

Constructions on Finite Automata

Computational Models: Class 3

CS 208: Automata Theory and Logic

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Theory of Computation

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

Lecture 1: Finite State Automaton

2. Elements of the Theory of Computation, Lewis and Papadimitrou,

Chapter 5. Finite Automata

Sri vidya college of engineering and technology

CS 455/555: Finite automata

Automata: a short introduction

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Constructions on Finite Automata

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Regular Expressions Kleene s Theorem Equation-based alternate construction. Regular Expressions. Deepak D Souza

Lecture 17: Language Recognition

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

Computer Sciences Department

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Java II Finite Automata I

Fall 1999 Formal Language Theory Dr. R. Boyer. 1. There are other methods of nding a regular expression equivalent to a nite automaton in

Computational Models - Lecture 3 1

Computational Theory

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

Nondeterministic Finite Automata

Chapter 6. Properties of Regular Languages

Inf2A: Converting from NFAs to DFAs and Closure Properties

Lecture 3: Nondeterministic Finite Automata

CS 275 Automata and Formal Language Theory

Nondeterministic Finite Automata

Notes on State Minimization

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 5 : DFA minimization

Regular Expressions Kleene s Theorem Equation-based alternate construction. Regular Expressions. Deepak D Souza

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

TDDD65 Introduction to the Theory of Computation

Theory of Computation 4 Non-Deterministic Finite Automata

Inf2A: The Pumping Lemma

Uses of finite automata

Closure under the Regular Operations

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Regular Language Equivalence and DFA Minimization. Equivalence of Two Regular Languages DFA Minimization

Theory of Computation 3 Deterministic Finite Automata

Extended transition function of a DFA

Finite-State Machines (Automata) lecture 12

Constructive Formalization of Regular Languages

Finite-state Machines: Theory and Applications

Formal Models in NLP

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Regular Expression Unit 1 chapter 3. Unit 1: Chapter 3

Automata extended to nominal sets

Deterministic Finite Automata (DFAs)

Homomorphisms and Efficient State Minimization

This lecture covers Chapter 7 of HMU: Properties of CFLs

1 More finite deterministic automata

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

CSE 135: Introduction to Theory of Computation Optimal DFA

Deterministic Finite Automata (DFAs)

Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 4: More on Regexps, Non-Regular Languages

Finite Universes. L is a fixed-length language if it has length n for some

NOTES ON AUTOMATA. Date: April 29,

Theory of computation: initial remarks (Chapter 11)

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Classes and conversions

CSE 105 THEORY OF COMPUTATION

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Introduction to Formal Languages, Automata and Computability p.1/51

Transcription:

Trento 2005 p. 1/4 Finite State Automata Automata: Theory and Practice Paritosh K. Pandya (TIFR, Mumbai, India) Unversity of Trento 10-24 May 2005

Trento 2005 p. 2/4 Finite Word Langauges Alphabet Σ is collection of symbols (letters). E.g. Σ = {a,b}. Finite word is a finite sequence of letters. E.g. aabb. Set of all finite words is denoted by Σ. Langauge U is a set of words, i.e. U Σ. Example: (a) Words over Σ = {a,b} with equal number of a and b. E.g. aabb or abba. Language recognition problem: To determine whether a word belongs to a language. Most computational problems can be encoded as language recognition problem. Automata are computational devices to solve langauge recognition problems.

Trento 2005 p. 3/4 Finite State Automata Basic model of computational systems with finite memory. Widely applicable Embedded System Controllers. Languages: Esterel, Lustre, Verilog, SMV. Synchronous Circuits. Regular Expression Pattern Matching Grep, Lex, Perl, Awk, Emacs. Protocols Network Protocols Architecture: Bus, Cache Coherence... Mobile Telephony. Good decision procedures

Trento 2005 p. 4/4 Topics DFA, NFA and Equivalence Closure Properties and Decision Problems Regular Expressions and McNaughton Yamada Lemma Homomorphisms DFA minization Pumping Lemma Myhill Nerode Theorem Bisimulation and collapsing nondeterministic automta Textbook: Dexter Kozen, Automata and Computability. Springer, 1997.

Trento 2005 p. 5/4 Notation a,b Σ finite alphabet. u,v,w Σ finite words. ǫ empty word. u.v catenation. u i = u.u..u repeated i-times. U,V Σ Finite word languages. For a set S we use 2 S to denote all its subsets. 2 S def = {X X S}.

Trento 2005 p. 6/4 Deterministic Finite State Automaton Example: DFA A 1 over Σ = {a,b}. a b b s 1 s 2 a

Trento 2005 p. 6/4 Deterministic Finite State Automaton Example: DFA A 1 over Σ = {a,b}. a b b s 1 s 1 s 2 a The run of A 1 over the word abba is : a b b a s 1 s 2 s 2 s 1. For a given word the run is unique.

Trento 2005 p. 6/4 Deterministic Finite State Automaton Example: DFA A 1 over Σ = {a,b}. a b b s 1 s 1 s 2 a The run of A 1 over the word abba is : a b b a s 1 s 2 s 2 s 1. For a given word the run is unique. Recognises words which do not end in b.

Trento 2005 p. 7/4 DFA Definition DFA is (Q, Σ,δ,I,F) Q Finite set of states. Σ is the finite alphabet. q 0 Q the initial states. F Q set of final states. δ : Q Σ Q, transition function (total). Notation: We use q a q to denote δ(q,a) = q. A run of DFA A on u = a 0,a 1,...,a n 1 is a sequence of a states q 0,q 1,...,q n s.t. q i i qi+1 for 0 i < n. For a given word w the DFA has a unique run. A run accepting if last state q n F.

Trento 2005 p. 8/4 Regular Langauges Language accepted by A L(A) = {u Σ A has an accepting run on u}. A langauge accepted by a DFA is called a regular language.

Trento 2005 p. 8/4 Regular Langauges Language accepted by A L(A) = {u Σ A has an accepting run on u}. A langauge accepted by a DFA is called a regular language. Define ˆδ(q,u) inductively over u Σ. ˆδ(q,ǫ) = q, ˆδ(q,ua) = δ(ˆδ(q,u),a). For X Q define ˆδ(X,u) def = q X ˆδ(q,u).

Trento 2005 p. 9/4 Nondeterministic FSA NFA A 2. a,b b s 1 s b 2

Trento 2005 p. 9/4 Nondeterministic FSA NFA A 2. a,b b s 1 s b 2 A run of A 2 over the word abbb is: a b b b s 1 s 1 s 2 s 2. s 1 Another run over the same word abbb is: a b b b s 1 s 1 s 1 s 1. s 1 A 2 has no accepting run over the word aba as: a b a s 1 s 2 s 1 NFA can have 0, 1 or more than one runs on a given word.

Trento 2005 p. 9/4 Nondeterministic FSA NFA A 2 recognises words which end in b. a,b b s 1 s b 2 A run of A 2 over the word abbb is: a b b b s 1 s 1 s 2 s 2. s 1 Another run over the same word abbb is: a b b b s 1 s 1 s 1 s 1. s 1 A 2 has no accepting run over the word aba as: a b a s 1 s 2 s 1 NFA can have 0, 1 or more than one runs on a given word.

Trento 2005 p. 10/4 NFA Definition Nodeterministic Finite State Automaton: NFA is (Q, Σ,δ,I,F) Q Finite set of states. I Q set of initial states. F Q set of final states. δ Q Σ Q transition relation (edges). a We use q q to denote (q,a,q ) δ. Alternate Definition of δ δ : Q Σ 2 Q. Exercise: Given that Q = n and Σ = k, give the number of syntactically distinct NFAs.

Trento 2005 p. 11/4 NFA Runs A run of NFA A on u = a 0,a 1,...,a n 1 is a sequence of a states q 0,q 1,...,q n s.t. q i i qi+1 for 0 i < n and q 0 I. For a given word w the NFA can have many runs. A run accepting if last state q n F. Language accepted by A is L(A) = {u Σ A has an accepting run on u}.

Trento 2005 p. 11/4 NFA Runs A run of NFA A on u = a 0,a 1,...,a n 1 is a sequence of a states q 0,q 1,...,q n s.t. q i i qi+1 for 0 i < n and q 0 I. For a given word w the NFA can have many runs. A run accepting if last state q n F. Language accepted by A is L(A) = {u Σ A has an accepting run on u}. Define ˆδ(S,w) inductively on w as follows. ˆδ(S,a) = s S δ(s,a) ˆδ(S,ǫ) = S, ˆδ(S,wa) = ˆδ(ˆδ(S,w),a). Claim x L(A) ˆδ(I,x) F

Trento 2005 p. 12/4 Subset Construction Theorem (determinisation) Given NFA A = (Q, Σ,δ,I,F) we can construct a DFA A s.t. L(A) = L(A ).

Trento 2005 p. 12/4 Subset Construction Theorem (determinisation) Given NFA A = (Q, Σ,δ,I,F) we can construct a DFA A s.t. L(A) = L(A ). Subset construction: 0,1 p q 1 0,1 Consider ˆδ(I,w) the set of states reached after word w. We define (S, a). 0 1 {p} {p} {p,q} {p,q} {p,r} {p,q,r} {p,r} {p} {p,q} {p,q,r} {p,r} {p,q,r} r

Trento 2005 p. 13/4 Subset Construction (cont) Let A = (2 Q, Σ,,I,F ) where (S,a) = {q q δ(p,a) p S} F = {S 2 Q S F }. Claim: L(A) = L(A ). Proof Method: Show that ˆδ(S,w) = ˆ (S,w). Complexity A 2 A. Lower Bound Example: Consider NFA recognising words over {0, 1} such that the n-th last symbol is 1. Claim: Equivalent DFA will have at least 2 n states. (Home Exercise: Prove this.)

Trento 2005 p. 14/4 Closure Properties Theorem (boolean closure) Given NFA A 1,A 2 over Σ we can construct NFA A over Σ s.t. L(A) = L(A 1 ) (Complement). Size: A = 2 A 1. L(A) = L(A 1 ) L(A 2 ) (union). Size: A = A 1 + A 2. L(A) = L(A 1 ) L(A 2 ) (intersection). A = A 1 A 2.

Trento 2005 p. 15/4 Synchronous Product: Example s 0 a b b b b a a a s 1 a t 2 t 0 b t 1 A 1 recognises words with even number of b. A 2 recognises words with number of a mod 3 = 0. The Product Automaton A 1 A 2 with F = {s 0,t 0 }. s 0 a a a t s 0 t 1 2 s 0 t 0 b b b b s 1 t 2 s 1 t 0 a a a b b s 1 t 1

Trento 2005 p. 16/4 Synchronous Product Construction Let A 1 = (Q 1, Σ,δ 1,I 1,F 1 ) and A 2 = (Q 2, Σ,δ 2,I 2,F 2 ). Then, A 1 A 2 = (Q, Σ,δ,I,F) where Q = Q 1 Q 2. I = I 1 I 2. F = F 1 F 2. < p,q > a < p,q > iff p a p and q Theorem L(A 1 A 2 ) = L(A 1 ) L(A 2 ). a q. Semantics of many concurrent systems E.g. Esterel, Statecharts, Lustre, Synchronous circuits, SMV.

Trento 2005 p. 17/4 Synchronised Product Construction Let A 1 = (Q 1, Σ 1,δ 1,I 1,F 1 ) and A 2 = (Q 2, Σ 2,δ 2,I 2,F 2 ). Then, A 1 A 2 = (Q, Σ,δ,I,F) where Q = Q 1 Q 2. Σ = Σ 1 Σ 2. I = I 1 I 2. F = F 1 F 2. < p,q > < a p,q > if a Σ 1 Σ 2 and p a p and a q q. < p,q > a < p,q > if a Σ 1, a Σ 2 and p a p. < p,q > a < p,q > if a Σ 1, a Σ 2 and q a q.

Trento 2005 p. 18/4 Asynchronous Product Construction Let A 1 = (Q 1, Σ 1,δ 1,I 1,F 1 ) and A 2 = (Q 2, Σ 2,δ 2,I 2,F 2 ). Then, A 1 A A 2 = (Q, Σ,δ,I,F) where Q = Q 1 Q 2. Σ = Σ 1 Σ 2. I = I 1 I 2. F = F 1 F 2. < p,q > a < p,q > if a Σ 1 and p a p. < p,q > a < p,q > if a Σ 2 and q a q.

Trento 2005 p. 19/4 Decision Problems Theorem (Emptiness) Given NFA A we can decide whether L(A) =. Method Forward/Backward Reachability in Automaton graph using say Depth First Search. Complexity is O( Q + δ ). In practice, symbolic techniques are used and often more effective. Theorem (Language Containment) Given NFA A 1 and A 2 we can decide whether L(A 1 ) L(A 2 ). Method: L(A 1 ) L(A 2 ) iff L(A 1 ) L(A 2 ) =. Complexity is O( A 1 2 A 2 ).

Trento 2005 p. 20/4 Kleene Closure Let U,V Σ. (Catenation) Let U V def = {x y x U y V }. (Iteration) Let U i def = {x 1 x 2... x i x k U, 1 k < i}. By convention U 0 def = {ǫ}. (Kleene Closure) Let U def = 0 i U i. Theorem Regular langauges are closed under the operations U V and U V and U. Proof method: Using ǫ-nfa.

Trento 2005 p. 21/4 Regular Expressions Syntax: ǫ a reg 1.reg 2 reg 1 + reg 2 reg.

Trento 2005 p. 21/4 Regular Expressions Syntax: ǫ a reg 1.reg 2 reg 1 + reg 2 reg. Language L(reg) is defined inductively: L( ) =, L(a) = {a}, L(ǫ) = {ǫ}. L(re 1 re 2 ) = L(re 1 ) L(re 2 ), L(re 1 + re 2 ) = L(re 1 ) L(re 2 ), L(re ) = (L(re 1 )) Example: a.(b + bb).a. Words over a,b having either 1 b or 2 consecutive b.

Trento 2005 p. 21/4 Regular Expressions Syntax: ǫ a reg 1.reg 2 reg 1 + reg 2 reg. Language L(reg) is defined inductively: L( ) =, L(a) = {a}, L(ǫ) = {ǫ}. L(re 1 re 2 ) = L(re 1 ) L(re 2 ), L(re 1 + re 2 ) = L(re 1 ) L(re 2 ), L(re ) = (L(re 1 )) Example: a.(b + bb).a. Words over a,b having either 1 b or 2 consecutive b. Equivalence of RegExp and FSA (McNaughton, Yamada) Theorem: For every regular expression reg we can construct a language equivalent ǫ-nfa of size O( reg ).

Trento 2005 p. 22/4 Automata to RegExp Theorem: For every NFA A = (Q, Σ,δ,I,F) we can construct a langauge equivalent regular expression reg(a).

Trento 2005 p. 22/4 Automata to RegExp Theorem: For every NFA A = (Q, Σ,δ,I,F) we can construct a langauge equivalent regular expression reg(a). Construction Define regular expression α X p,q for X Q and p,q Q. This denotes set of words w such that A has a run on w from p to q where all intermediate states are from X.

Trento 2005 p. 22/4 Automata to RegExp Theorem: For every NFA A = (Q, Σ,δ,I,F) we can construct a langauge equivalent regular expression reg(a). Construction Define regular expression α X p,q for X Q and p,q Q. This denotes set of words w such that A has a run on w from p to q where all intermediate states are from X. 0 1 1 q 0 Example: p 0 r α q p,r = 10 α p,q p,r = 0 1 0 Aim: To compute α p,q,r p,p

Trento 2005 p. 23/4 Automata to RegExp (2) α X p,r can be recursively defined using the following rules: α p,r = a 1 +... + a k where r δ(p,a i ) provided p r

Trento 2005 p. 23/4 Automata to RegExp (2) α X p,r can be recursively defined using the following rules: α p,r α p,p = a 1 +... + a k where r δ(p,a i ) = a 1 +... + a k + ǫ where p δ(p,a i ) provided p r

Trento 2005 p. 23/4 Automata to RegExp (2) α X p,r can be recursively defined using the following rules: α p,r α p,p = a 1 +... + a k where r δ(p,a i ) = a 1 +... + a k + ǫ where p δ(p,a i ) For any q X, α X p,r = α (X {q}) p,r + α (X {q}) p,q provided p r ( α (X {q}) q,q ) α (X {q}) q,r

Trento 2005 p. 23/4 Automata to RegExp (2) α X p,r can be recursively defined using the following rules: α p,r α p,p = a 1 +... + a k where r δ(p,a i ) = a 1 +... + a k + ǫ where p δ(p,a i ) For any q X, α X p,r = α (X {q}) p,r + α (X {q}) p,q provided p r ( α (X {q}) q,q ) α (X {q}) q,r The desired regular expression is given as follows: p I q F αq p,q.

Trento 2005 p. 24/4 Example Compute α p,q,r p,p α p,q,r p,p as It is easy to see that αp,p p,r = 0, αq,p p,r = 00(0 ), 0 p 1 0 q 1 0 = α p,r p,p + α p,r p,q (α p,r q,q) α p,r q,p. α p,r r p,q = 0 1 αq,q p,r = ǫ + 01 + 00(0 )1 Hence α p,q,r p,p = 0 + 0 1 (ǫ + 01 + 00(0 )1) 00(0 )

Trento 2005 p. 25/4 Kleene Algebra Axiomatizing equivalence of regular expression. Not covered in this course. (See Kozen.)

Trento 2005 p. 26/4 Homomorphism Homomorphism is a map h : Σ Γ with the property u,v Σ. h(u v) = h(u) h(v). Consequences: h(ǫ) = ǫ. Giving h(a) for a Σ uniquely determines h.

Trento 2005 p. 26/4 Homomorphism Homomorphism is a map h : Σ Γ with the property u,v Σ. h(u v) = h(u) h(v). Consequences: h(ǫ) = ǫ. Giving h(a) for a Σ uniquely determines h. Theorem If h : Σ Γ is a homomorphism and B Γ is regular then h 1 (B) = {x Σ h(x) B} is also regular.

Trento 2005 p. 26/4 Homomorphism Homomorphism is a map h : Σ Γ with the property u,v Σ. h(u v) = h(u) h(v). Consequences: h(ǫ) = ǫ. Giving h(a) for a Σ uniquely determines h. Theorem If h : Σ Γ is a homomorphism and B Γ is regular then h 1 (B) = {x Σ h(x) B} is also regular. Proof method: Given DFA BB = (Q, Γ,δ,q 0,F) for B construct DFA AA for h 1 (B) as follows. AA def = (Q, Σ,δ,q 0,F) with δ (q,a) = ˆδ(q,h(a)).

Trento 2005 p. 27/4 Homomorphism (2) Theorem If h : Σ Γ is a homomorphism and A Σ is regular then h(a) = {h(x) x A} is also regular.

Trento 2005 p. 27/4 Homomorphism (2) Theorem If h : Σ Γ is a homomorphism and A Σ is regular then h(a) = {h(x) x A} is also regular. Proof method: Given regular epxression re for A, obtain h(re) by substituting every letter a by h(a). Then L(h(re)) = h(a).

Trento 2005 p. 27/4 Homomorphism (2) Theorem If h : Σ Γ is a homomorphism and A Σ is regular then h(a) = {h(x) x A} is also regular. Proof method: Given regular epxression re for A, obtain h(re) by substituting every letter a by h(a). Then L(h(re)) = h(a). Theorem (projection) Given NFA(A 1 ) over Σ and surjection h : Σ Γ, we can construct NFA(A 2 ) over Γ s.t. L(A 2 ) = h(l(a 1 )). Proof Method: Substitute label a by h(a) in each transition of A 1 to get A 2. Note that this can make DFA into NFA. We have A 2 = A 1.

Trento 2005 p. 27/4 Homomorphism (2) Theorem If h : Σ Γ is a homomorphism and A Σ is regular then h(a) = {h(x) x A} is also regular. Proof method: Given regular epxression re for A, obtain h(re) by substituting every letter a by h(a). Then L(h(re)) = h(a). Theorem (projection) Given NFA(A 1 ) over Σ and surjection h : Σ Γ, we can construct NFA(A 2 ) over Γ s.t. L(A 2 ) = h(l(a 1 )). Proof Method: Substitute label a by h(a) in each transition of A 1 to get A 2. Note that this can make DFA into NFA. We have A 2 = A 1. Example: Given regular A over {0, 1} the language hamming 3 (A) is regular.

Trento 2005 p. 28/4 DFA Minimization 0 a b 1 2 a b b a 3 4 a,b a,b 5 a,b

Trento 2005 p. 28/4 DFA Minimization 0 a b 1 2 a b b a 3 4 a,b a,b 5 a,b

Trento 2005 p. 28/4 DFA Minimization 0 a b 1 2 a b b a 3 4 a,b a,b 5 a,b p q def = x Σ. (ˆδ(p,x) F ˆδ(q,x) F)

Trento 2005 p. 28/4 DFA Minimization 0 a b 1 2 a b b a 3 4 a,b a,b 5 a,b p q def = x Σ. (ˆδ(p,x) F ˆδ(q,x) F) Equivalent Automaton a,b 6 7 a,b 8 a,b

Trento 2005 p. 29/4 DFA Minimization (2) p q def = x Σ. (ˆδ(p,x) F ˆδ(q,x) F)

Trento 2005 p. 29/4 DFA Minimization (2) p q def = x Σ. (ˆδ(p,x) F ˆδ(q,x) F) Proposition is an equivalence relation, i.e. (a) p. p p, (b) p,q. p q q p (c) p,q,r. p q q r p r (Exercise: Check that above properties are true.)

Trento 2005 p. 29/4 DFA Minimization (2) p q def = x Σ. (ˆδ(p,x) F ˆδ(q,x) F) Proposition is an equivalence relation, i.e. (a) p. p p, (b) p,q. p q q p (c) p,q,r. p q q r p r (Exercise: Check that above properties are true.) partitions Q into equivalence classes. Let [p] denote the equivalence class of p. Example The classes are {0}, {1, 2} and {3, 4, 5}.

Trento 2005 p. 30/4 Quotient Automaton Given DFA A = (Q, Σ,δ, [q 0 ],F) and as before, the Quotient automaton is A/ def = (Q, Σ,δ, [q 0 ],F ), where Q = {[p] p Q} δ ([p],a) = [δ(p,a)] F = {[f] f F }

Trento 2005 p. 30/4 Quotient Automaton Given DFA A = (Q, Σ,δ, [q 0 ],F) and as before, the Quotient automaton is A/ def = (Q, Σ,δ, [q 0 ],F ), where Q = {[p] p Q} δ ([p],a) = [δ(p,a)] F = {[f] f F } Well-formedness Theorem(Congruence) p q a Σ. δ(p,a) δ(q,a).

Trento 2005 p. 30/4 Quotient Automaton Given DFA A = (Q, Σ,δ, [q 0 ],F) and as before, the Quotient automaton is A/ def = (Q, Σ,δ, [q 0 ],F ), where Q = {[p] p Q} δ ([p],a) = [δ(p,a)] F = {[f] f F } Well-formedness Theorem(Congruence) p q a Σ. δ(p,a) δ(q,a). Now we can show that quotient automaton recognises the same language. Theorem ˆδ ([p],w) = [ˆδ(p,w)]. Corollary L(A/ ) = L(A).

Trento 2005 p. 31/4 Minimization algorithm 1. Make pairs table with (p,q) Q Q and p < q. 2. Mark (p,q) if p F q / F or vice versa. 3. Repeat following steps until no change occurs. (a) Pick unmarked state (p, q). (b) If (δ(p,a),δ(q,a)) is marked for some a Σ then mark (p,q)

Trento 2005 p. 31/4 Minimization algorithm 1. Make pairs table with (p,q) Q Q and p < q. 2. Mark (p,q) if p F q / F or vice versa. 3. Repeat following steps until no change occurs. (a) Pick unmarked state (p, q). (b) If (δ(p,a),δ(q,a)) is marked for some a Σ then mark (p,q) Termination: In each pass at least one new pair must get marked. Lemma (p,q) is marked iff x Σ.ˆδ(p,x) F ˆδ(q,x) / F or vice versa.

Trento 2005 p. 31/4 Minimization algorithm 1. Make pairs table with (p,q) Q Q and p < q. 2. Mark (p,q) if p F q / F or vice versa. 3. Repeat following steps until no change occurs. (a) Pick unmarked state (p, q). (b) If (δ(p,a),δ(q,a)) is marked for some a Σ then mark (p,q) Termination: In each pass at least one new pair must get marked. Lemma (p,q) is marked iff x Σ.ˆδ(p,x) F ˆδ(q,x) / F or vice versa. Question: Can there be a DFA smaller than A/ equivalent to A?

Trento 2005 p. 32/4 Pumping Lemma Idea: Consider a long word recognized by a DFA with n states. Consider substring y s.t. y n. Some state during y part of the run must repeat. The string between repeating states can be pumped.

Trento 2005 p. 32/4 Pumping Lemma Idea: Consider a long word recognized by a DFA with n states. Consider substring y s.t. y n. Some state during y part of the run must repeat. The string between repeating states can be pumped. Lemma For every regular language L n > 0 such that x,y,z with x y z L and y n u,v,w s.t. y = u v w with v > 0 and x u v i w z L for all 0 i.

Trento 2005 p. 32/4 Pumping Lemma Idea: Consider a long word recognized by a DFA with n states. Consider substring y s.t. y n. Some state during y part of the run must repeat. The string between repeating states can be pumped. Lemma For every regular language L n > 0 such that x,y,z with x y z L and y n u,v,w s.t. y = u v w with v > 0 and x u v i w z L for all 0 i. Pumping Lemma is used to prove that some langugages are not regular. E.g. {a 2n n 0}.

Trento 2005 p. 33/4 Proving non-regularity Game with Demon Demon claims L is regular and chooses n. You choose a string xyz L with y n. Demon partitions y = uvw with v 0. You show that xu(v i )wz / L for some i for your choice.

Trento 2005 p. 34/4 Myhill-Nerode Relations Let be an equivalence relation over Σ. is right congruent if x,y Σ, a Σ we have x y x a y a

Trento 2005 p. 34/4 Myhill-Nerode Relations Let be an equivalence relation over Σ. is right congruent if x,y Σ, a Σ we have x y x a y a Let R Σ (not necessarily regular). refines R if x,y Σ x y (x R y R)

Trento 2005 p. 34/4 Myhill-Nerode Relations Let be an equivalence relation over Σ. is right congruent if x,y Σ, a Σ we have x y x a y a Let R Σ (not necessarily regular). refines R if x,y Σ x y (x R y R) is of finite index if partitions the Σ into only finitely many equivalence classes.

Trento 2005 p. 34/4 Myhill-Nerode Relations Let be an equivalence relation over Σ. is right congruent if x,y Σ, a Σ we have x y x a y a Let R Σ (not necessarily regular). refines R if x,y Σ x y (x R y R) is of finite index if partitions the Σ into only finitely many equivalence classes. Equivalence relation is called Myhill-Nerode Relation refining R if it satisfies all the three properties above.

Trento 2005 p. 35/4 Machine Equivalence Given a DFA A = (Q, Σ,δ,q 0,F) define the induced equivalence A over Σ as follows: def x A y = ˆδ(q 0,x) = ˆδ(q 0,y).

Trento 2005 p. 35/4 Machine Equivalence Given a DFA A = (Q, Σ,δ,q 0,F) define the induced equivalence A over Σ as follows: def x A y = ˆδ(q 0,x) = ˆδ(q 0,y). Proposition A is a Myhill-Nerode relation refining L(A). Proof Method Check the following: (a) A is an equivalence relation over Σ. (b) x A y a. xa A ya. (c) x A y x L(A) y L(A) (d) A is of finite index.

Trento 2005 p. 35/4 Machine Equivalence Given a DFA A = (Q, Σ,δ,q 0,F) define the induced equivalence A over Σ as follows: def x A y = ˆδ(q 0,x) = ˆδ(q 0,y). Proposition A is a Myhill-Nerode relation refining L(A). Proof Method Check the following: (a) A is an equivalence relation over Σ. (b) x A y a. xa A ya. (c) x A y x L(A) y L(A) (d) A is of finite index. Example: We give automaton A and the induced equivalence partitions.

Trento 2005 p. 36/4 From Equivalence to DFA Let be Myhill-Nerode refining R. Define DFA A def = (Q, Σ,δ,q 0,F) as follows: Q def = {[x] x Σ } def q 0 = [ǫ] F def = {[x] x R} δ([x],a]) def = [xa]. (Check well-formedness.)

Trento 2005 p. 36/4 From Equivalence to DFA Let be Myhill-Nerode refining R. Define DFA A def = (Q, Σ,δ,q 0,F) as follows: Q def = {[x] x Σ } def q 0 = [ǫ] F def = {[x] x R} δ([x],a]) def = [xa]. (Check well-formedness.) Theorem L(A ) = R. Lemma ˆδ([x],y) = [xy].

Trento 2005 p. 37/4 Correspondence The A and A are inverses of each other. Theorem A =. Theorem If A is automaton without unreachable states then A A is isomorphic to A.

Trento 2005 p. 38/4 Language Induced Equivalence An equivalence relation 1 refines equivalence relation 2 provided x 1 y x 2 y (Set theoretically, 1 2.) Intuitively, 1 makes finer partitions than 2.

Trento 2005 p. 38/4 Language Induced Equivalence An equivalence relation 1 refines equivalence relation 2 provided x 1 y x 2 y (Set theoretically, 1 2.) Intuitively, 1 makes finer partitions than 2. Definition (Language Induced Equivalence) Given R Σ, def x R y = z Σ. (xz R yz R).

Trento 2005 p. 38/4 Language Induced Equivalence An equivalence relation 1 refines equivalence relation 2 provided x 1 y x 2 y (Set theoretically, 1 2.) Intuitively, 1 makes finer partitions than 2. Definition (Language Induced Equivalence) Given R Σ, def x R y = z Σ. (xz R yz R). Proposition R is right congruent. Proposition R refines R.

Trento 2005 p. 38/4 Language Induced Equivalence An equivalence relation 1 refines equivalence relation 2 provided x 1 y x 2 y (Set theoretically, 1 2.) Intuitively, 1 makes finer partitions than 2. Definition (Language Induced Equivalence) Given R Σ, def x R y = z Σ. (xz R yz R). Proposition R is right congruent. Proposition R refines R. Proposition(Coarseness) Let be right-congruent refining R. Then, R.

Trento 2005 p. 39/4 Myhill-Nerode Theorem Let R Σ. The following statements are equivalent. 1. R is regular 2. There exists a Myhill-Nerode relation refinining R. 3. The relation R is of finite index. The automaton A R gives the minimal DFA for R.

Trento 2005 p. 40/4 State Minimization is optimal Let A recognise R. Consider the quotient automaton M = A/ as before, and assume that it has no inaccessible states. Lemma x R y x M y

Trento 2005 p. 41/4 Bisimulation Postponed to the End of course. See Kozen Supplementary Lecture B.