Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
CS21 Decidability and Tractability
Introduction to Computability Theory
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Finite Automata and Non Determinism
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections: September 1, 2006.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Non-Deterministic Automata Regular Expressions.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Topics Automata Theory Grammars and Languages Complexities
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Great Theoretical Ideas in Computer Science.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS 203: Introduction to Formal Languages and Automata
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Finite Automata & Regular Languages Sipser, Chapter 1.
Lecture Notes 
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
Lecture #5 Advanced Computation Theory Finite Automata.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Finite Automata.
Lecture2 Regular Language
Finite Automata a b A simplest computational model
Jaya Krishna, M.Tech, Assistant Professor
Lecture3 DFA vs. NFA, properties of RL
Finite Automata.
Regular Languages Finite Automata eg. Supermarket automatic door:
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
CHAPTER 1 Regular Languages
Presentation transcript:

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

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

Automata & Formal Languages, Feodor F. Dragan, Kent State University 3 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 that has three states q1q0 0 0 q2 0, 1 1 1

Automata & Formal Languages, Feodor F. Dragan, Kent State University 4 (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 q1q0 0 0 q2 0, 1 1 1

Automata & Formal Languages, Feodor F. Dragan, Kent State University 5 Formal Definition of DFAs A deterministic finite automaton (DFA) is specified by a 5-tuple, where is a finite set of states, is a finite alphabet, is the transition function, is the initial state, is the set of final states. A DFA is usually represented by a directed labeled graph (so called transition diagram) nodes = states, arc from q 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 q1q0 0 0 q2 0, 1 1 1

Automata & Formal Languages, Feodor F. Dragan, Kent State University 6 Acceptance of Strings and the Language of DFA Let M= be a finite automaton Let be a string over M accepts w if a sequence of states exists in Q with the following three conditions: for and q1q0 0 0 q2 0, 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( )=L, where L={ w: w contains at least one 1 and an even number of 0s follow the last 1 }

Automata & Formal Languages, Feodor F. Dragan, Kent State University 7 Regular Languages A language is called regular language if some finite automaton recognizes it. Main questions 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 question is Given a FA M, describe its language L(M) as a set of strings over its alphabet. First consider some examples: q1 1 q2 0 L( )={ w: w is or ends in a 0} q2 0 L( )={ w: w ends in a 1} q1 r1 q2r2 s L( )={ w: w starts and ends with the same symbol} a b b a b a b a a b

Automata & Formal Languages, Feodor F. Dragan, Kent State University 8 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 {0,1} with odd number of 1s.

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

Automata & Formal Languages, Feodor F. Dragan, Kent State University 10 Regular Operations Let L1 and L2 be languages. We define the regular operations union, intersection, concatenation, and star as follows. Union: Intersection: Concatenation: Star: Example: Let the alphabet be the standard 26 letters {a,b,…,z}. If L1={good, bad} and L2= {boy, girl}, then {good, bad, boy, girl}. {goodboy, badboy, goodgirl, badgirl}. {, good, bad, goodgood, badgood, badbad, goodbad, goodgoodgood, goodgoodbad, goodbadbad, …}

Automata & Formal Languages, Feodor F. Dragan, Kent State University 11 Product construction It would be useful if we can construct FAs for and from FAs for L1 and L2, no matter what L1 and L2. This would give a systematic way of constructing from the automata M1 and M2 an automaton that checks “if the input contains an odd number of 1’s or the substring 000” as well as “if the input contains an odd number of 1’s and the substring 000”. L(M1)={ w: w contains an odd number of 1’s} L( M2)={ w: w contains substring 000} qodd 1 qeven q 0 q0 1 0 q00 1 q ,1 0 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 12 Product construction Let M1= and M2= be two FA with the same alphabet. We define a finite automaton such that and such that as follows. where A,R 0 A,S 1 1 A,T 1 A,U B,R 0 B,SB,TB,U 0 1 Here, A=qood B=qeven R=q S=q0 T=q00 U=q000 ={ w: w contains an odd number of 1’s and the substring 000}

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