1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
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.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Theory Of Automata By Dr. MM Alam
Finite Automata CPSC 388 Ellen Walker Hiram College.
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.
YES-NO machines Finite State Automata as language recognizers.
Finite Automata with Output
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Cohen, Chapter 61 Introduction to Computational Theory Chapter 6.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Non-Deterministic Automata Regular Expressions.
Finite Automata Chapter 5. Formal Language Definitions Why need formal definitions of language –Define a precise, unambiguous and uniform interpretation.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
Finite-State Machines with No Output
Basics of automata theory
THEORY OF COMPUTATION 08 KLEENE’S THEOREM.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
Theory of computing, part 3. 1Introduction 2Theoretical background Biochemistry/molecular biology 3Theoretical background computer science 4History of.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Lecture # 15. Mealy machine A Mealy machine consists of the following 1. A finite set of states q 0, q 1, q 2, … where q 0 is the initial state. 2. An.
Recap: Transformation NFA  DFA  s s1s1... snsn p1p1 p2p2... pmpm >...  p1p1  p2p2  pipi s e s1s1 e s2s2 e sisi >
1 Chapter Constructing Efficient Finite Automata.
using Deterministic Finite Automata & Nondeterministic Finite Automata
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.
Conversions Regular Expression to FA FA to Regular Expression.
1 Chapter 3 Regular Languages.  2 3.1: Regular Expressions (1)   Regular Expression (RE):   E is a regular expression over  if E is one of:
1 Introduction to the Theory of Computation Regular Expressions.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1 Section 11.3 Constructing Efficient Finite Automata First we’ll see how to transform an NFA into a DFA. Then we’ll see how to transform a DFA into a.
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Deterministic Finite Automata Nondeterministic Finite Automata.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
L ECTURE 3 T HEORY OF AUTOMATA. E QUIVALENT R EGULAR E XPRESSIONS Definition Two regular expressions are said to be equivalent if they generate the same.
1 Finite Automata. 2 Introductory Example An automaton that accepts all legal Pascal identifiers: Letter Digit Letter or Digit "yes" "no" 2.
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
Kleene’s Theorem and NFA
Complexity and Computability Theory I
Chapter 2 FINITE AUTOMATA.
REGULAR LANGUAGES AND REGULAR GRAMMARS
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
NFAs and Transition Graphs
Finite Automata.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Theory of computing, part 3
Recap lecture 20 Recap Theorem, Example, Finite Automaton with output, Moore machine, Examples.
Finite Automaton with output
NFAs and Transition Graphs
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton (DFA) over an alphabet A is a finite digraph (where vertices or nodes are called states) for which each state emits one labeled edge for each letter of A. One state is designated as the start state and a set of states may be final states. Example. Either of the following alternatives is acceptable for representing a DFA, where final states are indicated by double circles. The Execution of DFA for input string w  A* begins at the start state and follows a path whose edges concatenate to w. The DFA accepts w if the path ends in a final state. Otherwise the DFA rejects w. The language of a DFA is the set of accepted strings. Example. The example DFA accepts the strings a, b, ab, bb, abb, bbb, …, ab n, bb n, …. So the language of the DFA is given by the regular expression (a + b)b*. Start a a b b b a a, b a b

2 Quiz. Find a DFA for the language of a + aa*b. Theorem (Kleene) The class of regular languages is exactly the same as the class of languages accepted by DFAs. Quiz. Find an DFA for each of the following languages over the alphabet {a, b}. (a) . (b) {  }. (c) {(ab) n | n  N}, which has regular expression (ab)*. Start a, b a a b a b b 2 3 Solution: (b): Start a, b Solutions: (a): Start a, b (c): Start b a, b a a b

3 Table Representation of a DFA A DFA over A can be represented by a transition function T : States  A  States, where T(i, a) is the state reached from state i along the edge labeled a, and we mark the start and final states. For example, the following figures show a DFA and its transition table. Start a, b a b Start a a b a b A solution: b a b a, b Note: T can be extended to T : States  A*  States by T(i,  ) = i and T(i, aw) = T(T(i, a), w) for a  A and w  A*. Quiz: Calculate T(0, bba). Solution: T(0, bba) = T(1, ba) = T(1, a) = T(2,  ) = 2. Example/Quiz. Back to the problem of describing input strings over {a, b} that contain exactly one substring bb. We observed that the strings could be described by the regular expression (a + ba)*bb(a + ab)*. Find a DFA to recognize the language.

4 Nondeterministic Finite Automata A nondeterministic finite automaton (NFA) over an alphabet A is similar to a DFA except that  -edges are allowed, there is no requirement to emit edges from a state, and multiple edges with the same letter can be emitted from a state. Example. The following NFA recognizes the language of a + aa*b + a*b. Start a a  a b Table representation of NFA An NFA over A can be represented by a function T : States  A  {  }  power(States), where T(i, a) is the set of states reached from state i along the edge labeled a, and we mark the start and final states. The following figure shows the table for the preceding NFA.

5 Start Solutions: (a): Start (b): Start b a (c): Theorem (Rabin and Scott) The class of regular languages is exactly the same as the class of languages accepted by NFAs. Quizzes. Find an NFA for each of the following languages over {a, b}. (a) . (b) {  }. (c) {(ab) n | n  N}, which has regular expression (ab)*. ExampleQuiz. Back to the problem of describing input strings over {a, b} that contain exactly one substring bb. We observed that the strings could be described by the regular expression (a + ba)*bb(a + ab)*. Find an NFA to recognize the language. A solution: Start a b a b b a a b

6 Algorithm: Transform a Regular Expression into a Finite Automaton Start by placing the regular expression on the edge between a start and final state: Regular expression Start Apply the following rules to obtain a finite automaton after erasing any  -edges. R + S i j R i j S transforms to RS i j ij R S transforms to R*R* i j ij   R Quiz. Use the algorithm to construct a finite automaton for (ab)* + ba. Start a b b a   Answer:

7 Algorithm: Transform a Finite Automaton into a Regular Expression Connect a new start state s to the start state of the FA and connect each final state of the FA to a new final state ƒ as shown in the figure.   Given FA Connect to start state of FA s ƒ Connect from each final state of FA If needed, combine all multiple edges between the same two nodes into one edge with label the sum of the labels on the multiple edges. If there is no edge between two states, assume there is an  -edge. Now eliminate each state k of the FA by constructing a new edge (i, j) for each pair of edges (i, k) and (k, j) where i ≠ k and j ≠ k. The new label new(i, j) is defined in terms of the old labels by the formula new(i, j) = old(i, j) + old(i, k)old(k, k)*old(k, j) D A C B i k j A + BC*D i j Example. becomes

8 Quiz. Use the algorithm to transform the following NFA into a regular expression. (Half the class eliminate state 0 then state 1 and half the class eliminate state 1 then state 0.) Solution: Connect the NFA to new a start state s and a new final state f as pictured. Start a a b 0 1 a a b 0 1 sƒ   First Solution: Eliminate state 0 to obtain: new(s, 1) =  +  a*a = a*a. new(1, 1) =  + ba*a = ba*a. sƒ 1 a*a ba*aba*a  sƒ a*a(ba*a)* Second Solution: Eliminate state 1 to obtain: new(0, f) =  + a  *  = a. new(0, 0) = a + a  *b = a + ab. sƒ 0  a + ab a sƒ (a + ab)*a Eliminate state 1 to obtain: new(s, f) =  + a*a(ba*a)*  a*a(ba*a)*. Eliminate state 0 to obtain: new(s, f) =  +  (a + ab)*a  (a + ab)*a 

9 Quiz. Use regular algebra to show the following equality from the previous quiz. a*a(ba*a)* = (a + ab)*a. Proof: a*a(ba*a)*= a*[a((ba*)a)*]· is associative = a*[(a(ba*))*a]R(SR)* = (RS)*R = a*[((ab)a*)*a] · is associative = [a*((ab)a*)*]a · is associative = (a + ab)*a R*(SR*)* = (R + S)*. QED. i/A a j/B a/A i j Automata with Output (Mealy and Moore) Mealy machine: Associate an output action with each transition between states. Challenge: Describe a two-floor elevator system with a Mealy or Moore machine. Start 0/1 0 1/0 Start 0/  2/0 1/ Solutions: Moore machine: Associate an output action with each state. Theorem: Mealy and Moore machines are equivalent. Example/Quiz. Output the complement of a binary number.