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

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

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,

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Equivalence of DFAs and NFAs

Lecture 3: Nondeterministic Finite Automata

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

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

CMSC 330: Organization of Programming Languages

Non-deterministic Finite Automata (NFAs)

Lecture 1: Finite State Automaton

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

Automata and Languages

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

CSC236 Week 11. Larry Zhang

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

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

Chapter Five: Nondeterministic Finite Automata

Chapter Two: Finite Automata

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

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 154, Lecture 3: DFA NFA, Regular Expressions

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Inf2A: Converting from NFAs to DFAs and Closure Properties

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

Deterministic Finite Automaton (DFA)

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Nondeterminism and Epsilon Transitions

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 )

Chapter 2: Finite Automata

CS 455/555: Finite automata

Theory of Computation (I) Yijia Chen Fudan University

Lecture 4 Nondeterministic Finite Accepters

CSE 105 THEORY OF COMPUTATION

CSE 311 Lecture 25: Relating NFAs, DFAs, and Regular Expressions. Emina Torlak and Kevin Zatloukal

CS 154 Formal Languages and Computability Assignment #2 Solutions

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

Nondeterministic Finite Automata. Nondeterminism Subset Construction

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

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

Nondeterministic finite automata

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

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

Finite Automata and Regular languages

Chapter 6: NFA Applications

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

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

CSE 105 Theory of Computation Professor Jeanne Ferrante

Chapter 5. Finite Automata

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

Finite Automata. Finite Automata

Constructions on Finite Automata

Uses of finite automata

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

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

Finite Automata. Seungjin Choi

CSC173 Workshop: 13 Sept. Notes

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

Extended transition function of a DFA

CS21 Decidability and Tractability

CS243, Logic and Computation Nondeterministic finite automata

Decision, Computation and Language

Intro to Theory of Computation

Further discussion of Turing machines

Finite Automata (contd)

Nondeterministic Finite Automata and Regular Expressions

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

Nondeterministic Finite Automata

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

Languages, regular languages, finite automata

Computational Models Lecture 2 1

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

Constructions on Finite Automata

Finite Automata. Mahesh Viswanathan

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

front pad rear pad door

Course 4 Finite Automata/Finite State Machines

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

Computational Models - Lecture 1 1

Computer Sciences Department

Theory of Languages and Automata

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Lecture 17: Language Recognition

Deterministic Finite Automata (DFAs)

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

Deterministic finite Automata

Classes and conversions

Deterministic Finite Automata (DFAs)

Finite Automata and Regular Languages

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

Automata: a short introduction

Theory of Computation

Transcription:

Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting states (F ) Read symbols (Σ ) Transition function (δ) First there was the DFA Deterministic Finite Automata For every state and every alphabet symbol there is exactly one move that the machine can make δ : Q x Σ Q δ is a total function: completely defined Ie it is defined for all q Q and a Σ Let s recap Then, the NFA Non-determinism When machine is in a given state and reads a symbol, the machine will have a choice of where to move to next There may be states where, after reading a given symbol, the machine has nowhere to go Applying the transition function will give, not 1 state, but 0 or more states Non-Deterministic Finite Automata (NFA) Transition function δ is a function from Q x Σ to 2 Q δ (q, a) = subset of Q (possibly empty) 1

And now Introducing The newest in the FA family The Non deterministic finite automata with ε For both DFAs and NFAs, you must read a symbol in order for the machine to make a move In Can make move without reading a symbol off the read tape Such a move is called a ε transition Example: Machine to accept decimal numbers q 0 ε + - ε q 1 q 2 q 3 q 5 How does such a machine accept? A string will be accepted if there is at least one sequence of state transitions on an input (including ε transitions) that leaves the machine in an accepting state q 4 Example: -345 is accepted 5678 37 is rejected q 0 ε + - q 1 q 2 q 3 ε q 5 A Non-Deterministic Finite Automata with ε transitions is a 5-tuple (Q, Σ, q o, δ, F) where Q is a finite set (of states) Σ is a finite alphabet of symbols q o Q is the start state F Q is the set of accepting states δ is a function from Q x (Σ {ε}) to 2 Q (transition function) q 4 2

Transition function δ is a function from Q x (Σ {ε}) to 2 Q δ (q, a) = subset of Q (possibly empty) In our example δ (q 1, 0) = {q 1, q 4 } δ (q 1, ) = {q 1 } δ (q 1, +) = δ (q 0, ε) = {q 1 } Transition function on a string ^ δ is a function from Q x Σ * to 2 Q ^ δ (q, x) = subset of Q (possibly empty) Set of all states that the machine can be in, upon following all possible paths on input x We ll need to consider all paths that include the use of ε transitions ε closure Before defining the transition function on a string ( ^ δ (q,x)), it is useful to first define what is known as the ε closure Given a set of states S, the ε closure will give the set of states reachable from each state in S using only ε transitions ε closure: Recursive definition Let M = (Q, Σ, q o, δ, F) be a ε-nfa Let S be a subset of Q The ε closure, denotes ECLOSE(S) is defined: For each state p S, p ECLOSE(S) For any q ECLOSE(S), every element of δ(q, ε) ECLOSE(S) No other elements of Q are in ECLOSE(S) : Algorithm Since we know that ECLOSE(S) is finite, we can convert the recursive definition to an algorithm Example To find ECLOSE(S) where S is a subset of Q Let T = S While (T does not change) do Add all elements of δ(q, ε) where q T ECLOSE(S) = T 3

ε closure: Example Find ECLOSE({s}) in our example T = {s} initial step T = {s, w} add δ(s, ε) T = {s, w, q 0 } add δ(w, ε) T = {s, w, q 0, p,t} add δ(q 0, ε) δ(w, ε) = δ(w, ε) = We are done, ECLOSE({s}) = T = {s, w, q 0, p,t} Now lets define ^ δ 1 For any q Q, ^ δ (q, ε) = ECLOSE ({q}) 2 For any y Σ *, a Σ, q Q ˆ( δ q, ya) = ECLOSE Uδ ( p, a) p ˆ( δ q, y) Set of all states obtained by applying δ to all states in δ * (q,y) and input a and taking the ε closure of the result Accepting a string A string x is accepted if running the machine on input x, considering all paths, including the use of ε transitions, puts the machine into one of the accepting states Formally: x Σ * is accepted by M if ^ δ (q 0, x) F Are the following strings accepted by the ε- NFA below: aba ababa aaabbb I bet that you re asking Can JFLAP handle ε-nfas? Well, let s check and see! Language accepted by M The language accepted by M L(M) = { x Σ * x is accepted by M } If L is a language over Σ, L is accepted by M iff L = L(M) For all x L, x is accepted by M For all x L, x is rejected by M 4

Why they re a good idea Given a regular expression, it is far easier to create an ε-nfa for the language described by the expression than it is to create a plain old DFA It will also be essential when showing the Fas accept the class of Regular Languages Questions? DFA / NFA / ε-nfa Equivalence Surprisingly enough ε transitions to our NDFA does NOT give it any additional language accepting power DFAs and NFAs and ε-nfa are all equivalent Every language that can be accepted by a ε-nfa can also be accepted by an DFA which can also be accepted by a NFA Let s show this Given ε-nfa find DFA Let E = (Q E, Σ, δ E, q 0, F E ) be a ε-nfa then There exists a DFA, D = (Q D, Σ, δ D, q D, F D ) Such that L(E) = L(D) Basic idea Very similar to the subset construction algorithm Recall that for a ε-nfa, δ: Q x Σ 2 Q Use the states of D to represent subsets of Q Formal definition E = (Q E, Σ, δ E, q 0, F E ) be a ε-nfa We define DFA, D = (Q D, Σ, δ D,q D, F D ) Q D = 2 QE q D = ECLOSE (q 0 ) F D = sets containing at least one state from F E Computing δ D δ D (S, a) for S Q D, a Σ Let S = { p 1, p 2,, p n } Compute the set of all states reachable from states in S on input a using transitions from E n { r1, r2, L, rm } = Uδ E ( pi, a) i= 1 δ D (S, a) will be the union of the ε closures of the elements of {r 1,, r m } δ U m D ( S, a) = ECLOSE( r j j= 1 ) 5

q 0 ε + - q 1 q 2 q 3 ε q 5 q 4 State q 0 {q 0, q 1 } q 1 {q 1 } q 2 {q 2 } q 3 {q 3, q 5 } q 4 {q 4 } q 5 {q 5 } ε closure + - q 0 q 1 q 1 q 1 q 4 q 2 q 3 q 5 Now we must show that D accepts the same language as E Can be shown (using induction) that for all x Σ * ^ δ (q, x) = ^δ D E (q, x) q 2 q 3 q 5 See Theorem 222 Show that D and E recognize the same language x is accepted by E iff ^ δ (q 0, x) F E E x is accepted by D iff ^ δ (q D, x) F E D Thus, x is accepted by D iff x is accepted by E DFA -> ε-nfa The other direction is fairly straighforward For any DFA, there is an equivalent NFA An NFA is nothing more than a ε-nfa with no ε transitions Thus δ (q, ε) for all states q = Questions? 6

What have we shown For every DFA, there is an NFA that accepts the same language and visa versa Let s take a break Questions? For every DFA, there is a ε-nfa that accepts the same language, and visa versa Thus, for every NFA there is a ε-nfa that accepts the same language, and visa versa DFAs, NFAs, and ε-nfa s are equivalent! 7