Computer Sciences Department

Similar documents
Automata: a short introduction

Nondeterminism. September 7, Nondeterminism

UNIT-III REGULAR LANGUAGES

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Theory of Computation (I) Yijia Chen Fudan University

Finite Automata and Regular languages

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

Closure under the Regular Operations

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

Theory of Computation (II) Yijia Chen Fudan University

TDDD65 Introduction to the Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Nondeterministic Finite Automata

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

Introduction to Languages and Computation

3515ICT: Theory of Computation. Regular languages

Closure under the Regular Operations

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

Theory of Languages and Automata

CPS 220 Theory of Computation REGULAR LANGUAGES

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

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

CSE 105 THEORY OF COMPUTATION

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

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models - Lecture 1 1

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

CS 455/555: Finite automata

Languages, regular languages, finite automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

What we have done so far

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CSE 105 THEORY OF COMPUTATION

Finite Automata. Seungjin Choi

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Computational Models #1

Applied Computer Science II Chapter 1 : Regular Languages

CS243, Logic and Computation Nondeterministic finite automata

Chapter Five: Nondeterministic Finite Automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

Name: Student ID: Instructions:

Theory of Computation Lecture 1. Dr. Nahla Belal

Lecture 17: Language Recognition

Computational Models Lecture 2 1

Computational Models Lecture 2 1

Computational Theory

CHAPTER 1 Regular Languages. Contents

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Fooling Sets and. Lecture 5

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

CISC 4090 Theory of Computation

(Refer Slide Time: 0:21)

Context-Free Languages

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

Critical CS Questions

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Computational Models - Lecture 3 1

Lecture 4: More on Regexps, Non-Regular Languages

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

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

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

Chapter 5. Finite Automata

Chapter 6. Properties of Regular Languages

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

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

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

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

Equivalence of DFAs and NFAs

Sri vidya college of engineering and technology

CPS 220 Theory of Computation

Part I: Definitions and Properties

Mathematics for linguists

Proving languages to be nonregular

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Computational Models - Lecture 3

CS21 Decidability and Tractability

Author: Vivek Kulkarni ( )

10. The GNFA method is used to show that

Finite Automata. Finite Automata

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

Chapter 3: The Church-Turing Thesis

CS 121, Section 2. Week of September 16, 2013

Finite-state machines (FSMs)

COMP4141 Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Computational Models - Lecture 4

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

UNIT-I. Strings, Alphabets, Language and Operations

Uses of finite automata

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

Computational Models: Class 1

Transcription:

1

Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3

objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular languages The regular operations Regular expression Non determinism/ determinism Equivalence of NFAS and DFAS Equivalence of regular expression with finite automata 4

REGULAR LANGUAGES 5

FINITE AUTOMATA Finite automata are good models for computers with an extremely limited amount of memory. The controller for an automatic door is one example of such a device. The controller is in either of two states: "OPEN" or "CLOSED," 6

State transition table? Closed Open N F R B 7

Shapes Figures State End state arrow State transition table? input State 8 8

Finite automaton It has three states, labeled ql, q2, and q3. The start state, q1, is indicated by the arrow pointing at it from nowhere. The accept state, q2, is the one with a double circle. The arrows going from one state to another are called transitions. 9

For example, when we feed the input string 1101 to the machine (state diagram), the processing proceeds as follows. Start in state q1. 2. Read 1, follow transition from q1 to q2. 3. Read 1, follow transition from q2 to q2. 4. Read 0, follow transition from q2 to q3. 5. Read 1, follow transition from q3 to q2-6. Accept because Machine is in an accept state q2 at the end of the input. 10

FORMAL DEFINITION OF A FINITE AUTOMATON 11

12

Case M1..100 13

EXAMPLES OF FINITE AUTOMATA 14

EXAMPLES OF FINITE AUTOMATA 15

16

17

REGULAR LANGUAGES 18

DESIGNING FINITE AUTOMATA you want to construct a finite automaton to recognize (the/a) language. you have determined the necessary information For example, suppose that the alphabet is { 0,1 } and that the language consists of all strings with an odd number of 1 s. You want to construct a finite automaton E1 to recognize this language. 19

1 s (even or odd)? Formal description????? Final state?????? 20

21

THE REGULAR OPERATIONS In arithmetic, the basic objects are numbers and the tools are operations for manipulating them, such as + and x. In the theory of computation the objects are languages and the tools include operations specifically designed for manipulating them. 22

THE REGULAR OPERATIONS (cont.) 23

Examples Concatenation aabaab = aabaab Union aa baab = aa and baab Closure ab*a = aa and abbba Parentheses a(a b)aab = aaaab and abaab (0* U 1*)?????????????? 24

NON DETERMINISM/ DETERMINISM In a nondeterministic machine, several choices may exist for the next state at any point. Nondeterminism is a generalization of determinism. Deterministic computation - when the machine is in a given state and reads the next input symbol, we know what the next state will be-it is determined. 25

NON DETERMINISM/ DETERMINISM (cont.) The difference between a deterministic finite automaton, abbreviated DFA, and a nondeterministic finite automaton NFA: 1. State: every state of a DFA always has exactly one exiting transition arrow for each symbol in the alphabet. 2. Transition arrow s Label: in a DFA, labels on the transition arrows are symbols from the alphabet. This NFA has an arrow with the label ɛ. 3. Nondeterminism may be viewed as a kind of parallel computation. 26

NON DETERMINISM/ DETERMINISM (cont.) If a state with an ɛ symbol on an exiting arrow is encountered, something similar happens. Without reading any input, the machine splits into multiple copies, one following each of the exiting є -labeled arrows and one staying at the current state. 27

28

The nondeterministic finite automaton State q1 has one exiting arrow for 0, but it has two for 1 = NDFA 29

The computation of input 010110 30

31

FORMAL DEFINITION OF A NONDETERMINISTIC FINITE AUTOMATON 32

FORMAL DEFINITION OF A NONDETERMINISTIC FINITE AUTOMATON 33

FORMAL DEFINITION OF A NONDETERMINISTIC FINITE AUTOMATON The following example explains a NFA M, with a binary alphabet, which determines if the input contains an even number of 0s or an even number of 1s. (Note that 0 occurrences is an even number of occurrences as well.) -Let M = (Q, Σ, T, s 0, F). -Describe the formal description? -Describe state transition table? -Describe the state diagram? 34

FORMAL DEFINITION OF A NONDETERMINISTIC FINITE AUTOMATON Formal description: Σ = {0, 1}, Q = {s 0, s 1, s 2, s 3, s 4 }, E({s 0 }) = { s 0, s 1, s 3 } F = {s 1, s 3 }, and The transition function T can be defined by this state transition table. 35

state diagram 1 The input contains an even number of 0s 36

state diagram 2 The input contains an even number of 1s 37

state diagram 1+2 38

state diagram 1+2 39

NFA An NFA for a language can be smaller and easier to construct than a DFA Strings whose next-to-last symbol is 1: 0 DFA: 1 NFA: 0 0 1 1 0,1 1 0,1 0 1 40

EQUIVALENCE OF NFAS AND DFAS NFAS AND DFAS machines are equivalent if they recognize the same language. THEOREM 1.39 Every nondeterministic finite automaton has an equivalent deterministic finite automaton 41

PROOF IDEA How would you simulate the NFA if you were pretending to be a DFA? What do you need to keep track of as the input string is processed? In the examples of NFAs you kept track of the various branches of the computation by placing a finger on each state that could be active at given points in the input. You updated the simulation by moving, adding, and removing fingers according to the way the NFA operates. All you needed to keep track (the set of states having fingers on them). 42

Regular Expressions and Nonregular Languages 43

REGULAR EXPRESSIONS In arithmetic, we can use the operations + and x to build up expressions such as (5 + 3) x 4. Similarly, we can use the regular operations to build up expressions describing languages, which are called regular expressions. An example is: (O U 1)0*. 44

45

46

EQUIVALENCE WITH FINITE AUTOMATA Fact: Regular expressions and finite automata are equivalent in their descriptive power. Any regular expression can be converted into a finite automaton that recognizes the language it describes, and vice versa. 47

48

49

50

51

Non-regularity B, C, and D seem to require machines with infinite number of to recognize them. B {0 n 1 n n 0} C { w w has an equal number of 0s and1s} D { w w has an equal number of occurrences of 01and 10 as substrings}. B and C will turn out to be nonregular while D regular. states 52

Theorem - Pumping Lemma If A is a regular language, then there is a number p (the pumpinglength) where, if s A with s p, then s can be divided into three pieces, s xyz, satisfyingthe following conditions : 1. for each i 0, xy 2. y 0, and 3. xy p. i z A, 53

54 Proof of Th 1.37 an accepting state. is where ) )( )( ( 2 1 2 1 2 1 a n l k a k k n l k q xyz s s s s s q q q q q s s s s s s

Example Claim: B {0 Proof. Assume the contrary that B is regular. Let p be the pumpinglength. Then, s 0 as s xyz with y 1, and There can be three cases y 1 nonzero k, l. In each case, we can eazily see that xy leads to contradiction. ( n n n n 0} is not regular. xy n 0 2) z B for any n 0. k, y 0 k p 1 p can be decomposed l l 1, and y 1, for some n z B, which 55

Example Claim: C { w w has an equal number of 0s and 1s} is not regular. Proof. Assume the contrary that C is regular. Let p be the pumpinglength. Then, s 0 as s xyz with y 1and xy p, and xy Then we must have y We can eazily see that xy 0 k n 1 for some nonzero k. p n p can be decomposed z C for any n 0. z C, which contradicts the assumption. 56

Example Claim: F { ww w {0,1} Proof. Assume the contrary that F is regular. Let p be the pumpinglength and let s into pieces like s xyz Then we must have y We can eazily see that xy with y 1and xy p, and xy 0 k n * } is not regular. 0 10 for some nonzero k. p p 1 F.This s can be split z F for any n z F, which contradicts the assumption. n 0. 57

Example - Pumping Down Claim: i E {0 1 Proof. Assume the contrary that E is regular. p 1 p Let p be the pumpinglength and let s 0. This s can be split n into s xyz with y 1and xy p, and xy z E for any n 0. Then we must have y We can eazily see that xy j i j} is not regular. 0 k 0 for some nonzero k. z xz E, which contradicts the assumption. 58