Finite Automata. Seungjin Choi

Similar documents
Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

Nondeterministic Finite Automata

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

Theory of Languages and Automata

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

Chapter Five: Nondeterministic Finite Automata

Finite Automata. Finite Automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Chapter 5. Finite Automata

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Nondeterministic Finite Automata

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

Computer Sciences Department

Introduction to Automata

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

Lecture 4 Nondeterministic Finite Accepters

Automata and Languages

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Chapter 6: NFA Applications

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

Nondeterminism. September 7, Nondeterminism

Closure under the Regular Operations

Theory of Computation (I) Yijia Chen Fudan University

CS 455/555: Finite automata

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

Decision, Computation and Language

CPS 220 Theory of Computation REGULAR LANGUAGES

Deterministic (DFA) There is a fixed number of states and we can only be in one state at a time

Course 4 Finite Automata/Finite State Machines

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

Computational Models - Lecture 1 1

CISC 4090 Theory of Computation

Inf2A: Converting from NFAs to DFAs and Closure Properties

Formal Definition of a Finite Automaton. August 26, 2013

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 3: Nondeterministic Finite Automata

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

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,

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( )

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

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

Finite Automata and Regular languages

CHAPTER 1 Regular Languages. Contents

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Closure under the Regular Operations

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS243, Logic and Computation Nondeterministic finite automata

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

Computational Models #1

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Lecture 1: Finite State Automaton

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

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Nondeterministic Finite Automata

Deterministic Finite Automata (DFAs)

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Deterministic Finite Automata (DFAs)

UNIT-I. Strings, Alphabets, Language and Operations

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

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

Introduction to Languages and Computation

Chapter Two: Finite Automata

Uses of finite automata

Context-Free Grammars: Normal Forms

Takeaway Notes: Finite State Automata

September 7, Formal Definition of a Nondeterministic Finite Automaton

Sri vidya college of engineering and technology

Critical CS Questions

Deterministic Finite Automata (DFAs)

Formal Definition of Computation. August 28, 2013

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

Lecture 17: Language Recognition

Properties of Context-Free Languages

Chapter 2: Finite Automata

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Deterministic Finite Automaton (DFA)

Java II Finite Automata I

UNIT-III REGULAR LANGUAGES

Non-deterministic Finite Automata (NFAs)

Extended transition function of a DFA

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Theory of Computation (II) Yijia Chen Fudan University

front pad rear pad door

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

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

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

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

Finite Automata and Regular Languages (part III)

Theory of Computation

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

(Refer Slide Time: 0:21)

Finite Automata. Mahesh Viswanathan

CS 154, Lecture 3: DFA NFA, Regular Expressions

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Part I: Definitions and Properties

Languages, regular languages, finite automata

Transcription:

Finite Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 / 28

Outline Examples of finite automata (=finite state machine, good models for computers with extremely limited amount of memory) Deterministic finite automata (DFA) Nondeterministic finite automata (NFA) Equivalence between DFA and NFA More details and applications 2 / 28

An Example of FA: Automatic Door Two states: open or closed Four inputs: front, rear, both, neither. Front pad Rear pad rear both neither closed front open front rear both Door (a) Automatic Door neither (b) FA 3 / 28

An Example of FA: e-commerce Protocol for e-commerce using e-money Allowed events: 1. The customer can pay the store (=send he money-file to the store). 2. The customer can cancel the money (like putting a stop on a check). 3. The store can ship the goods to the customer. 4. The store can redeem the money (=cash the check). 5. The bank can transfer the money to the store. 4 / 28

5 / 28

6 / 28

7 / 28

Deterministic Finite Automata (DFA) Definition (DFA) A deterministic finite automaton is a quintuple (5-tuple), M = (Q, Σ, δ, q, F ), where Q: a finite set of states, Σ: a finite set of input symbols (input alphabet), δ : Q Σ Q: a transition function, q Q: a start state (an initial state), F Q: a set of final or accepting states. 8 / 28

1 q q 1 q 2 1 1 The DFA associated with this transition diagram is given by M = ({q, q 1, q 2 }, {, 1}, δ, q, {q 1 }), δ(q, ) = q, δ(q, 1) = q 1, δ(q 1, ) = q, δ(q 1, 1) = q 2, δ(q 2, ) = q 2, δ(q 2, 1) = q 1. M accepts 1, 11, 111, 111 and does not accept,1, 11. 9 / 28

Notations for DFA Transition diagram Transition table See Sec. 2.2.3 1 / 28

Extended Transition Function The extended transition function, δ : Q Σ Q, describes what happens when we start in any state and follow any sequence of inputs. For example, given δ(q, a) = q 1 and δ(q 1, b) = q 2, we have We can define δ recursively by δ (q, ɛ) = q, δ (q, ab) = q 2. δ (q, wa) = δ(δ (q, w), a), q Q, w Σ, a Σ. For example, δ (q, a) = δ(δ (q, ɛ), a) = δ(q, a) = q 1. Thus, δ (q, ab) = δ(δ (q, a), b) = δ(q 1, b) = q 2. 11 / 28

The Language of DFA Definition The language accepted by a DFA, M = (Q, Σ, δ, q, F ), is the set of all strings on Σ accepted by M, L(M) = {w Σ δ (q, w) F }. Example: L = { n 1 n }, the language accepted by the DFA shown below: 1, 1 q q 1 q 2, 1 12 / 28

Example: Find a DFA that recognizes the set of all strings on Σ = {a, b} starting with the prefix ab. Need 4 states: (1) a start state; (2) 2 states for recognizing ab ending in a final trap state; (3) one non-final trap state. a b q q 1 q 2 a, b q 3 a, b 13 / 28

Example: Find a DFA that accepts all the strings on Σ = {, 1}, except those containing the substring 1. 1 ǫ 1 1, 1 1 14 / 28

Regular Language Definition (Regular) A language L is called regular if and only if there exits a DFA M such that L = L(M). Regular language DFA What you need to do to show that L is regular, is to find a DFA M such that L = L(M). 15 / 28

Example: Show that the language, L = {awa w {a, b} } is regular. q a b b q 2 q 3 a b a q 1 a,b 16 / 28

Example: Show that L 2 is regular, where L 2 = {aw 1 aaw 2 a w 1, w 2 {a, b} }. q a b b b b a q 2 q 3 q 4 q 5 a b a a q 1 a,b 17 / 28

Nondeterministic Finite Automata (NFA) Definition (NFA) A nondeterministic finite automaton is a quintuple (5-tuple), M = (Q, Σ, δ, q, F ), where Q: a finite set of states, Σ: a finite set of input symbols (input alphabet), δ : Q (Σ {ɛ}) 2 Q : a transition function, q Q: a start state (an initial state), F Q: a set of final or accepting states. 18 / 28

Differences between DFA and NFA In NFA, the range of the transition function δ is the power set 2 Q, implying that several different movements are allowed. For example, δ(q 1, a) = {q, q 2 }. NFA can make a transition without consuming an input symbol. For example, δ(q, ɛ) = q 1. The set δ(q i, a) may be empty. In other words, no transition may be defined for a specific situation. 19 / 28

An Example of NFA, 1 q q 1 q 2 1 ǫ Several edges with the same label originate from one vertex ɛ-transition δ(q 2, ) = φ 2 / 28

NFA with Extended Transition Functions ǫ q q 1 ǫ q 2 For an NFA, the extended transition function is defined so that δ (q i, w) contains q j if and only if there is a walk in the transition graph from q i to q j labeled w. δ (q 1, ) = {q, q 1, q 2 } and δ (q 2, ɛ) = {q, q 2 }. 21 / 28

The Language of NFA Definition The language L accepted by an NFA, M = (Q, Σ, δ, q, F ), is defined by L(M) = {w Σ δ (q, w) F φ}. Example: L = {(1) n n } is accepted by the NFA shown below:, 1 q q 1 q 2 1 ǫ 22 / 28

Why Nondeterminism? Nondeterministic machines can serve as models of search-and-backtrack algorithms. Sometimes helpful in solving problems easily. Certain results are more easily established for NFA s than for DFA s. 23 / 28

Equivalence Definition Two finite automata M 1 and M 2 are said to be equivalent if L(M 1 ) = L(M 2 ), that is, they accept the same language., 1 q q 1 q 2 1 ǫ (a) NFA 1 q q 1 q 2 1 (b) DFA, 1 These two FAs are equivalent. 24 / 28

Equivalence of DFA and NFA Theorem For any NFA M N there exists a DFA M D such that and vice versa. L(M D ) = L(M N ) This involves the subset construction, an important example how an automaton M B can be generically constructed from another automaton M A. Given an NFA M N = (Q N, Σ, δ N, q, F N ), we will construct a DFA M D = (Q D, Σ, δ D, {q }, F D ) such that L(M D ) = L(M N ). 25 / 28

Subset Construction Q D = {S S Q N }, i.e., Q D = 2 Q N. Note that Q D = 2 Q N, although most states in Q D are likely to be garbage. F D = {S Q N S F N φ}. For every S Q N and a Σ, δ D (S, a) = q S δ N (q, a). 26 / 28

Example: Subset Construction, 1 1 q q1 q2 1 φ φ φ {q } {q, q 1 } {q } {q 1 } φ {q 2 } {q 2 } φ φ {q, q 1 } {q, q 1 } {q, q 2 } {q, q 2 } {q, q 1 } {q } {q 1, q 2 } φ {q 2 } {q, q 1, q 2 } {q, q 1 } {q, q 2 } 27 / 28

Example: An Equivalent DFA Determine states accessible from the start state and draw a transition graph: 1 {q } {q, q 1 } 1 {q, q 2 } 1 28 / 28