Extended transition function of a DFA

Similar documents
CSE 135: Introduction to Theory of Computation Equivalence of DFA and NFA

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Lecture 1: Finite State Automaton

CS 208: Automata Theory and Logic

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

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

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

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 )

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Chapter 6: NFA Applications

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSE 105 Theory of Computation Professor Jeanne Ferrante

Nondeterministic Finite Automata

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

Finite Automata and Languages

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

Nondeterministic finite automata

Nondeterministic Finite Automata

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

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

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

Sri vidya college of engineering and technology

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 43

Takeaway Notes: Finite State Automata

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

E.g. The set RE of regular expressions is given by the following rules:

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,

Chapter Five: Nondeterministic Finite Automata

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Lecture 4 Nondeterministic Finite Accepters

Finite Automata and Regular Languages

CS 322 D: Formal languages and automata theory

Nondeterminism. September 7, Nondeterminism

CS 455/555: Finite automata

Computational Models Lecture 2 1

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

Computational Models Lecture 2 1

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

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

UNIT-III REGULAR LANGUAGES

Formal Models in NLP

September 7, Formal Definition of a Nondeterministic Finite Automaton

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

CS 154 Formal Languages and Computability Assignment #2 Solutions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Nondeterministic Finite Automata

Finite Automata (contd)

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Constructions on Finite Automata

Deterministic Finite Automaton (DFA)

Computational Models - Lecture 1 1

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Deterministic finite Automata

Constructions on Finite Automata

Decision, Computation and Language

Finite Automata Part Two

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Closure under the Regular Operations

Finite Automata. Finite Automata

Theory of Computation (I) Yijia Chen Fudan University

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

Finite Automata. Mahesh Viswanathan

CSCE 551 Final Exam, April 28, 2016 Answer Key

Nondeterminism and Epsilon Transitions

Computational Models #1

Automata and Languages

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

CSC236 Week 11. Larry Zhang

Deterministic Finite Automata (DFAs)

Finite Automata. Seungjin Choi

Deterministic Finite Automata (DFAs)

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

Non-deterministic Finite Automata (NFAs)

Methods for the specification and verification of business processes MPB (6 cfu, 295AA)

3515ICT: Theory of Computation. Regular languages

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Non-Deterministic Finite Automata

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

Business Processes Modelling MPB (6 cfu, 295AA)

CS243, Logic and Computation Nondeterministic finite automata

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

Chapter 5. Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

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

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

FINITE STATE MACHINES (AUTOMATA)

COMP4141 Theory of Computation

Deterministic Finite Automata (DFAs)

Course 4 Finite Automata/Finite State Machines

Introduction to Finite-State Automata

CSE 105 Homework 3 Due: Monday October 23, Instructions. should be on each page of the submission.

Classes and conversions

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Equivalence of DFAs and NFAs

Transcription:

Extended transition function of a DFA The next two pages describe the extended transition function of a DFA in a more detailed way than Handout 3.. p./43

Formal approach to accepted strings We define the extended transition function ˆδ. It takes a state q and an input string w to the resulting state. The definition proceeds by induction over the length of w. Induction basis (w has length ): in this case, w is the empty string, i.e. the string of length, for which we write ɛ. We define ˆδ(q, ɛ) = q.. p.2/43

Formal approach to accepted strings Induction step (from length l to length l + ): in this case, w, which has length l +, is of the form va, where v is a string of length l and a is a symbol. We define ˆδ(q, va) = δ(ˆδ(q, v), a). This works because, by induction hypothesis, ˆδ(q, v) is already defined.. p.3/43

Non-deterministic finite automata (NFA s). p.4/43

Non-deterministic FA (NFA) An NFA is like a DFA, except that it can be in several states at once. This can be seen as the ability to guess something about the input. Useful for searching texts.. p.5/43

NFA: example An NFA accepting all strings that end in :, Start q q q 2 It is non-deterministic because input in state q can lead to both q and q.. p.6/43

NFA example - correction The example on the next few pages is a corrected version of the wrong example in Handout 3!. p.7/43

Using the NFA, Start q q q 2 Suppose the input string is. starts in state q, as indicated by the token. The NFA. p.8/43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the first symbol,. It remains in state q.. p.9/43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the next symbol,. The resulting possible states are q or q.. p./43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the next symbol,. The resulting possible states are still q or q.. p./43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the next symbol,. The resulting possible states are q and q 2. (Because q 2 is a final states, this means that the word so far,, would be accepted.). p.2/43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the next symbol,. There is no transition for from q 2, so the token on q 2 dies. The resulting possible states are q or q.. p.3/43

Using the NFA, Start q q q 2 The remaining input string is. The NFA reads the next symbol,. The possible states are q and q 2. Because q 2 is final, the NFA accepts the word,.. p.4/43

Formal definition of NFA Definition. A non-deterministic finite automaton (NFA) consists of a finite set of states, often denoted Q, a finite set Σ of input symbols, a transition function δ : Q Σ P (Q), a start state q Q, and a set F Q of final or accepting states.. p.5/43

Difference between NFA and DFA Suppose that q is a state and a is an input symbol. In a DFA, we have δ(q, a) Q, that is, δ(q, a) is a state. In a NFA, we have δ(q, a) P (Q), that is, δ(q, a) is a set of states; it can be seen as the possible states that can result from input a in state q.. p.6/43

Formal approach to accepted strings We are aiming to describe the language L(A) accepted by a NFA A. This description is similar to the DFA case, but a bit more sophisticated. As in the DFA case, we first define the extended transition function: ˆδ : Q Σ P (Q). That function ˆδ will be used to define L(A).. p.7/43

Example of ˆδ (input string ), Start q q q 2 Before reading any symbols, the set of possible states is ˆδ(q, ɛ) = {q }.. p.8/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q }.. p.9/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q, q }.. p.2/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q, q }.. p.2/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q, q 2 }.. p.22/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q, q }.. p.23/43

Example of ˆδ (input string: ), Start q q q 2 We have ˆδ(q, ) = {q, q 2 }. Because {q, q 2 } F = {q, q 2 } {q 2 } = {q 2 }, the NFA accepts.. p.24/43

Formal definition of ˆδ Definition. The extended transition function ˆδ : Q Σ P (Q) of an NFA is defined inductively as follows: Induction basis (length ): ˆδ(q, ɛ) = {q} Induction step (from length l to length l + ): ˆδ(q, va) = δ(q, a). q ˆδ(q,v). p.25/43

The language of an NFA Intuitively, the language of a DFA A is the set of strings w that lead from the start state to an accepting possible state. Formally, the language L(A) accepted by the FA A is defined as follows: L(A) = {w ˆδ(q, w) F }.. p.26/43

Exercise Give NFA to accept the following languages.. The set of strings over an alphabet {,,..., 9} such that the final digit has appeared before. 2. The set of strings over an alphabet {,,..., 9} such that the final digit has not appeared before. 3. The set of strings of s and s such that there are two s separated by a number of positions that is a multiple of 4.. p.27/43

DFA s and NFA s Evidently, DFA s are precisely those NFA s for which the set of states δ(q, a) has exactly one element for all q and a. So, trivially, every language accepted by a DFA is also accepted by some NFA. Is every language accepted by an NFA also accepted by some DFA? Surprisingly, the answer is yes!. p.28/43

Simulation of an NFA by a DFA Let N = (Q N, Σ, δ N, q N, F N ) be a NFA. The equivalent DFA D is obtained from the so-called powerset construction (also called subset construction.) We define where... D = (Q D, Σ, δ D, q D, F D ),. p.29/43

Simulation of an NFA by a DFA The alphabet of D is that of N. The states of D are sets of states of N: Q D = P (Q N ) The initial state q D of D is {q N }.. p.3/43

Simulation of an NFA by a DFA The final states of D are those sets that contain the final state of N: F D = {S P (Q N ) S F N } The transition function of D arises from the transition function of N as follows: δ D (S, a) = δ N (q, a) q S. p.3/43

Example of powerset construction: table NFA DFA Start q q q 2, {q } {q, q } {q } {q } {q 2 } {q 2 } {q, q } {q, q } {q, q 2 } {q, q 2 } {q, q } {q } {q, q 2 } {q 2 } {q, q, q 2 } {q, q } {q, q 2 }. p.32/43

Example of powerset construction: graph {q } {q,q } {q,q 2 } {q 2 } {q,q,q 2 }, {q } {q,q 2 }, {} Transition graph of the resulting DFA.. p.33/43

Example of powerset construction: graph {q } {q,q } {q,q 2 } Optionally, we can remove the unreachable states of the DFA.. p.34/43

Proposition about the simulation Proposition.For every NFA N, there is a DFA D such that L(D) = L(N).. p.35/43

Proof of the proposition (part /3) First, we show that for every string w we have δ D ({q }, w) = δ N (q, w) () We proceed by induction on the length l of w. Base case (l = ): in this case, w is the empty string, ɛ. We have δ D ({q }, ɛ) = {q } (by defn. of δ D ) = δ N (q, ɛ) (by defn. of δ N ).. p.36/43

Proof of the proposition (part 2/3) Induction step (from l to l + ): in this case, w, which is of length l +, is of the form va, where v is a string of length l and a is a symbol. We have δ D ({q }, va) = δ D ( δ D ({q }, v), a) (by defn. of δ D ) = δ D ( δ N (q, v), a) (by indn. hypoth.) = δ N (q, a) (by defn. of δ D ) q δ N (q,v) = δ N (q, va) (by defn. of δ N ).. p.37/43

Proof of the proposition (part 3/3) Finally, we use Equation??, which we just proved, to prove that the languages of D and N are equal: w L(D) δ D ({q }, w) F D (by defn. of L(D)) δ N (q, w) F D (by Equation??) δ N (q, w) F N (by defn. of F D ) w L(N) (by defn. of L(N)).. p.38/43

Languages accepted by DFAs and NFAs The proposition implies: Corollary. A language L is accepted by some DFA if and only if L is accepted by some NFA. Proof. : this is the powerset construction we have just seen. : this is true because every DFA is a special case of an NFA, as observed earlier.. p.39/43

Warning Let N be an NFA, and let D be the DFA that arises from the powerset construction. As we have seen, we have Q D = P (Q N ). So, if Q N has size k, then the size of Q D is 2 k. This exponential growth of the number of states makes the powerset construction unusable in practice. It can be shown that removing unreachable states does not prevent this exponential growth.. p.4/43

Exercise Convert the following NFA to a DFA: p {p, q} {p} q {r} {r} r {s} {} s {s} {s}.. p.4/43

Exercise Convert the following NFA to a DFA: p {q, s} {q} q {r} {q, r} r {s} {p} s {} {p}.. p.42/43

Exercise Convert the following NFA to a DFA: p {p, q} {p} q {r, s} {t} r {p, r} {t} s {} {} t {} {} Describe informally the language accepted by this NFA accept? (Don t worry if you need tutor s help. p.43/43