CHAPTER 1 Regular Languages. Contents

Similar documents
Critical CS Questions

CPS 220 Theory of Computation REGULAR LANGUAGES

Computational Models #1

Computational Models - Lecture 1 1

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

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

UNIT-III REGULAR LANGUAGES

Computational Models: Class 1

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

CISC 4090 Theory of Computation

Time Magazine (1984)

Introduction to Languages and Computation

CS 455/555: Finite automata

Non-Deterministic Finite Automata

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

Theory of Languages and Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Sri vidya college of engineering and technology

CS 154, Lecture 3: DFA NFA, Regular Expressions

Deterministic Finite Automata (DFAs)

Applied Computer Science II Chapter 1 : Regular Languages

Formal Definition of Computation. August 28, 2013

Deterministic Finite Automata (DFAs)

Computer Sciences Department

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

UNIT-I. Strings, Alphabets, Language and Operations

Deterministic Finite Automata (DFAs)

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

Nondeterministic Finite Automata

Finite Automata. Seungjin Choi

CS243, Logic and Computation Nondeterministic finite automata

Deterministic Finite Automata (DFAs)

CSE 105 THEORY OF COMPUTATION

Theory of Computation (II) Yijia Chen Fudan University

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

Theory of Computation (I) Yijia Chen Fudan University

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

Closure under the Regular Operations

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

Chapter 5. Finite Automata

Finite Automata and Regular languages

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

Closure under the Regular Operations

Computational Models - Lecture 4

Chapter Five: Nondeterministic Finite Automata

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

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

Theory of Computation Lecture 1. Dr. Nahla Belal

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

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

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

Deterministic Finite Automaton (DFA)

front pad rear pad door

CSE 105 THEORY OF COMPUTATION

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

Finite Automata and Languages

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,

Nondeterminism. September 7, Nondeterminism

Finite Automata Part Two

What we have done so far

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

Intro to Theory of Computation

Uses of finite automata

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Equivalence of DFAs and NFAs

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Theory of Computation

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

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

CS 154 Introduction to Automata and Complexity Theory

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Homework. Staff. Happy and fruitful New Year. Welcome to CS105. (Happy New Year) שנה טובה. Meeting Times.

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

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

Finite-State Machines (Automata) lecture 12

Automata: a short introduction

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

CS21 Decidability and Tractability

3515ICT: Theory of Computation. Regular languages

Name: Student ID: Instructions:

Inf2A: Converting from NFAs to DFAs and Closure Properties

Non-deterministic Finite Automata (NFAs)

Nondeterminism and Epsilon Transitions

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

Finite Automata Part One

Chapter 6. Properties of Regular Languages

CSC236 Week 10. Larry Zhang

The View Over The Horizon

CSE 105 Theory of Computation Professor Jeanne Ferrante

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

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

Decidability (intro.)

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

CSE 105 THEORY OF COMPUTATION

Lecture 3: Nondeterministic Finite Automata

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

Lecture 17: Language Recognition

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

Transcription:

Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure under regular operations Regular expressions definitions, euivalence with finite automata Non-regular Languages the pumping lemma for regular languages Automata & Formal Languages, Feodor F. Dragan, Kent State University

Finite Automata A simplest computational model Models computers with very small amount of memory various electromechanical devices rear Example: automatic door controller front i.e., entries, exits in supermarkets Two states: open, closed 4 possible inputs (from two sensors) front both rear neither State transition table Input signal neither front rear both State diagram rear both neither front front rear both State closed closed open closed closed open closed open open open closed open neither Automata & Formal Languages, Feodor F. Dragan, Kent State University

Finite Automata Other examples: elevator controller, dish washers, digital watches, calculators Next we will give a definition of FA from mathematical prospective terminology for describing and manipulating FA theoretic results describing their power and limitation A finite automaton M that has three states, Automata & Formal Languages, Feodor F. Dragan, Kent State University 3

(Deterministic) Finite Automata: Definition An important way to describe certain simple but highly useful languages called regular languages. It is A graph with a finite number of nodes, called states. Arcs are labeled with one or more symbols from some alphabet. One state is chosen as the start state or initial state. Some states are final states or accepting states. The language of the FA is the set of strings that label paths that go from the start state to some final state. Example: a finite automaton that has three states M, Automata & Formal Languages, Feodor F. Dragan, Kent State University 4

Formal Definition of DFAs A deterministic finite automaton (DFA) is specified by a 5-tuple ( Q, Σ, δ,, where, F) Q is a finite set of states, Q = {,, } Σ is a finite alphabet, Σ = {,} δ : Q Σ Q is the transition function, δ (,) =, δ (,) =, Q is the initial state, = is the set of final states. F = {} F Q A DFA is usually represented by a directed labeled graph (so called transition diagram) nodes = states, arc from to p is labeled by the set of input symbols a such that no arc if no such a, start state indicated by word start and an arrow, accepting states get double circles. For DFA we have M Automata & Formal Languages, Feodor F. Dragan, Kent State University 5 δ (, a) =,... p

Acceptance of Strings and the Language of DFA Let M= ( Q, Σ, δ,, F ) be a finite automaton Let be a string over w = w, w,..., w n M accepts w if a seuence of states r exists in Q with, r, r,..., r n the following three conditions: Σ. r =,. δ ( ri, wi ) = ri + 3. r n F for i =,...,, and + n If L is a set of strings that M accepts, we say that L is the language of machine M and write L=L(M). We say M recognizes L or M accepts L. In our example, L( M )=L, where L={w: w contains at least one and an even number of s follow the last } Automata & Formal Languages, Feodor F. Dragan, Kent State University 6,

Regular Languages A language is called regular language if some finite automaton recognizes it. Main uestions is: Given a language L, construct, if possible, a FA M which recognizes L, i.e., L(M)=L. (Is L a regular language?) Another uestion is Given a FA M, describe its language L(M) as a set of strings over its alphabet. First consider some examples: L( M )={w: w ends in a } b r L( M 3 )={w: w is ε or ends in a } L( M 4 )={w: w starts and ends with the same symbol} Automata & Formal Languages, Feodor F. Dragan, Kent State University 7 a b a a s a b r b b a

Design of DFAs Given a language, design a finite automaton that recognizes it. This is a creative process, is art. No simple universal methods. One intuitive way: put yourself in the place of the machine you are trying to design and see how you would go about performing the machine s task. we need to receive a string and to determine whether it is a member of the language. we get to see the symbols in the string one by one. after each symbol we must decide whether the string seen so far is in the language (we don t know when the end of the string is coming, so we must always be ready with the answer). we have a finite memory, so we have to figure out what we need to remember about the string as we are reading it (we cannot remember all we have seen). In this way we will find out how many states our automaton will have (and what are the states). Example: the language consists of all strings over alphabet {,} with odd number of s. Automata & Formal Languages, Feodor F. Dragan, Kent State University 8

e o Two possibilities:. Even so far,. Odd so far. Hence two states. Design of a FA for L={strings containing } We scan our string. There are four possibilities:. have not just seen any symbol of the pattern,. have just seen a, 3. have just seen, or 4. have seen the entire pattern. So, four states,,, Therefore, L={strings with odd number of s}, Automata & Formal Languages, Feodor F. Dragan, Kent State University 9

Regular Operations Let L and L be languages. We define the regular operations union, intersection, concatenation, and star as follows. Union: Intersection: Concatenation: Star: L L = { w : L L = { w : Lo L = { wv : L * = { w w... w w L w L w L L}. Example: Let the alphabet Σ be the standard 6 letters {a,b,,z}. If L={good, bad} and L= {boy, girl}, then L L = {good, bad, boy, girl}. k : k or and and and w L}. w L}. v L}. each L L = Lo L = {goodboy, badboy, goodgirl, badgirl}. * L = { ε, good, bad, goodgood, badgood, badbad, goodbad, goodgoodgood, goodgoodbad, goodbadbad, } w i Automata & Formal Languages, Feodor F. Dragan, Kent State University

Product construction It would be useful if we can construct FAs for L L and from FAs for L and L, no matter what L and L. This would give a systematic way of constructing from the automata M and M an automaton that checks if the input contains an odd number of s or the substring as well as L L if the input contains an odd number of s and the substring. even odd L(M)={w: w contains an odd number of s} L( M)={w: w contains substring } we can run both automata in parallel, by remembering the states of both automata while reading the input. This is achieved by the product construction, Automata & Formal Languages, Feodor F. Dragan, Kent State University

Product construction Let M= ( Q, Σ, δ,, F ) and M= ( Q, Σ, δ,, F ) be two FA with the same alphabet. We define a finite automaton M such that L( M ) = L( M) L( M ) and such that L( M ) = L( M) L( M ) as follows. M M M A,R B,R = ( Q, Σ, δ, = ( Q, Σ, δ,, F, F A,S L( M ) = L( M) L( M ) ) ) where A,T Q = Q δ (( ( ( = ( ) F Automata & Formal Languages, Feodor F. Dragan, Kent State University,,, ) F A,U Q ), a) = ( δ (, B,S B,T B,U, ), iff iff F, a), δ ( F or and, a)), F F Here, A=ood B=even R= S= T= U= ={w: w contains an odd number of s and the substring }.,

Product construction A,R B,R A,S A,T A,U B,S B,T B,U L( M ) = L( M) L( M ) ={w: w contains an odd number of s or the substring } We have proved by construction that Theorem. The class of regular languages is closed under the union operation. Theorem. The class of regular languages is closed under the intersection operation. Later we will show that they are closed under concatenation and star operations. Automata & Formal Languages, Feodor F. Dragan, Kent State University 3