COM364 Automata Theory Lecture Note 2 - Nondeterminism

Similar documents
Theory of Computation (I) Yijia Chen Fudan University

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 3: Nondeterministic Finite Automata

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

Nondeterministic Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

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,

Intro to Theory of Computation

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

Chapter Five: Nondeterministic Finite Automata

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

Closure under the Regular Operations

CS 455/555: Finite automata

CPS 220 Theory of Computation REGULAR LANGUAGES

Automata and Languages

Finite Automata and Regular languages

CS243, Logic and Computation Nondeterministic finite automata

Equivalence of DFAs and NFAs

Computer Sciences Department

CS21 Decidability and Tractability

CSE 105 THEORY OF COMPUTATION

Nondeterminism. September 7, Nondeterminism

Sri vidya college of engineering and technology

Finite Automata Part Two

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

Theory of Computation Lecture 1. Dr. Nahla Belal

Chap. 1.2 NonDeterministic Finite Automata (NFA)

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

Nondeterministic Finite Automata

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

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

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Nondeterministic Finite Automata. Nondeterminism Subset Construction

September 7, Formal Definition of a Nondeterministic Finite Automaton

Computational Models Lecture 2 1

Inf2A: Converting from NFAs to DFAs and Closure Properties

Theory of Computation (II) Yijia Chen Fudan University

CSE 105 Theory of Computation Professor Jeanne Ferrante

Decision, Computation and Language

Fooling Sets and. Lecture 5

Computational Models Lecture 2 1

Lecture 1: Finite State Automaton

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

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

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

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

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

Computational Models - Lecture 1 1

Theory of Languages and Automata

Lecture 4 Nondeterministic Finite Accepters

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

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

Deterministic Finite Automaton (DFA)

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 105 THEORY OF COMPUTATION

Course 4 Finite Automata/Finite State Machines

CS 154 Introduction to Automata and Complexity Theory

Automata: a short introduction

Non-deterministic Finite Automata (NFAs)

CS 208: Automata Theory and Logic

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

Nondeterministic finite automata

CS21 Decidability and Tractability

Lecture 17: Language Recognition

Computational Models #1

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

Finite Automata (contd)

Finite Automata. Seungjin Choi

CISC 4090 Theory of Computation

CSC236 Week 11. Larry Zhang

Computability Theory

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

CSE 105 THEORY OF COMPUTATION

Nondeterminism and Epsilon Transitions

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Context-Free Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSC173 Workshop: 13 Sept. Notes

Closure under the Regular Operations

Finite Automata and Languages

Formal Models in NLP

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

Introduction to Languages and Computation

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,

CSE 105 THEORY OF COMPUTATION

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

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

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

CS 133 : Automata Theory and Computability

Finite Automata Part Two

Nondeterministic Finite Automata and Regular Expressions

CPS 220 Theory of Computation Pushdown Automata (PDA)

CSCI 2670 Introduction to Theory of Computing

Theory of Computation

Chapter 2: Finite Automata

Transcription:

COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly one possible transition. In a nondeterministic FA (NFA), this condition is relaxed. So, it is possible to not to have a transition from a state for an input symbol or there can be several choices for the same symbol. Nondeterminism is a more general case. So, every DFA can be considered as a NFA. Example: Figure 1 shows our first example NFA. You should note three important differences from those until now. First, there are two transitions from q 1 for the input symbol 1. Second, for some state and input symbols, there is no transition. For example, there is no transition for symbol 1 and state q 2 or for symbol 0 and q 3. Lastly, there is a transition from q 2 to q 3 for symbol ε. The ε symbol here is used for the empty string as before and this transition means that the automaton can go from q 2 to q 3 without any input symbol. When a NFA is processing a string, we consider all possible computation paths. If any of these possible paths leads to an accepting state at the end of the input, the NFA accepts that input. This way of processing can be visualized by using a tree notation. The root of the tree corresponds to the start of the computation. Every branching point in the tree corresponds to a point in the computation at which the machine has multiple choices. The machine accepts if at least one of the computation branches ends in an accept state. As an example look at Figure 2. The example shows the NFA N 1 above processing string 010110. Example: Let A be the language consisting of all strings over {0, 1} containing a 1 in the third position from the end. (For example, 000100 is in A but 0011 is not.) An NFA to recognize A is shown in Figure 3. Note: Every NFA can be converted into an equivalent DFA. Most of the time, the DFA will have any more states. Question: What changes if we add ε-transitions from q 2 to q 3 and q 3 to q 4 in N 2? Formal Definition of a NFA The formal definition of a NFA is similar to that of a DFA except some important differences in details. A NFA is a 5-tuple (Q, Σ, δ, q 0, F ), where 1. (same as in DFA) Q is a finite set of states, Based on the book Introduction to the Theory of Computation by Michael Sipser. Figure 1: Our first example NFA, N 1. 1

Figure 2: NFA N 1 processing string 010110 visualized as a tree. Figure 3: NFA N 2. 2. (same as in DFA) Σ is the input alphabet, 3. (different) δ : Q Σ ε P (Q) is the transition function where Σ ε stands for Σ {ε} and P (Q) is the power set of Q, 4. (same as in DFA) q 0 Q is the start state, and 5. (same as in DFA) F Q is the set of accepting (final) states. Equivalance of NFA and DFA Although NFA appear to be more powerful, the two types of automata are actually of equal power. In other words, the class of languages that can be recognized by NFA are the same as that of DFA and these are the regular languages. Theorem: Every NFA has an equivalent DFA. Proof Idea: We need to show that if a language is recognized by a NFA, there is also a DFA that recognizes the same language. We will convert the NFA to a DFA that simulates it. If the NFA has k states, the power set has 2 k elements. These will be the states for the DFA. Transitions, start and accepting states can all be arranged logically according to the NFA. For a full proof, let N = (Q, Σ, δ, q 0, F ) be the initial NFA and try to define the components of a DFA D = (Q, Σ, δ, q 0, F ) that will recognize the same language. It is easy to first assume that there are no ε-transitions, and then try to extend including them. When extending, a new definition, called ε-closure, becomes useful. The ε-closure for a state q, written as ε-closure(q) is defined as the set of states that can be reached from q following 0 or more ε-transitions. ε-closure of a state always includes at least itself. For example, for the machine N 1 in Figure 1, ε-closure(q 2 ) = {q 2, q 3 }. 2

Figure 4: NFA N 4. Figure 5: DFA D 4, which is equaivalent to the NFA N 4 in Figure 4. Example: Figure 4 shows an example NFA called N 4 for which we will find the equivalent DFA, D 4. N 4 has three states, {1, 2, 3}, so we construct the DFA D 4 with eight states, one for each subset of N 4 s states. Thus D 4 s state set is {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. The start state of N 4 is 1, so the start state for D 4 should be ε-closure(1) = {1, 3}. The accepting states of D 4 should be the states that include an accepting state from N 4. The only accepting state of N 4 is 1, so the accepting states of D 4 are {{1}, {1, 2}, {1, 3}, {1, 2, 3}}. Lastly, the transitions can be found from the transitions of N 4 with careful analysis. We show the resulting D 4 in Figure 5. You should note that in the figure, there are six states although the power set of N 4 s states has eight elements. In particular, states corresponding to {1} and {1, 2} are not shown. This is because there is no way to reach these states when we start from the start state. Hence, we omitted these states in the figure. (Back to) Closure Properties Before we started discussing nondeterminism, we proved that the regular languages are closed under union operation (by constructing a machine for A B from the machines for A and B). This proof would be much easier with nondeterminism as follows. If we have machines M A and M B that recognize languages A and B respectively, we can simply combine these two to create a new machine M by adding only a new start state and adding ε-transitions from this new state to the individual start states of M A and M B. This is shown graphically in Figure 6. Closure Under Concatenation: If A and B are regular languages, prove that AB is also regular. Because A and B are regular languages, there must be machines N 1 and N 2 that recognize them. We can construct a new machine N from N 1 and N 2 as shown in Figure 7 to recognize AB. This construction involves taking only the accepting states of N 1, making them nonaccepting, and adding ε-transitions from these states to the start state of N 2. Start state of N is the start state of N 1. 3

Figure 6: M A and M B can be combined in this way to create M, which will recognize A B. Figure 7: N 1 and N 2 can be combined in this way to create N, which will recognize AB. 4

Figure 8: N 1 can be extended in this way to create N, which will recognize A. Theorem: Regular languages are closed under the star operation. Proof Idea: Let N 1 be the automaton that recognize language A. The procedure shown in Figure 8 can be used to construct N that can recognize A. 5