1 Finite Automata. 2 Introductory Example An automaton that accepts all legal Pascal identifiers: 1 2 3 Letter Digit Letter or Digit "yes" "no" 2.

Slides:



Advertisements
Similar presentations
CSE 311 Foundations of Computing I
Advertisements

CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Lecture 6 Nondeterministic Finite Automata (NFA)
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2005.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Introduction to Computability Theory
1 Introduction to Computability Theory Discussion1: Non-Deterministic Finite Automatons Prof. Amos Israeli.
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Homework #2 Solutions.
1 Languages and Finite Automata or how to talk to machines...
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Non-Deterministic Automata Regular Expressions.
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Finite Automata Costas Busch - RPI.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Finite-State Machines with No Output
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CS 3813: Introduction to Formal Languages and Automata Chapter 2 Deterministic finite automata These class notes are based on material from our textbook,
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
1 Pushdown Automata There are context-free languages that are not regular. Finite automata cannot recognize all context-free languages.
Three Basic Concepts Languages Grammars Automata.
Modeling Computation: Finite State Machines without Output
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho.
1.2 Three Basic Concepts Languages start variables Grammars Let us see a grammar for English. Typically, we are told “a sentence can Consist.
CS 154 Formal Languages and Computability February 9 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Non Deterministic Automata
Theory of Computation Lecture # 9-10.
Chapter 2 FINITE AUTOMATA.
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
Non Deterministic Automata
Finite Automata.
Chapter 1 Regular Language
Non Deterministic Automata
Presentation transcript:

1 Finite Automata

2 Introductory Example An automaton that accepts all legal Pascal identifiers: Letter Digit Letter or Digit "yes" "no" 2

3 Deterministic Finite Automata (DFA) M = (Q, , , q 0, F) Q: finite set of internal states  : finite set of symbols - input alphabet  : Q    Qtransition function q 0  Q: initial state F  Q: set of final states

4 Operational Manner Control unit q 0 Input file yes/no

5 Transition Graphs M = (Q, , , q 0, F) |Q| vertices (circles) Edge (q i, q j ) labelled a for  (q i, a) = q j Initial vertice q 0 Final vertices (double circles) in F

6 Example 1 M = ({q 0, q 1, q 2 }, {0, 1}, , q 0, {q 1 })  (q 0, 0) = q 0  (q 0, 1) = q 1  (q 1, 0) = q 0  (q 1, 1) = q 2  (q 2, 0) = q 2  (q 2, 1) = q 1 q0q0 q1q1 1 q2q

7 Extended Transition Function  (q 0, a) = q 1 &  (q 1, b) = q 2   * (q 0, ab) = q 2

8 Extended Transition Function  (q 0, a) = q 1 &  (q 1, b) = q 2   * (q 0, ab) = q 2  * (q, ) = q  * (q, wa) =  (  * (q, w), a)

9 Languages and DFAs M = (Q, , , q 0, F) L(M) = {w  * |  * (q 0, w)  F} L(M) = {w  * |  * (q 0, w)  F}

10 Example 1 M = ({q 0, q 1, q 2 }, {a, b}, , q 0, {q 1 }) L(M) = ? q0q0 q1q1 q2q2 a, b a b

11 Example 1 M = ({q 0, q 1, q 2 }, {a, b}, , q 0, {q 1 }) L(M) = {a n b | n  0} trap state q0q0 q1q1 q2q2 a, b a b

12 Theorem M = (Q, , , q 0, F) G M : associated transition graph w  +  * (q i, w) = q j iff there is a walk labelled w from q i to q j

13 Example 2 L(M) = {w  {a, b} * | w starts with ab}

14 Example 2 L(M) = {w  {a, b} * | w starts with ab} q0q0 q1q1 q2q2 b a, b b a trap state q3q3 a a, b

15 Example 3 L(M) = {w  {0, 1} * | w does not contain 001}

16 Example 3 L(M) = {w  {0, 1} * | w does not contain 001} , trap state

17 Regular Languages L is regular iff L = L(M) for some DFA M

18 Example 4 L = {awa | w  {a, b} * }

19 Example 4 L = {awa | w  {a, b} * } q0q0 q2q2 q3q3 b a b a trap state q1q1 a a, b b

20 Example 5 L = {awa | w  {a, b} * } L 2 = {aw 1 aaw 2 a | w 1, w 2  {a, b} * }

21 Example 5 L 2 = {aw 1 aaw 2 a | w 1, w 2  {a, b} * } q4q4 q5q5 ba b a trap state q1q1 a a, b b q0q0 q2q2 q3q3 b b a a b

22 Nondeterministic Finite Automata (NFA) M = (Q, , , q 0, F) Q: finite set of internal states  : finite set of symbols - input alphabet  : Q  (   { })  2 Q transition function q 0  Q: initial state F  Q: set of final states

23 Example 6 q1q1 q2q2 q3q3 a a q4q4 q5q5 a a q0q0 a a

24 Example 7 q0q0 q1q1 q2q , 1

25 Extended Transition Function  * (q i, w) = Q j

26 Extended Transition Function  * (q i, w) contains q j iff there is a walk labelled w from q i to q j

27 Example 8  * (q 1, a) = ?  * (q 2, ) = ? q0q0 q1q1 q2q2 a

28 Example 8  * (q 1, a) = {q 0, q 1, q 2 }  * (q 2, ) = {q 0, q 2 } q0q0 q1q1 q2q2 a

29 Example 8  * (q i, w) = ? q0q0 q1q1 q2q2 a

30 Example 8  * (q i, w) = ? Evaluate all walks of length at most  + (1 +  )|w|  is the number of -edges q0q0 q1q1 q2q2 a

31 Languages and NFAs M = (Q, , , q 0, F) L(M) = {w  * |  * (q 0, w)  F   }

32 Languages and NFAs q0q0 q1q1 q2q , 1 L(M) = ?

33 Languages and NFAs L(M) = {(10) n | n  0} q0q0 q1q1 q2q , 1

34 Languages and NFAs  * (q 0, 110) =  (q 2, 0) =  dead configuration q0q0 q1q1 q2q , 1

35 Homework Exercises: 1, 5, 6, 11, 14, 17, 15, 17 of Section Linz’s book. Exercises: 3, 4, 6, 7, 9, 10 of Section Linz’s book. Reading: Why nondeterminism - Linz’s book. Presentation: Section Linz’s book (procedures mark and reduce).

36 Equivalence of DFAs and NFAs A class of automata may be more powerful than another. DFA is a restricted kind of NFA. DFA:  (q i, a) = q j NFA:  (q i, a) = {q j }

37 Equivalence of DFAs and NFAs DFA and NFA are equally powerful. NFA:  * (q, w) = {q i, q j,..., q k } a label of one state

38 Example 9 2 Q = { , {q 0 }, {q 1 }, {q 0, q 1 }} q0q0 q1q1 q2q2 a b a

39 Example 9  ({q 0 }, a) = {q 1, q 2 }  ({q 0 }, b) =  q0q0 q1q1 q2q2 a b a

40 Example 9  ({q 0 }, a) = {q 1, q 2 }  ({q 0 }, b) =   ({q 1, q 2 }, a) = {q 1, q 2 }  ({q 1, q 2 }, b) = {q 0 } q0q0 q1q1 q2q2 a b a

41 Example 9 {q 0 } {q 1,q 2 } b a  b a a, b

42 Theorem Given M N = (Q N, ,  N, q 0N, F N ) there exists M D = (Q D, ,  D, q 0D, F D ) such that L(M D ) = L(M N )

43 Procedure NFA  DFA 1.Create G D with vertex q 0D = {q 0N }. 2.Repeat: Take any vertex {q i, q j,..., q k } of G D that has a missing edge for a . Compute  * (q i, a),  * (q j, a),...,  * (q k, a). Create new {q l, q m,..., q n } =  * (q i, a)  * (q j, a) ...  * (q k, a). Add {q i, q j,..., q k }  a  {q l, q m,..., q n }. 3.Every state of G D containing q f  F N is a final vertex. 4.If  L(M N ) then {q 0N } is also a final vertex.

44 Example 10 q0q0 q1q1 q2q2 0, 1 0 1

45 Homework Exercises: 3, 8, 11, 12 of Section Linz’s book. Exercises: 1, 4 of Section Linz’s book. Programming: Implement procedures mark and reduce (Section 2.4) (Submission: 15/October).