FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453.

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

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.
Deterministic Finite Automata (DFA)
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
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.
NFAs and DFAs Sipser 1.2 (pages 47-63). Last time…
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Finite Automata and Non Determinism
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
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.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
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.
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.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
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.
Great Theoretical Ideas in Computer Science.
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,
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Cs3102: Theory of Computation Class 4: Nondeterminism Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
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.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
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 Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
1 Finite Automata. 2 Introductory Example An automaton that accepts all legal Pascal identifiers: Letter Digit Letter or Digit "yes" "no" 2.
Foundations of Computing Science
PROPERTIES OF REGULAR LANGUAGES
CSE 105 theory of computation
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
CHAPTER 1 Regular Languages
Presentation transcript:

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FIRST HOMEWORK IS DUE Thursday, January 22

NON-DETERMINISM THURSDAY JAN 18

NON-DETERMINISM AND THE PUMPING LEMMA THURSDAY JAN 18

Q = {q 0, q 1, q 2, q 3 } Σ = {0,1}  : Q  Σ → Q transition function * q 0  Q is start state F = {q 1, q 2 }  Q accept states M = (Q, Σ, , q 0, F) where  01 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q2q2 q3q3 q2q2 q3q3 q0q0 q2q2 * q2q2 0 0, q0q0 q1q1 q3q3 M

Q is the set of states (finite) Σ is the alphabet (finite)  : Q  Σ → Q is the transition function q 0  Q is the start state F  Q is the set of accept states A ^ finite automaton ^ is a 5-tuple M = (Q, Σ, , q 0, F) deterministic DFA M accepts a string w if the process ends in a double circle

Q is the set of states (finite) Σ is the alphabet (finite)  : Q  Σ → Q is the transition function q 0  Q is the start state F  Q is the set of accept states A ^ finite automaton ^ is a 5-tuple M = (Q, Σ, , q 0, F) deterministic DFA Let w 1,..., w n  Σ and w = w 1... w n  Σ* Then M accepts w if there are r 0, r 1,..., r n  Q, s.t. 1.r 0 =q 0 2.  (r i, w i+1 ) = r i+1, for i = 0,..., n-1, and 3.r n  F

Q is the set of states (finite) Σ is the alphabet (finite)  : Q  Σ → Q is the transition function q 0  Q is the start state F  Q is the set of accept states A ^ finite automaton ^ is a 5-tuple M = (Q, Σ, , q 0, F) deterministic DFA A language L is regular if it is recognized by a deterministic finite automaton, i.e. if there is a DFA M such that L = L (M). L(M) = set of all strings machine M accepts

UNION THEOREM The union of two regular languages is also a regular language Intersection THEOREM The intersection of two regular languages is also a regular language

Complement THEOREM The complement of a regular languages is also a regular language In other words, if L is regular than so is  L, where  L= { w  Σ* | w  L } Proof ?

THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w  Σ* | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

Reverse THEOREM The reverse of a regular languages is also a regular language

REVERSE CLOSURE Regular languages are closed under reverse Assume L is a regular language and M recognizes L We build M R that accepts L R If M accepts w then w describes a directed path in M from start to an accept state Define M R as M with the arrows reversed

M R IS NOT ALWAYS A DFA! It may have many start states Some states may have too many outgoing edges, or none

,1 0

NON -DETERMINISM ,1 0 What happens with 100? We will say that the machine accepts if there is some way to make it reach an accept state

IBM JOURNAL APRIL 1959 Turing Award winning paper

0,1 0,ε0 0,1 At each state, possibly zero, one or many out arrows for each   Σ or with label ε EXAMPLE

1 ε0 0,1 1 0 Possibly many start states EXAMPLE

1 0 0 L(M)={1,00} EXAMPLE

Q is the set of states Σ is the alphabet  : Q  Σ ε → 2 Q is the transition function Q 0  Q is the set of start states F  Q is the set of accept states A non-deterministic finite automaton (NFA) is a 5-tuple N = (Q, Σ, , Q 0, F) 2 Q is the set of subsets of Q and Σ ε = Σ  {ε}

Let w  Σ* and suppose w can be written as w 1... w n where w i  Σ ε (ε is viewed as representing the empty string ) Then N accepts w if there are r 0, r 1,..., r n  Q such that 1.r 0  Q 0 2.r i+1   (r i, w i+1 ) for i = 0,..., n-1, and 3.r n  F A language L is recognized by an NFA N if L = L (N). L(N) = the language recognized by N = set of all strings machine N accepts

1 0 0  (q 3,1) = q1q1 q2q2 q3q3 q4q4 N = (Q, Σ, , Q 0, F) Q = {q 1, q 2, q 3, q 4 } Σ = {0,1} Q 0 = {q 1, q 2 } F = {q 4 }  Q  (q 2,1) = {q 4 }  ε  (q 1,0) = { q 3 } 00  L(N)? 01  L(N)?

Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

MULTIPLE START STATES We allow multiple start states for NFAs, and Sipser allows only one Can easily convert NFA with many start states into one with a single start state: ε ε ε

UNION THEOREM FOR NFAs

NFAs ARE SIMPLER THAN DFAs An NFA that recognizes the language {1}: 1 10,1 0 A DFA that recognizes the language {1}:

Theorem: Every NFA has an equivalent* DFA Corollary: A language is regular iff it is recognized by an NFA Corollary: L is regular iff L R is regular * N is equivalent to M if L(N) = L (M)

FROM NFA TO DFA Input: N = (Q, Σ, , Q 0, F) Output: M = (Q, Σ, , q 0, F) accept reject To learn if NFA accepts, we could do the computation in parallel, maintaining the set of states where all threads are Q = 2 Q Idea: Q = 2 Q

 : Q  Σ → Q  (R,  ) =  ε(  (r,  ) ) rRrR q 0 = ε(Q 0 ) F = { R  Q | f  R for some f  F } FROM NFA TO DFA Input: N = (Q, Σ, , Q 0, F) Output: M = (Q, Σ, , q 0, F) * For R  Q, the ε-closure of R, ε(R) = {q that can be reached from some r  R by traveling along zero or more ε arrows}, *

0,1 0,ε0 0,1 EXAMPLE q0q0 q1q1 q2q2 ε({q 0 }) = {q 0, q 1 }

a a, b a b ε Given: NFA N = ( {1,2,3}, {a.b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1} {2} {3}

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1}  {2} {3} {1,2} {1,3} {2,3} {1,2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1}  {2} {2,3} {3} {1,2} {1,3} {2,3} {1,2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1}  {2} {2,3} {3} {1,3}  {1,2} {2,3} {1,3} {2} {2,3} {1,2,3} {3} {1,2,3} {2,3} q 0 =

a a, b a b ε Given: NFA N = ( {1,2,3}, {a,b}, , {1}, {1} ) Construct: equivalent DFA M ε({1}) = {1,3} N N = ( Q, Σ, , Q 0, F ) = (Q, Σ, , q 0, F)  ab  {1}  {2} {2,3} {3} {1,3}  {1,2} {2,3} {1,3} {2} {2,3} {1,2,3} {3} {1,2,3} {2,3} q 0 =

Q = 2 Q  : Q  Σ → Q  (R,  ) =  ε(  (r,  ) ) rRrR q 0 = ε(Q 0 ) F = { R  Q | f  R for some f  F } FROM NFA TO DFA Input: N = (Q, Σ, , Q 0, F) Output: M = (Q, Σ, , q 0, F) * For R  Q, the ε-closure of R, ε(R) = {q that can be reached from R by traveling along zero or more ε arrows}, *

REGULAR LANGUAGES CLOSED UNDER CONCATENATION Given DFAs M 1 and M 2, construct NFA by connecting all accept states in M 1 to start states in M 2

REGULAR LANGUAGES CLOSED UNDER STAR Let L be a regular language and M be a DFA for L We construct an NFA N that recognizes L* 0 0, ε ε ε

Formally: Input: M = (Q, Σ, , q 1, F) Output: N = (Q, Σ, , {q 0 }, F) Q = Q  {q 0 } F = F  {q 0 }  (q,a) = {  (q,a)} {q1}{q1} {q1}{q1}  if q  Q and a ≠ ε if q  F and a = ε if q = q 0 and a = ε if q = q 0 and a ≠ ε  else

L (N) = L* Assume w = w 1 …w k is in L*, where w 1,…,w k  L We show N accepts w by induction on k Base Cases: k = 0 k = 1 Inductive Step: Assume N accepts all strings v = v 1 …v k  L*, v i  L, and let u = u 1 …u k u k+1  L*, u j  L, Since N accepts u 1 …u k and M accepts u k+1, N must accept u

Assume w is accepted by N, we show w  L* If w = ε, then w  L* If w ≠ ε accept ε ε  L*

Assume w is accepted by N, we show w  L* If w = ε, then w  L* If w ≠ ε accept ε ε  L*

REGULAR LANGUAGES ARE COLSED UNDER REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w  Σ* | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

SOME LANGUAGES ARE NOT REGULAR B = {0 n 1 n | n ≥ 0} is NOT regular!

WHICH OF THESE ARE REGULAR C = { w | w has equal number of 1s and 0s} D = { w | w has equal number of occurrences of 01 and 10} NOT REGULAR REGULAR!!!

THE PUMPING LEMMA Let L be a regular language with |L| =  Then there exists a positive integer P such that 1. |y| > 0 2. |xy| ≤ P 3. xy i z  L for any i ≥ 0 if w  L and |w| ≥ P then w = xyz, where:

Let P be the number of states in M Assume w  L is such that |w| ≥ P q0q0 qiqi qjqj q |w| … There must be j > i such that q i = q j Let M be a DFA that recognizes L 1. |y| > 0 2. |xy| ≤ P 3. xy i z  L for any i ≥ 0 We show w = xyz x

USING THE PUMPING LEMMA Use the pumping lemma to prove that B = {0 n 1 n | n ≥ 0} is not regular Hint: Assume B is regular, and try pumping s = 0 P 1 P If B is regular, s can be split into s = xyz, where for any i ≥ 0, xy i z is also in B If y is all 0s: xyyz has more 0s than 1s If y is all 1s: xyyz has more 1s than 0s If y has both 1s and 0s: xyyz will have some 1s before some 0s

For next time Read Chapter 1.2 of the book. Also, get started on the homework ASAP!!