M = (Q,Σ,δ,q 0,F) Σ is the alphabet over which the transitions are defined.

Similar documents
Finite Automata and Regular Languages (part II)

Building a befer mousetrap. Transi-on Graphs. L = { abba } Building a befer mousetrap. L = { abba } L = { abba } 2/16/15

CS 4120 Lecture 3 Automating lexical analysis 29 August 2011 Lecturer: Andrew Myers. 1 DFAs

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Lecture 1: Finite State Automaton

Nondeterministic Finite Automata

Plan for Today and Beginning Next week (Lexical Analysis)

1.3 Regular Expressions

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

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

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

Nondeterminism and Epsilon Transitions

CSE Theory of Computing: Homework 3 Regexes and DFA/NFAs

Chapter Five: Nondeterministic Finite Automata

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

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

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

Computability Theory

FINITE STATE MACHINES (AUTOMATA)

Lecture 2: Regular Expression

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

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

Pseudo-automata for generalized regular expressions

Fooling Sets and. Lecture 5

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Automata and Languages

Formal Definition of a Finite Automaton. August 26, 2013

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

Finite Automata. Seungjin Choi

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Finite Automata. Finite Automata

September 7, Formal Definition of a Nondeterministic Finite Automaton

Pushdown Automata. Reading: Chapter 6

Deterministic Finite Automata (DFAs)

CISC 4090 Theory of Computation

Computability and Complexity

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Deterministic Finite Automata (DFAs)

CS243, Logic and Computation Nondeterministic finite automata

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

Deterministic Finite Automata (DFAs)

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

Finite Automata. Mahesh Viswanathan

Algorithms for NLP

Chapter Two: Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Closure under the Regular Operations

Formal Language and Automata Theory (CS21004)

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

Closure under the Regular Operations

Intro to Theory of Computation

Finite-State Machines (Automata) lecture 12

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

Automata Theory, Computability and Complexity

Nondeterministic finite automata

Lecture 4 Nondeterministic Finite Accepters

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,

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

Computer Sciences Department

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

Sri vidya college of engineering and technology

Name: Student ID: Instructions:

Deterministic Finite Automata (DFAs)

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Computational Models #1

(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},

Computational Models: Class 1

Theory of Computation

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Computational Models - Lecture 1 1

Decision, Computation and Language

CSE 105 Theory of Computation

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computation Turing Machine and Pushdown Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 154 Introduction to Automata and Complexity Theory

Non-deterministic Finite Automata (NFAs)

Lecture 3: Finite Automata. Finite Automata. Deterministic Finite Automata. Summary. Dr Kieran T. Herley

Constructions on Finite Automata

Deterministic Finite Automata

Course 4 Finite Automata/Finite State Machines

How do regular expressions work? CMSC 330: Organization of Programming Languages

Nondeterministic Finite Automata and Regular Expressions

Inf2A: The Pumping Lemma

Automata Theory CS F-04 Non-Determinisitic Finite Automata

Turing Machines Part III

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

DM17. Beregnelighed. Jacob Aae Mikkelsen

(Refer Slide Time: 0:21)

Theory of Computation Lecture 1. Dr. Nahla Belal

CSE 105 THEORY OF COMPUTATION

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

Formal Definition of Computation. August 28, 2013

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Transcription:

LECTURE 23 10.1 Formal Definition of a DFA Definition 10.1 A Deterministic Finite Automaton (DFA) M, is a five-tuple: where M = (Q,Σ,δ, 0,F) Q is a finite set of states. It is important that the set of states e finite, otherwise it wouldn t e a finite Automaton. Σ is the alphaet over which the transitions are defined. δ is the transition function. The transition function descries each transition that takes as input a state and a symol from the alphaet, and produces another state. In the example (vending machine) we would say that given state 0 and input symol d, the transition function would produce state 10, or that δ(0,d) = 10, therefore, δ : Q Σ Q. 0 is the start state. F is the set of final (accepting) states. The DFA will compute y processing one input symol at a time, until all the input has een used. If the state that the machine is in when all the input has een used is one of those in F, the machine is said to Accept, otherwise it is said to Reject. Example. We are asked to design a DFA that accepts only those strings of a s and s that have two consecutive s. When designing a DFA it is important to assign meaning to each of the states. For example, in the case of the vending machine, each state represents the amount of money the vending machine has at that point. We will keep track of how many consecutive s have een read at a given time, y having 3 states. If the machine is in the first one (state 0) it means that it has not found two consecutive s and the last symol read is not a. In the second state (state 1), the machine has not found two consecutive s yet, and the last symol read is a, in the third state (state 2), the machine has found two consecutive s. We can descrie the transitions in the following way: From state 0: 1

If an a is found, continue in state 0, no new has een found. If a is found, move to state 1. The last symol read was a. From state 1: If an a is found, move to state 0. The last symol read is not a. If a is found, move to state 2. The last two symols read were s. From state 2: Once in state 2, we know that the string has two consecutive s regardless of other symols read. So the machine will remain in state 2 when an a or a are found. The start state is state 0, and the final state is state 2. The previous description can e represented y the following DFA. a a, 0 1 2 a A machine can e descried in two ways 1. A transition diagram. As shown aove, a transition diagram contains all the information needed to descrie the DFA. It includes, the states, the alphaet, the transition function, the start state and the set of final states (with doule circle). 2. A formal description is given y explicitly showing all the five elements of a DFA. The following is a formal description of the machine shown aove in diagram form. M 1 = (Q 1,Σ 1,δ, 0,F) where: Q = {0,1,2} Σ = {a,} δ : Q Σ Q. δ can e descried as a tale, called a transition tale. δ a 0 0 1 1 0 2 2 2 2 2

0 = 0 F = {2} 10.1.1 Computation Tracing To trace the computation of a DFA when reading an input string w we use instantaneous configurations. We already used instantaneous configurations when tracing the computation of a vending machine. Each instantaneous configuration showsthe currentstate ofthe DFAaswellasthe unusedinput, andis represented y the notation [current state, unused string]. From each instantaneous configuration we can go to the next configuration y following the transition tale. In this case we say that the first configuration yields the next configuration. Formally, [ i,ax] [δ( i,a),x] Where a Σ and x Σ. Example. Let us trace the computation of machine M 1, descried aove, on input aa. [0,aa] [0,a] since δ(0,a) = 0 [1,a] since δ(0,) = 1 [0,] since δ(1,a) = 0 [1,] since δ(0,) = 1 [2,ǫ] since δ(1,) = 2 The computation ends when there is no more input to read, in which case we write an ǫ (empty string) as the unused string. Since the computation ended in state 2, which is a final state 2 F, then the M 1 accepts the string aa. Sometimes we want to say that a computation yields some configuration after several steps, in which case we use the symol. In the example, we could use the notation [0,aa] [2,ǫ] to represent a seuence of steps from the initial configuration [0, aa] to the final configuration [2, ǫ] We say that a DFA M = (Q,Σ,δ, 0,F) accepts a string w, if the computation of M on input w ends in a final state. Formally, Definition 10.2 M accepts w Σ if [ 0,w] [ f,ǫ], and f F. The language of a machine M is the set of all those strings that are accepted y the machine. Formally, 3

Definition 10.3 Given a DFA M = (Q,Σ,δ, 0,F), the language of the machine M is L(M) = {w Σ M accepts w} Example. We are asked to design a DFA for the language L = {w Σ w has an even numer of a s and an odd numer of s} As we said efore, it is useful to design a DFA y assigning some meaning to each one of the states. In this case there are several option for the string read at a given point y our machine. The string could have either an even numer of a s, and an even numer of s ( e,e ) an even numer of a s, and an odd numer of s ( e,o ) an odd numer of a s, and an even numer of s ( o,e ) an odd numer of a s, and an odd numer of s ( o,o ) The laels appearing in parentheses represent the names of the states. So we will have four states. We can easily uild the transition function ased on the descriptionofthesestates. Forinstance, ifthe machineisin state e,o readingan a, we know that the machine already read an even numer of a s, after reading the a, the machine will have read an odd numer of a s, ut the numer of s won t change. Therefore the new state should e o,o. Figure 10.1.1 shows the transition diagram of machine M. 4

e,e e,o a a a a o,e o,o Figure 1: Machine that accepts strings with even numer ofa s and odd numer of s 5