Formal Definition of a Finite Automaton. August 26, 2013

Similar documents
Formal Definition of Computation. August 28, 2013

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

Chapter Two: Finite Automata

Nondeterministic Finite Automata

Introduction to Languages and Computation

Finite Automata. Seungjin Choi

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

Closure under the Regular Operations

Lecture 3: Nondeterministic Finite Automata

Please give details of your answer. A direct answer without explanation is not counted.

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

Theory of Languages and Automata

Closure under the Regular Operations

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

Introduction to Computers & Programming

Chapter Five: Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

ECS 120 Lesson 15 Turing Machines, Pt. 1

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

Theory of Computation

Nondeterminism. September 7, Nondeterminism

Context-Free Languages

Computation Histories

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Embedded systems specification and design

Takeaway Notes: Finite State Automata

CSCC63 Worksheet Turing Machines

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

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

Decision, Computation and Language

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

MTH401A Theory of Computation. Lecture 17

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

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

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.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chapter 6. Properties of Regular Languages

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

Theory of Computation (I) Yijia Chen Fudan University

Lecture 13: Turing Machine

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

Automata and Languages

Nondeterministic Finite Automata

Chapter 3. Regular grammars

Nondeterministic Finite Automata and Regular Expressions

UNIT-I. Strings, Alphabets, Language and Operations

CISC 4090 Theory of Computation

Finite Automata (contd)

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

Einführung in die Computerlinguistik

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

Automata: a short introduction

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

Lecture 1: Finite State Automaton

Finite Automata. Mahesh Viswanathan

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Finite Automata and Regular languages

UNIT-III REGULAR LANGUAGES

Algorithms for NLP

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

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

Computability and Complexity

Regular Expressions Kleene s Theorem Equation-based alternate construction. Regular Expressions. Deepak D Souza

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

Non-emptiness Testing for TMs

CSE 105 THEORY OF COMPUTATION

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,

CSCI 2670 Introduction to Theory of Computing

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

UNIT-VIII COMPUTABILITY THEORY

UNRESTRICTED GRAMMARS

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

1 More finite deterministic automata

Equivalence of Regular Expressions and FSMs

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 154. Finite Automata, Nondeterminism, Regular Expressions

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

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

TAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA

Introduction to Finite-State Automata

Homework 1 Due September 20 M1 M2

Finite Automata Part One

Theory of Computation

Nondeterministic finite automata

A Universal Turing Machine

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CPS 220 Theory of Computation Pushdown Automata (PDA)

Chapter 6: NFA Applications

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Course 4 Finite Automata/Finite State Machines

Theory of Computation (II) Yijia Chen Fudan University

Transcription:

August 26, 2013

Why a formal definition? A formal definition is precise: - It resolves any uncertainties about what is allowed in a finite automaton such as the number of accept states and number of transitions exiting from a state A formal definition provides a notation: - Good notation helps think and express thoughts clearly

Parts of a finite automaton A finite set of states Rules for going from one state to another depending upon the input symbol A finite input alphabet that indicates the allowed symbols A start state A finite set of accept states Note: a formal definition will state that a finite automaton is a list of this five components

Observation In mathematical language a list of five elements is called a 5-tuple, hence a finite automaton can be defined as a 5-tuple We can denote the transition rules by a function called the transition function, δ : States Alphabet States Example: δ(q 0, x) = q 1

Formal definition A finite automaton is a 5-tuple (Q, Σ, δ, q 0, F ): 1. Q is a finite set called the set of states 2. Σ is a finite set called the alphabet 3. δ : Q Σ Q is the transition function 4. q 0 Q is the start (or initial) state 5. F Q is the set of accept (or final) states

Note Since the set F can be emptyset a finite automaton may have zero accept states Since transitions are described by a function, the function δ specifies exactly one next state for each possible combination of state and input symbol

Example finite automaton The automaton M 1 have been defined by the transition diagram in Figure 1 0 1 q 1 q 2 q 3 0, 1 Figure 1 : The finite automaton M 1 1 0

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 }

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 } 2. Σ = {0, 1}

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 } 2. Σ = {0, 1} 3. δ is described by the table:

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 } 2. Σ = {0, 1} 3. δ is described by the table: δ 0 1 q 1 q 1 q 2 q 2 q 3 q 2 q 3 q 2 q 2

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 } 2. Σ = {0, 1} 3. δ is described by the table: δ 0 1 q 1 q 1 q 2 q 2 q 3 q 2 q 3 q 2 q 2 4. q 1 is the start state

Formalizing M 1 M 1 = (Q, Σ, δ, q 1, F ) where 1. Q = {q 1, q 2, q 3 } 2. Σ = {0, 1} 3. δ is described by the table: δ 0 1 q 1 q 1 q 2 q 2 q 3 q 2 q 3 q 2 q 2 4. q 1 is the start state 5. F = {q 2 }.

Language of a machine Since a finite automaton is used here as the model of a computer we also refer to a finite automaton as a machine If A is the set of all strings that a machine M accepts, we say that A is the language of the machine M and write L(M) = A.

Terminology The term accept has a different meaning when we refer to machines accepting strings and machines accepting languages. In order to avoid confusion: Use accept when we refer to strings Use recognize when we refer to languages

Consequences A machine may accept several strings, but it always recognizes only one language If a machine accepts no strings, it still recognizes one language, namely the empty language Language recognized by machine M 1 is:

Consequences A machine may accept several strings, but it always recognizes only one language If a machine accepts no strings, it still recognizes one language, namely the empty language Language recognized by machine M 1 is: A = {w w contains at least one 1 and an even number of 0s follow the last 1} Conclusion: L(M 1 ) = A, or equivalently, M 1 recognizes A

Machine M 2 The state diagram in Figure 2 describes a machine M 2 0 1 1 q 1 q 2 0 Figure 2 : State diagram of the finite automaton M 2

Machine M 2 The state diagram in Figure 2 describes a machine M 2 0 1 1 q 1 q 2 0 Figure 2 : State diagram of the finite automaton M 2 Formally, M 2 = ({q 1, q 2 }, {0, 1}, δ, q 1, {q 2 }) where δ(q 1, 0) = q 1, δ(q 1, 1) = q 2, δ(q 2, 0) = q 1, δ(q 2, 1) = q 2

Note State diagram of M 2 and its formal description contain the same information, in different form A good way of understanding any machine is to try it on some sample input string Example: Discover the language of M 2,

Note State diagram of M 2 and its formal description contain the same information, in different form A good way of understanding any machine is to try it on some sample input string Example: Discover the language of M 2, L(M 2 ) = {w w ends in a 1}

Another example Consider the finite automaton M 3 in Figure 3 0 1 1 q 1 q 2 0 Figure 3 : State diagram of the finite automaton M 3 Note: M 3 is similar to M 2, except for the location of the accept state

Observations As usual, M 3 accepts all strings that leave it in an accept state when it has consumed the input. Because M 3 s start state is also accept state, M 3 accepts the empty string ɛ. it - Note: as soon as M 3 begins the reading of ɛ it is at the end, so it accepts In addition to ɛ, M 3 accepts any string that ends in 0

Observations As usual, M 3 accepts all strings that leave it in an accept state when it has consumed the input. Because M 3 s start state is also accept state, M 3 accepts the empty string ɛ. it - Note: as soon as M 3 begins the reading of ɛ it is at the end, so it accepts In addition to ɛ, M 3 accepts any string that ends in 0 L(M 3 ) = {w w is the empty string ɛ or ends in 0}

Machine M 4 Consider the five-state machine M 4, Figure 4 a b b s a b b r 1 q 1 a a q 2 r 2 Figure 4 : Finite automaton M 4 a b

Observations M 4 has two accept states, q 1 and r 1 M 4 operates over the alphabet Σ = {a, b} Some experimentation with M 4 shows that it accepts strings as a, b, aa, bb, bab and does not accept strings as ab, ba, bbba M 4 begins in state s and after it reads the first symbol in the input it either goes to the left to q states or to the right to r states

More observations

More observations Once M 4 goes to the left or to the right it can never return to the start state

More observations Once M 4 goes to the left or to the right it can never return to the start state If the first symbol in the string is a then it goes to the left and accepts when the strings ends with an a

More observations Once M 4 goes to the left or to the right it can never return to the start state If the first symbol in the string is a then it goes to the left and accepts when the strings ends with an a If the first symbol in the string is b then it goes to the right and accept when the strings ends with a b

More observations Once M 4 goes to the left or to the right it can never return to the start state If the first symbol in the string is a then it goes to the left and accepts when the strings ends with an a If the first symbol in the string is b then it goes to the right and accept when the strings ends with a b M 4 accepts strings that start and end with the same symbol.

Machine M 5 The state diagram in Figure 5 shows the machine M 5 which has a four-symbol input alphabet, Σ = { RESET, 0, 1, 2} where RESET is treated as a single symbol 2, RESET q 0 0, RESET 1 0 q 1 2 1, RESET 2 1 q 2 0 Figure 5 : Finite automaton M 5

Running M 5

Running M 5 M 5 keeps a running count of the sum of the numerical input symbols it reads, modulo 3.

Running M 5 M 5 keeps a running count of the sum of the numerical input symbols it reads, modulo 3. The three states of the automaton correspond to the three numbers 0,1,2.

Running M 5 M 5 keeps a running count of the sum of the numerical input symbols it reads, modulo 3. The three states of the automaton correspond to the three numbers 0,1,2. Every time the automaton receives the RESET symbol it resets the count to 0 while moving to state q 0.

Running M 5 M 5 keeps a running count of the sum of the numerical input symbols it reads, modulo 3. The three states of the automaton correspond to the three numbers 0,1,2. Every time the automaton receives the RESET symbol it resets the count to 0 while moving to state q 0. M 5 accepts if the sum is 0 modulo 3, i.e., if the sum is a multiple of 3.

Limitation of state diagrams It is not always possible to describe a finite automaton using a state diagram That may occur when the diagram would be too big to draw, or if, as in the case of M 5, the description depends on some unspecified parameter In these cases one needs to resort to a formal description to specify the machine

Example 1.15 Consider a generalization of the M 5 (example 1.13) using the same four symbol alphabet Σ For each i 0 let A i be the language of all strings where the sum of the numbers is a multiple of i, except that the sum is reset to 0 whenever a symbol RESET appears For each A i we construct a finite automaton B i recognizing A i

The automaton B i The machine B i is described formally as follows: B i = (Q i, Σ, δ i, q 0, {q 0 }) where Q i = {q 0, q 1,..., q i 1 } Σ = {0, 1, 2, RESET } δ i is designed so that for each j, 0 j i 1, if B i is in the state q j then the running sum is j modulo i. For each q j we set: δ i (q j, 0) = q j δ i (q j, 1) = q k, k = j + 1 modulo i δ i (q j, 2) = q k, k = j + 2 modulo i δ i (q j, RESET ) = q 0