Automata Theory CS F-04 Non-Determinisitic Finite Automata

Similar documents
Automata Theory CS F-08 Context-Free Grammars

CS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.

Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

CS 154, Lecture 3: DFA NFA, Regular Expressions

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Chapter 5. Finite Automata

CMSC 330: Organization of Programming Languages

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

CS 154. Finite Automata, Nondeterminism, Regular Expressions

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Nondeterminism. September 7, Nondeterminism

The assignment is not difficult, but quite labour consuming. Do not wait until the very last day.

Computer Sciences Department

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Nondeterministic Finite Automata and Regular Expressions

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

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

Lecture 1: Finite State Automaton

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

Automata and Languages

CS375 Midterm Exam Solution Set (Fall 2017)

CS 455/555: Finite automata

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

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

Chapter Five: Nondeterministic Finite Automata

Formal Definition of a Finite Automaton. August 26, 2013

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Finite State Machines. Languages g and Machines

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

Automata: a short introduction

Finite Automata Part Two

Author: Vivek Kulkarni ( )

Formal Languages and Automata

Decision, Computation and Language

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Lecture 3: Nondeterministic Finite Automata

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

CSCI 2670 Introduction to Theory of Computing

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

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

Sri vidya college of engineering and technology

Recap from Last Time

Graduate Algorithms CS F-20 String Matching

CISC 4090 Theory of Computation

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Section 1.3 Ordered Structures

Lecture 4: More on Regexps, Non-Regular Languages

Languages, regular languages, finite automata

Theory of Computation

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Uses of finite automata

Finite Automata Part Two

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

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

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

Finite-state machines (FSMs)

Theory of Computation Lecture 1. Dr. Nahla Belal

Computational Models - Lecture 3 1

Finite-State Machines (Automata) lecture 12

CSE 105 THEORY OF COMPUTATION

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

False. They are the same language.

In English, there are at least three different types of entities: letters, words, sentences.

Critical CS Questions

Computational Models - Lecture 4

UNIT-I. Strings, Alphabets, Language and Operations

Finite Automata. Seungjin Choi

Theory of Computation (I) Yijia Chen Fudan University

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

Constructions on Finite Automata

Closure under the Regular Operations

Deterministic Finite Automata (DFAs)

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

Finite Automata. Finite Automata

CS 154 Formal Languages and Computability Assignment #2 Solutions

Nondeterministic Finite Automata

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

Non-deterministic Finite Automata (NFAs)

Author: Vivek Kulkarni ( )

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

CS 133 : Automata Theory and Computability

Theoretical Computer Science

Lecture 7 Properties of regular languages

Inf2A: Converting from NFAs to DFAs and Closure Properties

Computational Theory

Pushdown Automata. Reading: Chapter 6

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

Text Search and Closure Properties

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Text Search and Closure Properties

Embedded systems specification and design

Transcription:

Automata Theory CS411-2015F-04 Non-Determinisitic Finite Automata David Galles Department of Computer Science University of San Francisco

04-0: Non-Determinism A Deterministic Finite Automata s transition function has exactly one transition for each state/symbol pair A Non-Deterministic Finite Automata can have 0, 1 or more transitions for a single state/symbol pair Example: L = {w {a,b} : w starts with a} Regular expression?

04-1: NFA Example Example: L = {w {a,b} : w starts with a} a(a+b)* a,b a 0 1

04-2: NFA Example Example: L = {w {a,b} : w starts with a} a(a+b)* a,b a 0 1 What happens if a b is seen in state q 0? The machine crashes, and does not accept the string

04-3: NFA Example Example: L = {w {a,b} : w contains the substring aa} Regular Expression?

04-4: NFA Example Example: L = {w {a,b} : w contains the substring aa} (a+b)*aa(a+b)* a,b a,b a a 0 1 2 What happens if a a is seen in state q 0?

04-5: NFA Example Example: L = {w {a,b} : w contains the substring aa} (a+b)*aa(a+b)* a,b a,b a a 0 1 2 What happens if a a is seen in state q 0? Stay in state q 0, or go on to state q 1 Multiple Computational Paths (board example)

04-6: NFA Example Example: L = {w {a,b} : w contains the substring aa} a,b a,b a a 0 1 2 (q0, abaa) (q0, baa) (q0,aa) (q0, a) (q0, ε) reject crash reject (q1, baa) (q1, a) (q1, ε) (q2, ε) reject accept Does this machine accept abaa?

04-7: NFA Acceptance If there is any computational path that accepts a string, then the machine accepts the string Two ways to think about NFAs: Magic Oracle, which always picks the correct path to take Try all possible paths

04-8: NFA Example Example: L = {w {a,b} : w contains the substring aa} a,b a,b a a 0 1 2 If a string contains aa, will there be a computational path that accepts it? If a string does not contain aa, will there be a computational path that accepts it?

04-9: NFA Definition Difference between a DFA and an NFA DFA has exactly only transition for each state/symbol pair δ : (K Σ) K NFA has 0, 1 or more transitions for each state/symbol pair

04-10: NFA Definition Difference between a DFA and an NFA DFA has exactly only transition for each state/symbol pair Transition function: δ : (K Σ) K NFA has 0, 1 or more transitions for each state/symbol pair Transition relation: ((K Σ) K)

04-11: NFA Definition A NFA is a 5-tuple M = (K,Σ,,s,F) K Set of states Σ Alphabet : (K Σ) K is a Transition relation s K Initial state F K Final states

04-12: Fun with NFA Create an NFA for: All strings over {a, b} that start with a and end with b

04-13: Fun with NFA Create an NFA for: All strings over {a, b} that start with a and end with b a,b 0 a b 1 3 (example compuational paths for ababb, abba, bbab)

04-14: Fun with NFA Create an NFA for: All strings over {0, 1} that contian 0110 or 1001

04-15: Fun with NFA Create an NFA for: All strings over {0, 1} that contian 0110 or 1001 0,1 0 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0,1 3

04-16: ǫ-transitions ǫ transition consumes no input NFA (with ǫ transitions) for (ab)*(aab)* a 1 1 b ε a a 1 1 1 b

04-17: ǫ-transitions Create an NFA (with ǫ-transitions) for: All strings over {a, b, c} that are missing at least one letter. For example, aabba, cbbc, ccacc L, while abbc L

04-18: ǫ-transitions Create an NFA (with ǫ-transitions) for: All strings over {a, b, c} that are missing at least one letter. For example, aabba, cbbc, ccacc L, while abbc L 0 ε ε ε 1 2 3 a,b b,c a,c abcb, bbab, abbab, abc

04-19: Yet More Formalism ǫ-closure ǫ-closure(q) = set of all states that can be reached following zero or more ǫ-transitions from state q.

04-20: ǫ-closure ǫ-closure examples 0 ε a 1 2 a b ε c b ε 3 4 5 6 ε ε a (quick review: What is L[M]?)

04-21: ǫ-closure ǫ-closure examples 0 ε a 1 2 a b ε c b ε 3 4 5 ε ε a L[M] = {a, aa, ba, ca, aba} 6

04-22: ǫ-closure ǫ-closure examples 0 ε a 1 2 a b ε c b ε 3 4 5 ε ε a 6 ǫ-closure(q 0 ) = ǫ-closure(q 3 ) = ǫ-closure(q 2 ) = ǫ-closure(q 5 ) =

04-23: ǫ-closure ǫ-closure examples 0 ε a 1 2 a b ε c b ε 3 4 5 ε ε a 6 ǫ-closure(q 0 ) = {q 0,q 1,q 4,q 5 } ǫ-closure(q 3 ) = {q 3,q 4,q 5 } ǫ-closure(q 2 ) = {q 2,q 6 } ǫ-closure(q 5 ) = {q 5 }

04-24: ǫ-closure Sets ǫ-closure ǫ-closure(q) = set of all states that can be reached following zero or more ǫ-transitions from state q. Can extend ǫ-closure to a set of states ǫ-closure(s) = {A : q S ǫ-closure(q) = A}

04-25: NFA Definition (revised) A NFA is a 5-tuple M = (K,Σ,,s,F) K Set of states Σ Alphabet : (K (Σ {ǫ})) K is a Transition relation s K Initial state F K Final states

04-26: NFA M Binary relation M : What machine M yields in one step M (K Σ ) (K Σ ) M = {((q 1,aw),(q 2,w)) : q 1,q 2 K M,w Σ M,a Σ M {ǫ},((q 1,a),q 2 ) M } Binary relation M : Transitive, reflexive closure of M

04-27: NFA Languages L[M] Language defined by NFA M L[M] = {w : (s M,w) M (f,ǫ) for some f F M } L NFA = {L : NFA M,L[M] = L}

04-28: NFA Examples Create an NFA for the language Give an NFA for the language L = All strings over {0,1} that contain two pairs of adjacent 0 s separated by an even number of symbols. So, 0100110011, 01100101100101, and 01001000 are in the language, but 0100100, 1011001, and 0111011 are not in the language.

04-29: NFA Examples Create an NFA for the language Give an NFA for the language L = All strings over {0,1} that contain two pairs of adjacent 0 s separated by an even number of symbols. So, 0100110011, 01100101100101, and 01001000 are in the language, but 0100100, 1011001, and 0111011 are not in the language. 0,1 0,1 0 0 0 0 0,1 0,1

04-30: NFA Examples Create an NFA for the language L = All strings over {a,b} that have an a as one of the last 3 charaters in the string. So, a, baab, bbbab, aabbaaabb L, but bb, baabbb, bbabbbbb L

04-31: NFA Examples Create an NFA for the language L = All strings over {a,b} that have an a as one of the last 3 charaters in the string. So, a, baab, bbbab, aabbaaabb L, but bb, baabbb, bbabbbbb L a,b a b b