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

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

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

Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Automata and Languages

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

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

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Extended transition function of a DFA

CS243, Logic and Computation Nondeterministic finite automata

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

Chapter Five: Nondeterministic Finite Automata

Nondeterminism. September 7, Nondeterminism

Lecture 1: Finite State Automaton

CMSC 330: Organization of Programming Languages

CS 154, Lecture 3: DFA NFA, Regular Expressions

Intro to Theory of Computation

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Deterministic Finite Automaton (DFA)

Classes and conversions

CSC236 Week 11. Larry Zhang

Theory of Computation (I) Yijia Chen Fudan University

Finite Automata. Finite Automata

Nondeterministic finite automata

Chapter 6: NFA Applications

Finite Automata. Seungjin Choi

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

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

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

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

Theory of Computation

CSE 105 Theory of Computation Professor Jeanne Ferrante

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

CS 455/555: Finite automata

Finite Automata Part Two

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Nondeterminism and Epsilon Transitions

Nondeterministic Finite Automata

Sri vidya college of engineering and technology

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

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

Decision, Computation and Language

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

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

Finite Automata. Mahesh Viswanathan

Lecture 17: Language Recognition

Finite Automata Part Two

Nondeterministic Finite Automata

CS 322 D: Formal languages and automata theory

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

Finite Automata and Regular languages

Non-deterministic Finite Automata (NFAs)

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

Chapter Two: Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

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

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Equivalence of DFAs and NFAs

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

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

Theory of computation: initial remarks (Chapter 11)

CS21 Decidability and Tractability

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

Course 4 Finite Automata/Finite State Machines

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

Lecture 4 Nondeterministic Finite Accepters

Constructions on Finite Automata

Algorithms for NLP

Chapter 2. Finite Automata. (part A) (2015/10/20) Hokkaido, Japan

Takeaway Notes: Finite State Automata

CS 154 Formal Languages and Computability Assignment #2 Solutions

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

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

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

Regular Languages. Kleene Theorem I. Proving Kleene Theorem. Kleene Theorem. Proving Kleene Theorem. Proving Kleene Theorem

Constructions on Finite Automata

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

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

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Uses of finite automata

CSE 105 THEORY OF COMPUTATION

Finite Automata (contd)

front pad rear pad door

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Chapter 5. Finite Automata

Transcription:

Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic 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. I.e. it is defined for all q Q and a Σ 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. Example: L corresponds to the regular expression {11 110} * 0 How does such a machine accept? A string will be accepted if there is at least one sequence of state transitions on an input that leaves the machine in an accepting state. Such a machine is called a non-deterministic finite automata A 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 final states is a function from Q x Σ to 2 Q (transition function)

Transition function is a function from Q x Σ to 2 Q (q, a) = subset of Q (possibly empty) In our example (q 3, 0) = {q o } (q o, 1) = {q 1, q 2 } (q 4, 1) = Transition function on a string x 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. Recursive definition of 1. For any q Q, (q, ε) = {q} 2. For any y Σ *, a Σ, q Q ˆ( q, ya) = U * p ( q, y) ( p, a) Set of all states obtained by applying to all states in (q,y) and input a. In our example: (q 0, 110) = (q 1, 10) (q 2, 10) = (q 0, 0) (q 3, 0) = (q 4, ε) (q 0, ε) = {q 4 } {q 0 } = {q 0, q 4 } Definition of accepting A string x is accepted if running the machine on input x, considering all paths, puts the machine into one of the final states Formally: x Σ * is accepted by A if (q 0, x) F Once again, in our example (q 0, 110) = {q 0, q 4 } F = {q 4 } (q 0, 110) F = {q 4 } 110 is accepted by A

Language accepted by A The language accepted by A L(A) = { x Σ * x is accepted by A } I bet that you re asking Can JFLAP handle NFAs? Well, let s check and see! If L is a language over Σ, L is accepted by A iff L = L(A). For all x L, x is accepted by A. For all x L, x is rejected by A. Let s try another one: L = set of strings ending in ab Let s see how this fares with JFLAP Reality Check Nondeterministic Finite Automata At each state,for each symbol, the machine can move into 0 or more states. is a function from Q x Σ to 2 Q A string is accepted if there is at least one sequence of moves on input x placing the machine into an accepting state. Questions? DFA / NFA Equivalence Surprisingly enough Adding nondeterminism to our DFA does NOT give it any additional language accepting power. DFAs and NFAs are equivalent Every language that can be accepted by an NFA can also be accepted by a DFA and visa-versa DFA / NFA Equivalence How we will show this 1. Given an NFA that accepts L, create an DFA that also accepts L 2. Given an DFA that accepts L, create an NFA that also accepts L Are we ready?

NFA->DFA Given N FA find DFA Let N = (Q N, Σ, N, q 0, F N ) be a NFA then There exists a DFA, D = (Q D, Σ, D,q D, F D ) Such that L(N) = L(D) Basic idea Recall that for a NFA, : Q x Σ 2 Q Use the states of D to represent subsets of Q. If there is one state of D for every subset of Q, then the non-determinism of N can be eliminated. This technique, called subset construction, is a primary means for removing non-determinism from an NFA. Formal definition N = (Q N, Σ, N, q 0, F N ) be a NFA We define DFA, D = (Q D, Σ, D, q D, F D ) Q D = 2 Q q D = {q 0 } For q Q D and a Σ, D ( q, a) = U N ( p, a) p q F D = {q Q D q F N } Note that we need only include states on D (subsets of Q) if the state is reachable. Algorithm for building D Add {q 0 } to Q D While there are states of Q D whose transitions are yet to be defined Let q Q D For each a Σ, determine the set of states, P, in N that are reachable from q on input a If there is no state in Q D corresponding to P, add one. Define D (q, a) = state in Q D corresponding to P Define F D as any state in Q D that corresponds to a subset containing any of the final states of N Example Now we must show that D accepts the same language as N It can be shown (by induction) that for all x Σ * (q D, x) D = N (q 0, x) Note that both of these are Sets of states from N See Theorem 2.11 in Text

Show that D and N recognize the same language x is accepted by D iff D (q D, x) F D F D contains sets that contain any state in F N Thus (q D, x) F D iff D N (q N, x) F N What have we shown In Step 1 we ve shown: Given a NFA There exists an DFA that accepts the same language Non-determinism can be removed from an NFA by using a subset construction algorithm. Questions? x is accepted by D iff x is accepted by N Step 2: Given DFA find NFA Observe that a DFA can easily be converted to an equivalent NFA: DFAs all transitions lead to exactly one state Define the transitions of the NFA to consists of sets of only 1 element. What have we shown In Step 2 we ve shown: Given a DFA There exists an NFA that accepts the same language What have we shown Equivalence Is there something in here? NFA DFA NFA DFA If L NFA then L DFA If L DFA then L NFA

Summary Non-deterministic finite automata Machine now can choose it s path. Each transition takes you from a state to a set of states. Equivalent in language recognition power to DFA. Questions?