CHAPTER 1 Regular Languages

Slides:



Advertisements
Similar presentations
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Advertisements

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Introduction to Computability Theory
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
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.
Introduction to Computability Theory
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
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.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
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 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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.
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Dr. Gary Weiss, January Computer Language Theory Chapter 1: Regular Languages.
Theory of Languages and Automata By: Mojtaba Khezrian.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
CIS Automata and Formal Languages – Pei Wang
Foundations of Computing Science
Non Deterministic Automata
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
Principles of Computing – UFCFA3-30-1
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
Finite Automata Reading: Chapter 2.
CSE 2001: Introduction to Theory of Computation Fall 2009
Chapter Five: Nondeterministic Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
Regular Languages Finite Automata eg. Supermarket automatic door:
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
NFAs and Transition Graphs
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

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

Non-determinism So far in our discussion, every step of a computations follows in a unique way from the preceding step. 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. We call this deterministic computation. In a non-deterministic machine, several choices may exist for the next state at any point. 0, 1 1 q2 q1 q2 q3 q4 q0 q1 1 1 0, 1 0, 1 0, 1 A deterministic FA (DFA) A non-deterministic FA (NFA) Non-determinism is a generalization of determinism, so every DFA is automatically a NFA. The difference: - every state of a DFA has exactly one exiting arrow for each symbol - in a NFA a state may have 0, 1, or many exiting arrows for each symbol - a NFA may have arrows with the label

How does an NFA compute? After reading the symbol, the machine splits into multiple copies of itself and follows all the possibilities in parallel. Each copy takes one of the possible ways to proceed and continues as before. If there are subsequent choices, the machine splits again. If the next input symbol doesn’t appear on any of the arrows exiting the state occupied by a copy of the machine, that copy dies. If any one of these copies of the machine is in an accept state at the end of the input, the NFA accepts the input string. If a state with an symbol on an exiting arrow is encountered, the machine (w/o reading any input) splits into multiple copies, one following each of the exiting arrow with and one staying at current state. 0, 1 Non-determinism may be viewed as a kind of parallel computation wherein several “processes” can be running concurrently. q1 q2 q3 q4 1 1 0, 0, 1 A non-deterministic FA (NFA) (Run for inputs 11, 101)

Tree of Possibilities A way to think of a non-deterministic computation is as a tree of possibilities. The root corresponds to the start of the computation Every branching point in the tree corresponds to a point in the computation at which the machine has multiple choices The machine accepts if at least one of the computation branches ends in an accept state. symbol read start q1 q1 1 0, 1 q1 q2 q3 q1 q2 q3 q4 q1 q3 1 1 0, 1 0, 1 q1 q2 q3 q4 1 NFA (input is 010110) q1 q2 q3 q4 q4 q1 q3 q4 q4

NFA vs. DFA NFAs are useful in several aspects. q1 q2 q3 q4 Every NFA can be converted into an equivalent DFA (construction later). Constructing NFAs is sometimes easier than directly constructing DFAs. An NFA may be much smaller than its deterministic counterpart. Its functioning may be easier to understand. We will use non-determinism in more powerful computational models. Example. q000 q100 q010 q110 0,1 1 1 1 q1 q2 q3 q4 1 1 0,1 0,1 q001 q101 q011 q111 1 NFA 1 1 1 DFA They recognize the same language A={all strings over {0,1} containing a 1 in the third position from the end}

Formal Definition of NFAs A non-deterministic finite automaton (NFA) 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. For NFA we have Is a collection of all subsets of Q 0 1 q1 {q1} {q1,q2} q2 {q3} {q3} q3 {q4} q4 {q4} {q4} 0, 1 q1 q2 q3 q4 1 1 0, 0, 1 NFA

Acceptance of Strings and the Language of NFA Let N= be a NFA N accepts w if we can write w as , where each is a member of and a sequence of states exists in Q with the following three conditions: for and If L is a set of strings that N accepts, we say that L is the language of N and write L=L(N). We say N recognizes L or N accepts L. In this example, recognizes the strings a, baba, baa, but doesn’t accept the strings b, bb, babba. q1 a a b q2 q3 a,b

Subset Construction For , we define For every NFA there is an equivalent (accepts the same language) DFA. But the DFA can have exponentially many states. Let N= be an NFA. The equivalent DFA constructed by the subset construction is For , we define E(R)={ q: q can be reached from R by traveling along 0 or more arrows}. Then, ), ( . 1 Q P N D = ( = the set of subsets of ), 2. For and let contains an accept state of

Example And The Theorem a,b a b {1} {2} {1,2} a b a a,b b b 1 a {1,2,3} {3} {1,3} {2,3} a b a a a b b 2 3 simplifying a a,b a,b b a {1,3} {3} b a b b a a {1,2,3} {2} {2,3} b We have proved by construction that Theorem. Every NFA has an equivalent DFA. Corollary. A language is regular if and only if some NFA recognizes it.

A language is regular if and only if some NFA recognizes it. We have seen that for any NFA there exists an equivalent DFA. Hence A language is regular if and only if some NFA recognizes it. We will show today that regular languages are closed under regular operations. Regular Operations (again) Let L1 and L2 be languages. We defined the regular operations union, concatenation, and star as follows. Union: 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, …}

Th.1 The class of regular languages is closed under the union operation. We have regular languages L1 and L2 and want to prove that L1 L2 is regular. The idea is to take two NFAs N1 and N2 for L1 and L2, and combine them into one new NFA N. N must accept its input if either N1 or N2 accepts this input N will have a new state that branches to the start states of the old machines N1, N2 with arrows In this way N non-deterministically guesses which of the two machines accepts the input If one of them accepts the input then N will accept it, too recognizes L1 L2 recognizes L1 recognizes L2

Th.2 The class of regular languages is closed under the concatenation operation. We have regular languages L1 and L2 and want to prove that L1 L2 is regular. The idea is to take two NFAs N1 and N2 for L1 and L2, and combine them into a new NFA N. N accepts when the input can be split into two parts, the first accepted by N1 and the second by N2 We can think of N as non-deterministically guessing where to make the split recognizes L1 recognizes L2 recognizes L1 L2

Th.3 The class of regular languages is closed under the star operation. We have regular language L1 and want to prove that L1* is regular. We take an NFA N1 for L1, and modify it to recognize L1*. The resulting NFA N accepts its input if it can be broken into several pieces and N1 accepts each piece. N is like N1 with additional arrows returning to the start state from the accept state. In addition we must modify N so that it accepts , which always is a member of L1*. recognizes L1* recognizes L1

Homework Problems: 1.1, 1.2 (page 83 of the textbook); 1.3, 1.4, 1.5(a-d), 1.6, 1.7(a) (page 84 of the textbook); 1.8(b,c), 1.12(b) (page 85 of the textbook).