CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.

Slides:



Advertisements
Similar presentations
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Advertisements

Lecture 24 MAS 714 Hartmut Klauck
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2005.
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
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
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.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
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)
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
1 Languages and Finite Automata or how to talk to machines...
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
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.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Basics of automata theory
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
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
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS 203: Introduction to Formal Languages and Automata
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
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.
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
Conversions Regular Expression to FA FA to Regular Expression.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Languages.
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
CSE 105 theory of computation
Hierarchy of languages
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

Chapter One Finite Automata

Outline Finite Automata Deterministic vs Nondeterministic finite automata, and their equivalence Finite Automata vs. regular expressions, and their equivalence Pumping lemma and non-regular languages

What Is a Finite Automaton? Input tape a b a b a a b b a … Input Tape Reading tape States, initial state, final states Moves Computation Accepting an input string Rejecting an input string q0 q5 q1 q4 q2 q3 Finite Control Reading head

Formal Definition A deterministic finite automaton is a quintuple M = (K, Σ, δ, s, F) where  K is a finite set of states;  Σ is a finite alphabet,  s  K is the initial state,  F  K is the set of final states,  δ is the transition function from K x Σ  K Explain K, Σ, δ, s, F.  The hardest one is δ.  What does δ(p, a) = q mean?

Configurations How to describe moves involved in a computation process?  Configurations Formal definition of configuration is very simple  A configuration is any element of K x Σ*. Given a configuration (q, w), q  K, w  Σ*,  What is its physical meaning?  For example, (q, aabbab)?

Yield Relation The yield relation We must understand that the yield relation describes exactly one step of a computation processing.

Because the yield relation is a relation, we can find a unique reflexive and transitive closure of. Denote the closure as Now, Given any two configurations (p, w) and (p’, w’),  If (p,w) (p’,w’)  then we say that (p,w) yields (p’,w’) stop! Think about the physical meaning of (p, w) yielding (p’, w’)!

The Language Accepted by a DFA The language accepted by an DFA M is  L(M) = { w: w  Σ*, (s, w) (q, e) for some q  F } Explain the definition.

Ex’s of DFA’s M = (K, Σ, δ, s, F)   δ is given in the following table Show computation form What is L(M)?

State Diagram State Diagram of a DFA M= (K, Σ, δ, s, F):  A directed graph:  for each state in K, draw a node  for each final state in F, draw a double circle.  Mark the initial node of the initial state >.  If δ(p, a) = q, then draw an edge from p to q and label it with a. Ex. The state diagram representation of a DFA is simple and intuitive. a a b b q o q 1

Design DFAs to Accept L1 = {w: w  {a,b}*, w has no three consecutive b’s} L2 = {w: w  {a,b}*, w has abab as a substring} L3 = {w: w  {a,b}*, w has no aa nor bb}

L1

L2 a b a,b b bb aa a q0q0 q1q1 q2q2 q3q3 q4q4 aa

L3 a a a b b b q1q1 q2q2 q3q3 q4q4 q5q5

Nondeterministic Finite Automata (NFA) Motivation of nondeterminism  Play chess, factor a number The key point is at each step, there are a fixed number of possible choices for the next. Some choices are good, some are bad. When we try to study the power of nondeterminism, we assume that a machine knows how to make a good choice.

NFA Examples Ex.Three NFAs accepting the same language defined by the regular expression  (ab v aba)* aa a b b q0q0 q1q1 q2q2 q3q3 q1q1 q0q0 a b ba q0q0 q1q1 q2q2 a a e b

Definition of NFA An NFA M = (K, ∑, ∆, s, F) where,  K is a finite set of states  ∑ is a finite alphabet  s is the initial state  F  K is the set of finite states  ∆ is the transition relation from K x (∑ ⋃ {e})  K Understand ∆ !  ∆ (p, a) may have more than one value  M is nondeterministic, because ∆ may have multiple values for a given pair of (p, a)

Configurations of NFAs Configuration  Pairs in K X ∑*  Meaning of a configuration? Yield Relation (q, w) (q’, w’) if w = aw’ for a Є ∑ ⋃ {e} and ∆ (q, a) = q’

The Reflexive and Transitive Closure Because the yield relation is a relation, we can find a unique reflexive and transitive closure of. Denote the closure as Now, Given any two configurations (p, w) and (p’, w’),  If (p,w) (p’,w’)  then we say that (p,w) yields (p’,w’) stop! Think about the physical meaning of (p, w) yielding (p’, w’)!

The Language Accepted by an NFA The language accepted by an NFA M is  L(M) = { w: w  *, (s, w) (q, e) for some q  F }

NFA Example a, b bb e b a

Design an NFA to accept  L = {w: not all symbols in  occured in w },  where  = {a, b, c, d } a,b,c a,b,d b,c,d a,c,d e e e e

Theorem. For each NFA, there is an equivalent DFA. Remark. Because each DFA has an equivalent NFA, the above result tells us that the power of NFA is the same as DFA.

Proof of the above Theorem Proof by Construction: Construct a DFA to simulate the given NDF Let the NFD M = ( k, , , s, F ) Wanted a DFA M’ = ( K’, , , s’, F’ )  Such that L( M ) = L( M’ ) Construction of M’   =   K’ = 2K  s’ = { q  K: (s, e) |---* (q, e ) }  F’ = { A  K’: A  F  }  For A  K, a   ( A, a ) = { q  K: ( p, a ) |---* ( q, e ) for some p  A }

Claim 1. M’ is deterministic by definition of  For any q  K, define E(q) = { p  K: ( q, e ) |---* ( p, e )} Claim 2. For any string w  *, p, q  K ( q, w ) |---* ( p, e )  ( E(q), w ) |---* ( P, e ) for some P  K’ such that p  P. Proof By induction on |w|  Basic step. For |w| = 0, w = e, we need to show: (q, e) |---* (p, e)  ( E(q), e )|---* (P, e) for some P  K’ such that p  P

Induction Hypothesis  Suppose the claim is true for all string w such that |w|  k Induction Step  We prove the claim is true for all string w such that |w| = k+ 1. Let w = ua for some a , u   * First prove: (q, w) |---* (p, e)  ( E(q), w ) |---* (P, e) for some P with p  P (q, w) |---* (p, e)   r1, r2 such that (q, w) |---* (r1, a) |---(r2, e) |---(p, e) apply induction hypothesis to (q, w) |---* (r1, a) Second we prove (E(q), w) |---*( P, e)  (q, w) |---*(p, e) for some P with p  P Again, let w = ua for some a , u  * (E(q), w) |---* (P, e)  (E(q), w) |---* (R1, a) |--- ( R2, e) |---* (P, e) Apply induction hypothesis to (E(q), w) |---* (P, e)  (E(q), w) |---* (R1, a)

Claim3: L(M) = L(M’)  By claim 2, for any w  *, (s, w) |---* (p, e), for p  F  (E(s), w) |---*, (P, e), for some P with p  P  Note E(s) = s’, P  F’

Equivalent DFA of NFA NFA DFA ae e b a b e e a a b b a,b a a

FA and Regular Expressions Theorem 1. The class of languages accepted by FA is closed under  (a) Union  (b) Concatenation  (c) Kleene star  (d) Complementation  (e) Intersection

Proof of Theorem 1 Proof.  (a) Union: Given Need to prove that there is a FA such that Idea for proving (a): by construction  Ideas for proving (b), (c) and (d): also by construction  Idea for proving (e):

Theorem 2. A language is regular if and only if it is accepted by a FA. Proof.  (The if-part) If a language is regular then it is accepted by a FA Recall that the class of regular languages is the smallest class of languages containing the empty set Ø and the singleton a, where a is a symbol, and closed under union, concatenation, and Kleene star. It is evident the empty set and all singletons are indeed accepted by FA; and by closure property of FA, every regular language is accepted by some FA.

(The only-if-part) If a language is accepted by a FA, then it is regular. Idea: Starting from the directed graph representation, find all paths from the initial state to the final states. For each path write a regular expression. Use Kleene star to deal with loops. Let be a FA. We shall construct a regular expression R such that. We shall represent L(M) as the union of many (but a finite number of) simple languages. Let. For i, j =1,…,n and k=0,…,n, we define R(i,j,k) as the set of all strings in that may drive M from state to state without passing through any intermediate state numbered k+1 or greater.

Note. By Math Induction, R(i,j,k) is regular for k=0,1,…,n. Hence, L(M) is regular.

The Pumping Theorem Theorem. Let be an infinite regular language. There is an integer such that any string with can be rewritten as such that and for each. Proof. Follows from the graph representation.

Irregular Languages w has equal number of a’s and b’s} The first two can be proved with the Pumping Theorem The third can be proved by contradiction and closure property of regular languages:  If L3 is regular, so is L1. But L1 is not

Algorithms for FA Theorem.  (a) There is an exponential time algorithm which, given an NFA, constructs an equivalent DFA.  (b) There is a polynomial time algorithm which, given a regular expression, construct an equivalent NFA  (c) There is an exponential time algorithm which, given an NFA, constructs an equivalent regular expression

 (d) There is a polynomial time algorithm which, given two DFAs, decides whether they are equivalent  (e) There is an exponential time algorithm which, given two NFAs, decided whether they are equivalent; similarly for equivalence of two regular expressions. For (d) and (e), note the following

More Algorithms Theorem. If L is a regular language, then there is an algorithm which, given tests whether it is in L in time. Proof. Construct a DFA to accept L.

More Algorithms Theorem. Let be an NFA. then there is an algorithm which, given tests whether it is in L(M) in time. Proof. Simulate the accepting process of M:  Step 0: Find E(s), which is s plus all states that are reachable with e-moves  Step 1: Start at E(s), find all states reachable passing the first letter of w plus their e-reachable states.  …  Step |w|: find the current state set as in Step 1 and decide whether a final state is in the current state set.  Estimate the time of the above process.

Conclusions NFA have the same computing power as DFA NFA have the same computing power as regular expressions Pumping Theorem vs. irregular languages Algorithms for  Constructing an equivalent NFA for a regular exp.  Constructing an equivalent regular exp. for an NFA  Constructing an equivalent DFA for an NFA  Deciding whether two FA are equivalent or not  Deciding whether a string is accepted by a DFA (or NFA) or not