Finite Automata. BBM Automata Theory and Formal Languages 1

Similar documents
Finite Automata. Reading: Chapter 2

Finite Automata. Reading: Chapter 2

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Regular Expressions and Automata using Haskell

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Deterministic Finite Automata

Regular Languages and Finite State Machines

Reading 13 : Finite State Automata and Regular Expressions

Formal Deænition of Finite Automaton. 1. Finite set of states, typically Q. 2. Alphabet of input symbols, typically æ.

6.080/6.089 GITCS Feb 12, Lecture 3

Scanner. tokens scanner parser IR. source code. errors

Automata on Infinite Words and Trees

CS5236 Advanced Automata Theory

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

Automata and Computability. Solutions to Exercises

C H A P T E R Regular Expressions regular expression

Introduction to Automata Theory. Reading: Chapter 1

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Informatique Fondamentale IMA S8

Handout #1: Mathematical Reasoning

The Halting Problem is Undecidable

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Finite Automata and Regular Languages

Compiler Construction

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Midterm Practice Problems

Hint 1. Answer (b) first. Make the set as simple as possible and try to generalize the phenomena it exhibits. [Caution: the next hint is an answer to

Turing Machines: An Introduction

DISCRETE MATH: LECTURE 3

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Regular Languages and Finite Automata

Automata and Formal Languages

Reliability Guarantees in Automata Based Scheduling for Embedded Control Software

3515ICT Theory of Computation Turing Machines

Two Way F finite Automata and Three Ways to Solve Them

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Math Workshop October 2010 Fractions and Repeating Decimals

On a Structural Property in the State Complexity of Projected Regular Languages

Graph Theory Problems and Solutions

8 Divisibility and prime numbers

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

6.3 Conditional Probability and Independence

T Reactive Systems: Introduction and Finite State Automata

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

Introduction to Turing Machines

Lecture 1: Course overview, circuits, and formulas

6.2 Permutations continued

COMPUTER SCIENCE TRIPOS

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Lecture 1: Oracle Turing Machines

Cartesian Products and Relations

Composability of Infinite-State Activity Automata*

Properties of Stabilizing Computations

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

4.6 The Primitive Recursive Functions

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.


26 Integers: Multiplication, Division, and Order

NFAs with Tagged Transitions, their Conversion to Deterministic Automata and Application to Regular Expressions

CHAPTER 7 GENERAL PROOF SYSTEMS

Basic Proof Techniques

Regular Languages and Finite Automata

Genetic programming with regular expressions

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

Section 1. Logarithms

Preventing Denial of Service Attacks in a Calculus of Mobile Resources

Lecture I FINITE AUTOMATA

2.1 Complexity Classes

FINITE STATE AND TURING MACHINES

Converting Finite Automata to Regular Expressions

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Automata, languages, and grammars

The Optimum One-Pass Strategy for Juliet

Comparison of Standard, Integrated and Multimedia Information System (IS) with Solutions

Introduction to Logic in Computer Science: Autumn 2006

Practice with Proofs

A Course in Discrete Structures. Rafael Pass Wei-Lung Dustin Tseng

SECTION 10-2 Mathematical Induction

Full and Complete Binary Trees

1 Definition of a Turing machine

Introduction to Finite Automata

Hypothesis testing. c 2014, Jeffrey S. Simonoff 1

Database Design and Normal Forms

Omega Automata: Minimization and Learning 1

Proseminar on Semantic Theory Fall 2013 Ling 720. Problem Set on the Formal Preliminaries : Answers and Notes

Algorithmic Software Verification

Formal Verification of Software

03 - Lexical Analysis

On Winning Conditions of High Borel Complexity in Pushdown Games

Just the Factors, Ma am

24 Uses of Turing Machines

Testing LTL Formula Translation into Büchi Automata

The last three chapters introduced three major proof techniques: direct,

Boolean Algebra Part 1

Transcription:

Finite Automata BBM 401 - Automata Theory and Formal Languages 1

Deterministic Finite Automata (DFA) A Deterministic Finite Automata (DFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states 2. is a finite set of symbols (alphabet) 3. Delta ( ) is a transition function (q,a) p 4. q 0 is the start state (q 0 Q ) 5. F is a set of final (accepting) states ( F Q ) Transition function takes two arguments: a state and an input symbol. (q, a) = the state that the DFA goes to when it is in state q and input a is received. BBM 401 - Automata Theory and Formal Languages 2

Graph Representation of DFA s Nodes = states. Arcs represent transition function. Arc from state p to state q labeled by all those input symbols that have transitions from p to q. Arrow labeled Start to the start state. Final states indicated by double circles. 0 0,1 A 1 B 1 C Start 0 BBM 401 - Automata Theory and Formal Languages 3

Alternative Representation: Transition Table Arrow for start state Final states starred * * 0 1 A A B B A C C C C Columns = input symbols Rows = states BBM 401 - Automata Theory and Formal Languages 4

Strings Accepted By A DFA An DFA accepts a string w = a 1 a 2... a n if its path in the transition diagram that 1. Begins at the start state 2. Ends at an accepting state This DFA accepts input: 010001 This DFA rejects input: 011001 Start A 0 0,1 1 0 B 1 C BBM 401 - Automata Theory and Formal Languages 5

Extended Delta Function Delta Hat The transition function can be extended to ^ that operates on states and strings (as opposed to states and symbols) ^ (q, ) = q ^ (q,xa) = ( ^ (q,x), a) BBM 401 - Automata Theory and Formal Languages 6

Language Accepted by a DFA Formally, the language accepted by a DFA A is L(A) = { w ^ (q 0,w) F } Languages accepted by DFAs are called as regular languages. Every DFA accepts a regular language, and For every regular language there is a DFA accepts it BBM 401 - Automata Theory and Formal Languages 7

Language Accepted by a DFA 0 0,1 A 1 B 1 C Start 0 This DFA accepts all strings of 0 s and 1 s without two consecutive 1 s. Formally, L(A) = { w w is in {0,1}* and w does not have two consecutive 1 s } BBM 401 - Automata Theory and Formal Languages 8

DFA Example A DFA accepting all and only strings with an even number of 0's and an even number of 1's Tabular representation of the DFA BBM 401 - Automata Theory and Formal Languages 9

Proofs of Set Equivalence We need to prove that two descriptions of sets are in fact the same set. Here, one set is the language of this DFA, and the other is the set of strings of 0 s and 1 s with no consecutive 1 s. In general, to prove S=T, we need to prove two parts: S T and T S. That is: 1. If w is in S, then w is in T. 2. If w is in T, then w is in S. As an example, let S = the language of our running DFA, and T = no consecutive 1 s. 0 0,1 A 1 B 1 C Start BBM 401 - Automata Theory and Formal Languages 10 0

Proof Part 1 : S T To prove: if w is accepted by our DFA then w has no consecutive 1 s. Proof is an induction on length of w. Important trick: Expand the inductive hypothesis to be more detailed than you need. BBM 401 - Automata Theory and Formal Languages 11

The Inductive Hypothesis 1. If ^ (A, w) = A, then w has no consecutive 1 s and does not end in 1. 2. If ^ (A, w) = B, then w has no consecutive 1 s and ends in a single 1. Basis: w = 0; i.e., w = ε. (1) holds since ε has no 1 s at all. (2) holds vacuously, since ^ (A, ε) is not B. Important concept: If the if part of if..then is false, the statement is true. BBM 401 - Automata Theory and Formal Languages 12

Inductive Step Need to prove (1) and (2) for w = xa. (1) for w is: If ^ (A, w) = A, then w has no consecutive 1 s and does not end in 1. Since ^ (A, w) = A, ^ (A, x) must be A or B, and a must be 0 (look at the DFA). By the IH, x has no 11 s. Thus, w has no 11 s and does not end in 1. BBM 401 - Automata Theory and Formal Languages 13

Inductive Step Now, prove (2) for w = xa: If ^ (A, w) = B, then w has no 11 s and ends in 1. Since ^ (A, w) = B, ^ (A, x) must be A, and a must be 1 (look at the DFA). By the IH, x has no 11 s and does not end in 1. Thus, w has no 11 s and ends in 1. BBM 401 - Automata Theory and Formal Languages 14

Proof Part 1 : T S Now, we must prove: if w has no 11 s, then w is accepted by our DFA Contrapositive : If w is not accepted by our DFA then w has 11. Key idea: contrapositive of if X then Y is the equivalent statement if not Y then not X. BBM 401 - Automata Theory and Formal Languages 15

Using the Contrapositive Every w gets the DFA to exactly one state. Simple inductive proof based on: Every state has exactly one transition on 1, one transition on 0. The only way w is not accepted is if it gets to C. The only way to get to C [formally: ^ (A,w) = C] is if w = x1y, x gets to B, and y is the tail of w that follows what gets to C for the first time. If ^ (A,x) = B then surely x = z1 for some z. Thus, w = z11y and has 11. 0 0,1 A 1 B 1 C Start 0 BBM 401 - Automata Theory and Formal Languages 16

Nondeterministic Finite Automata (NFA) A NFA can be in several states at once, or, it can "guess" which state to go to next. A NFA state can have more than one arc leaving from that state with a same symbol. Example: An automaton that accepts all and only strings ending in 01. State q 0 can go to q 0 or q 1 with the symbol 0. BBM 401 - Automata Theory and Formal Languages 17

NFA Example What happens when the NFA processes the input 00101 In fact, all missing arcs go to a death state, the death state goes to itself for all symbols, and the death state is a non-accepting state. BBM 401 - Automata Theory and Formal Languages 18

Definition of Nondeterministic Finite Automata Formally, a Nondeterministic Finite Automata (NFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states 2. is a finite set of symbols (alphabet) 3. Delta ( ) is a transition function from Qx to the powerset of Q. 4. q 0 is the start state (q 0 Q ) 5. F is a set of final (accepting) states ( F Q ) Transition function takes two arguments: a state and an input symbol. (q, a) = the set of the states that the DFA goes to when it is in state q and input a is received. BBM 401 - Automata Theory and Formal Languages 19

NFA Table Representation The table representation of this NFA is as follows. NFA is its transition function is BBM 401 - Automata Theory and Formal Languages 20

Extended Transition Function for NFA Delta Hat ^ ^ ^ ^ ^ BBM 401 - Automata Theory and Formal Languages 21

Language of a NFA The language accepted by a NFA A is i.e. a string w is accepted by a NFA A iff the states that are reachable from the starting state by consuming w contain at least one final state. BBM 401 - Automata Theory and Formal Languages 22

Language of a NFA - Example Let's prove formally that the NFA accepts the language {x01 : x * }. We'll do a mutual induction on the following three statements, BBM 401 - Automata Theory and Formal Languages 23

Proof BBM 401 - Automata Theory and Formal Languages 24

BBM 401 - Automata Theory and Formal Languages 25

Equivalence of DFA and NFA NFA's are usually easier to construct. Surprisingly, for any NFA N there is a DFA D, such that L(D) = L(N), and vice versa. This involves the subset construction, an important example how an automaton B can be generically constructed from another automaton A. Given an NFA we will constract a DFA such that L(D) = L(N) BBM 401 - Automata Theory and Formal Languages 26

Subset Construction BBM 401 - Automata Theory and Formal Languages 27

Subset Construction - Example BBM 401 - Automata Theory and Formal Languages 28

Subset Construction Accessible States We can often avoid the exponential blow-up by constructing the transition table for D only for accessible states S as follows: BBM 401 - Automata Theory and Formal Languages 29

Subset Construction Accessible States (example) NFA DFA BBM 401 - Automata Theory and Formal Languages 30

Equivalence of DFA and NFA - Theorem Theorem: Let D be the subset DFA of an NFA N. Then L(D) = L(N). Proof: We show on an induction on w that Basis: w =. The claim follows from definition. Induction: So, L(D) =L(N) BBM 401 - Automata Theory and Formal Languages 31

Equivalence of DFA and NFA Theorem 2 Theorem: A language L is accepted by some DFA if and only if L is accepted by some NFA. Proof: The if-part is proved by the previous theorem. For the only-if-part, we note that any DFA can be converted to an equivalent NFA by modifying the D to N by the rule BBM 401 - Automata Theory and Formal Languages 32

A Bad Case for Subset Construction - Exponential Blow-Up There is an NFA N with n+1 states that has no equivalent DFA with fewer than 2 n states BBM 401 - Automata Theory and Formal Languages 33

A NFA for Text Search NFA accepting the set of keywords {ebay, web} BBM 401 - Automata Theory and Formal Languages 34

Corresponding DFA for Text Search BBM 401 - Automata Theory and Formal Languages 35

NFA with Epsilon Transitions - -NFA -NFA s allow transtions with label. Formally, -NFA is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states 2. is a finite set of symbols (alphabet) 3. Delta ( ) is a transition function from Q x { } to the powerset of Q. 4. q 0 is the start state (q 0 Q ) 5. F is a set of final (accepting) states ( F Q ) BBM 401 - Automata Theory and Formal Languages 36

-NFA Example An -NFA accepting decimal numbers consisting of: 1. An optional + or - sign 2. A string of digits 3. a decimal point 4. another string of digits One of the strings in (2) and.(4) are optional BBM 401 - Automata Theory and Formal Languages 37

-NFA Example - Transition Table Transition Table BBM 401 - Automata Theory and Formal Languages 38

Epsilon Closure We close a state by adding all states reachable by a sequence... Inductive denition of ECLOSE(q) Basis: q ECLOSE(q) Induction: p ECLOSE(q) and r (p, ) r ECLOSE(q) BBM 401 - Automata Theory and Formal Languages 39

Epsilon Closure ECLOSE(1) = {1,2,3,4,6} ECLOSE(2) = {2,3,6} ECLOSE(3) = {3,6} ECLOSE(4) = {4} ECLOSE(5) = {5,7} ECLOSE(6) = {6} ECLOSE(7) = {7} BBM 401 - Automata Theory and Formal Languages 40

Exdended Delta for -NFA Inductive definition ^ of for -NFA Basis: Induction: BBM 401 - Automata Theory and Formal Languages 41

Given an -NFA Equivalence of DFA and -NFA we will construct a DFA such that L(D) = L(E) BBM 401 - Automata Theory and Formal Languages 42

Equivalence of DFA and -NFA Subset Construction BBM 401 - Automata Theory and Formal Languages 43

Equivalence of DFA and -NFA Subset Construction - Example BBM 401 - Automata Theory and Formal Languages 44

Equivalence of DFA and -NFA - Theorem Theorem: A language L is accepted by some -NFA E if and only if L is accepted by some DFA D. Proof: We use D constructed using subset-construction and show by induction that Basis: Induction: BBM 401 - Automata Theory and Formal Languages 45