Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Similar documents
Automata and Formal Languages - CM0081 Finite Automata and Regular Expressions

Automata and Formal Languages - CM0081 Determinist Finite Automata

Automata and Formal Languages - CM0081 Algebraic Laws for Regular Expressions

Extended transition function of a DFA

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Chapter Five: Nondeterministic Finite Automata

Nondeterministic Finite Automata

Nondeterministic Finite Automata. Nondeterminism Subset Construction

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

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Chapter 6: NFA Applications

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Theory of Computation

Lecture 1: Finite State Automaton

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

Nondeterministic Finite Automata

Formal Models in NLP

CS 208: Automata Theory and Logic

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Theory of Computation (I) Yijia Chen Fudan University

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D )

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Deterministic Finite Automata

3515ICT: Theory of Computation. Regular languages

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Computational Models Lecture 2 1

CS 154 Formal Languages and Computability Assignment #2 Solutions

Chap. 2 Finite Automata

Automata and Languages

Computational Models - Lecture 1 1

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,

Sri vidya college of engineering and technology

Inf2A: Converting from NFAs to DFAs and Closure Properties

What we have done so far

Computational Models Lecture 2 1

CS 121, Section 2. Week of September 16, 2013

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

Course 4 Finite Automata/Finite State Machines

Finite Automata and Languages

Nondeterministic Finite Automata

Nondeterministic Finite Automata

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Lecture 3: Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Homomorphisms and Efficient State Minimization

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Finite Automata and Regular Languages (part III)

Nondeterminism and Epsilon Transitions

CS 154, Lecture 3: DFA NFA, Regular Expressions

CSC236 Week 10. Larry Zhang

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Chapter 5. Finite Automata

Constructions on Finite Automata

CS 275 Automata and Formal Language Theory

CS 455/555: Finite automata

September 7, Formal Definition of a Nondeterministic Finite Automaton

Lecture 4 Nondeterministic Finite Accepters

Equivalence of DFAs and NFAs

Computational Models #1

Topics COSC Administrivia. Topics Today. Administrivia (II) Acknowledgements. Slides presented May 9th and 16th,

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

C2.1 Regular Grammars

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

arxiv:cs/ v1 [cs.cc] 9 Feb 2007

C2.1 Regular Grammars

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

Intro to Theory of Computation

CS243, Logic and Computation Nondeterministic finite automata

Finite Automata and Regular Languages

CMSC 330: Organization of Programming Languages

Introduction to Finite-State Automata

Non-Deterministic Finite Automata

Lecture 5: Minimizing DFAs

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

Decision, Computation and Language

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CSC236 Week 11. Larry Zhang

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

Closure under the Regular Operations

COMP4141 Theory of Computation

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

Classes and conversions

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

Constructions on Finite Automata

Finite Automata. Seungjin Choi

Chap. 2 Finite Automata

Lecture 2: Regular Expression

Finite Automata and Regular Languages (part II)

Discrete Structures - CM0246 Mathematical Induction

CSE 105 Theory of Computation Professor Jeanne Ferrante

Advanced Automata Theory 2 Finite Automata

Transcription:

Automata and Formal Languages - CM81 Non-Deterministic Finite Automata Andrés Sicard-Ramírez Universidad EAFIT Semester 217-2

Non-Deterministic Finite Automata (NFA) Introduction q i a a q j a q k The automaton can be in several states at once Facilitates the design of automata Question: Are the NFAs more powerful than the DFAs? Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 2/38

Non-Deterministic Finite Automata (NFA) Example (A NFA accepting all the binary strings that end in 1), 1 q start q 1 1 q 2 q : The automaton guess that the final 1 has not begun. q 1 : The automaton guess that the final 1 has begun. q 2 : The word ends in 1. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 3/38

NFA Definition Definition (NFA) A NFA is a quintuple (Q, Σ, δ, q, F ) where Q: A finite set of states Σ: An alphabet of input symbols δ Q Σ P(Q): A transition function q Q: A start state F Q: A set of accepting (or final) states Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 4/38

Extension of the Transition Function for NFAs Let N = (Q, Σ, δ, q, F ) be a NFA. The function δ Q Σ P(Q) δ(q, ε) = {q}, δ(q, xa) = p δ(q,x) δ(p, a). δ is recursively defined by Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 5/38

Language Accepted by a NFA Definition (Language accepted by a NFA) Let D = (Q, Σ, δ, q, F ) be a DFA. The language accepted by D is L(D) = {w Σ δ(q, w) F }. Hopcroft, J. E., Motwani, R. and Ullman, J. D. (27). Introduction to Automata theory, Languages, and Computation, 2.4. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 6/38

Language Accepted by a NFA Definition (Language accepted by a NFA) Let D = (Q, Σ, δ, q, F ) be a DFA. The language accepted by D is L(D) = {w Σ δ(q, w) F }. Let N = (Q, Σ, δ, q, F ) be a NFA. The language accepted by N is L(N) = {w Σ δ(q, w) F }. Hopcroft, J. E., Motwani, R. and Ullman, J. D. (27). Introduction to Automata theory, Languages, and Computation, 2.4. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 7/38

Language Accepted by a NFA Definition (Language accepted by a NFA) Let D = (Q, Σ, δ, q, F ) be a DFA. The language accepted by D is L(D) = {w Σ δ(q, w) F }. Let N = (Q, Σ, δ, q, F ) be a NFA. The language accepted by N is Reading L(N) = {w Σ An application: Text search. δ(q, w) F }. Hopcroft, J. E., Motwani, R. and Ullman, J. D. (27). Introduction to Automata theory, Languages, and Computation, 2.4. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 8/38

Language Accepted by a NFA Theorem (Hopcroft, Motwani and Ullman [27], Example 2.9) For the NFA of the figure, L(N) = {w {, 1} w ends in 1}., 1 q start q 1 1 q 2 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 9/38

Language Accepted by a NFA Theorem (Hopcroft, Motwani and Ullman [27], Example 2.9) For the NFA of the figure, L(N) = {w {, 1} w ends in 1}., 1 q start q 1 1 q 2 Sketch of proof Mutual induction on the following propositions: S (w): q δ(q, w) for all w Σ S 1 (w): q 1 δ(q, w) w ends in S 2 (w): q 2 δ(q, w) w ends in 1 From S 2 (w) and F = {q 2 } then the theorem follows. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 1/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.a) NFA accepting the set of strings over Σ = {1, 2, 3} such that the final digit has appeared before. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 11/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.a) NFA accepting the set of strings over Σ = {1, 2, 3} such that the final digit has appeared before. Σ {1} q 1 Σ i start 1 2 3 Σ {2} 1 q 2 Σ {3} 3 2 f q i : The automaton guess that the repeated digit is i. q 3 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 12/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.b) NFA accepting the set of strings over Σ = {, 1, 2} such that the final digit has not appeared before. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 13/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.b) NFA accepting the set of strings over Σ = {, 1, 2} such that the final digit has not appeared before. Σ start Σ {} q i Σ {} q q f Σ {1} Σ {1} 1 Σ {2} q 1 Σ {2} 2 q 2 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 14/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.c) NFA accepting the set of strings over Σ = {, 1} such that there are two s separated by a number of positions that is multiple of 2. Note that is an allowable multiple of 2. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 15/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.3.4.c) NFA accepting the set of strings over Σ = {, 1} such that there are two s separated by a number of positions that is multiple of 2. Note that is an allowable multiple of 2. Σ q Σ q 1 q 2 start 1 Σ q Σ 3 q Σ 4 q 5 q 6 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 16/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.5.3.b) NFA accepting the set of strings that consist of either 1 repeated one or more times or 1 repeated one or more times. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 17/38

Language Accepted by a NFA Example (Hopcroft, Motwani and Ullman [27], Exercise 2.5.3.b) NFA accepting the set of strings that consist of either 1 repeated one or more times or 1 repeated one or more times. q q 1 1 q 2 start q 1 3 q 4 q 5 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 18/38

The Subset Construction Input: A NFA N = (Q N, Σ, δ N, q, F N ) Output: A DFA D = (Q D, Σ, δ D, {q }, F D ) where Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 19/38

The Subset Construction Input: A NFA N = (Q N, Σ, δ N, q, F N ) Output: A DFA D = (Q D, Σ, δ D, {q }, F D ) where Q D = P(Q N ), F D = {S P(Q N ) S F N }, δ D (S, a) = δ N (p, a), for each S P(Q N ) and a Σ. p S Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 2/38

The Subset Construction Example Given the following NFA to build the DFA given by the subset construction., 1 q start q 1 1 q 2 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 21/38

The Subset Construction Example (cont.) {q, q 1, q 2 } {q 1, q 2 } {q 1 } {q 2 } {q } {q, q 1 } {q, q 2 } start

The Subset Construction Example (cont.), 1 {q, q 1, q 2 } {q 1, q 2 } 1 1, 1 1 1 {q 1 } {q 2 } {q } 1 {q, q 1 } {q, q 2 } start 1 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 23/38

The Subset Construction Example (cont.) 1 1 start {q } {q, q 1 } {q, q 2 } 1 Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 24/38

Equivalence of DFAs and NFAs Example (Special case) A NFA recognising the word then : t h e n start q t th the then Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 25/38

Equivalence of DFAs and NFAs Example (Special case) A NFA recognising the word then : t h e n start q t th the then The DFA given by the subset construction: t h e n start {q } {t} {th} {the} {then} Σ {t} Σ {h} Σ {e} Σ {n} Σ Σ Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 26/38

Equivalence of DFAs and NFAs Let D = (Q D, Σ, δ D, {q }, F D ) be the DFA constructed from a NFA N = (Q N, Σ, δ N, q, F N ) by the subset construction. Theorem (Proof by structural induction on w) δ D ({q }, w) = δ N (q, w). Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 27/38

Equivalence of DFAs and NFAs Let D = (Q D, Σ, δ D, {q }, F D ) be the DFA constructed from a NFA N = (Q N, Σ, δ N, q, F N ) by the subset construction. Theorem (Proof by structural induction on w) δ D ({q }, w) = δ N (q, w). Theorem (Hopcroft, Motwani and Ullman [27], Theorem 2.11) L(D) = L(N). Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 28/38

Equivalence of DFAs and NFAs Theorem (Hopcroft, Motwani and Ullman [27], Exercise 2.3.5) Let D = (Q, Σ, δ D, q, F ) be a DFA and let N = (Q, Σ, δ N, q, F ) be a NFA, where δ N is defined by: Hence, if if δ D (q, a) = p, then δ N (q, a) = {p}. (1) δ D (q, w) = p, then δ N (q, w) = {p}. (Proof in the next slides) Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 29/38

Equivalence of DFAs and NFAs Proof (by structural induction on w) 1. P (w): If δ D (q, w) = p, then δ N (q, w) = {p}. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 3/38

Equivalence of DFAs and NFAs Proof (by structural induction on w) 1. P (w): If δ D (q, w) = p, then δ N (q, w) = {p}. 2. Basis step P (ε): Since δ D (q, ε) = q (by def. of of δ N ) then P (ε). δ D ) and δ N (q, ε) = {q } (by def. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 31/38

Equivalence of DFAs and NFAs Proof (cont.) 3. Inductive step: x Σ. a Σ. P (x) P (xa) Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 32/38

Equivalence of DFAs and NFAs Proof (cont.) 3. Inductive step: x Σ. a Σ. P (x) P (xa) Inductive hypothesis P (x): If δ D (q, x) = p, then δ N (q, x) = {p}. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 33/38

Equivalence of DFAs and NFAs Proof (cont.) 3. Inductive step: x Σ. a Σ. P (x) P (xa) Inductive hypothesis P (x): If Let δ D (q, x) = p, then δ N (q, x) = {p}. δ D (q, x) = p and δ D (p, a) = q, that is, δ D (q, xa) = q. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 34/38

Equivalence of DFAs and NFAs Proof (cont.) 3. Inductive step: x Σ. a Σ. P (x) P (xa) Inductive hypothesis P (x): If Let Hence δ D (q, x) = p, then δ N (q, x) = {p}. δ D (q, x) = p and δ D (p, a) = q, that is, δ D (q, xa) = q. Therefore, if δ N (q, xa) = p δ N (q,x) = p {p} δ N (p, a) δ N (p, a) (by def. of δ N ) (by IH) = {q} (by (1)) δ D (q, xa) = q, then δ N (q, xa) = {q}. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 35/38

Equivalence of DFAs and NFAs Theorem (Hopcroft, Motwani and Ullman [27], Theorem 2.12) A language L is accepted by some DFA if and only if L is accepted by some NFA. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 36/38

Equivalence of DFAs and NFAs Theorem (Hopcroft, Motwani and Ullman [27], Theorem 2.12) A language L is accepted by some DFA if and only if L is accepted by some NFA. Definition (Regular language) A language L is regular if exists a finite automaton A (DFA or NFA) such L = L(A). Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 37/38

References Hopcroft, J. E., Motwani, R. and Ullman, J. D. (27). Introduction to Automata theory, Languages, and Computation. 3rd ed. Pearson Education. Automata and Formal Languages - CM81. Non-Deterministic Finite Automata 38/38