January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.

Slides:



Advertisements
Similar presentations
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Advertisements

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
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions 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.
Introduction to Computability Theory
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
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.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
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.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
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.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
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
Pushdown Automata (PDAs)
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.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSCI 2670 Introduction to Theory of Computing September 13.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Regular Expressions Section 1.3 (also 1.1, 1.2) CSC 4170 Theory of Computation.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Expressions CS 130: Theory of Computation HMU textbook, Chapter 3.
 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.
1 Introduction to the Theory of Computation Regular Expressions.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Theory of Computation Automata Theory Dr. Ayman Srour.
CSE 105 theory of computation
Non Deterministic Automata
CSE 105 theory of computation
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
Non Deterministic Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
CSE 105 theory of computation
Chapter 1 Regular Language
NFAs accept the Regular Languages
CSE 105 theory of computation
Presentation transcript:

January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015

CS21 Lecture 32 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions Pumping Lemma

January 9, 2015CS21 Lecture 33 NFA formal definition A nondeterministic FA is a 5-tuple (Q, Σ, δ, q 0, F) –Q is a finite set called the states –Σ is a finite set called the alphabet –δ:Q x (Σ  {ε}) →  (Q) is a function called the transition function –q 0 is an element of Q called the start state –F is a subset of Q called the accept states transitions labeled with alphabet symbols or ε “powerset of Q”: the set of all subsets of Q

January 9, 2015CS21 Lecture 34 Formal description of NFA operation NFA M = (Q, Σ, δ, q 0, F) accepts a string w = w 1 w 2 w 3 …w n  Σ* if w can be written (by inserting ε’s) as: y = y 1 y 2 y 3 …y m  (Σ  {ε})* and  sequence r 0,r 1,…,r m of states for which –r 0 = q 0 –r i+1  δ(r i, y i+1 ) for i = 0,1,2, …, m-1 –r m  F

January 9, 2015CS21 Lecture 35 NFA, FA equivalence Theorem: a language L is recognized by a FA if and only if L is recognized by a NFA. Must prove two directions: (  ) L is recognized by a FA implies L is recognized by a NFA. (  ) L is recognized by a NFA implies L is recognized by a FA. (usually one is easy, the other more difficult)

January 9, 2015CS21 Lecture 36 NFA, FA equivalence (  ) L is recognized by a FA implies L is recognized by a NFA Proof: a finite automaton is a nondeterministic finite automaton that happens to have no ε-transitions, and for which each state has exactly one outgoing transition for each symbol.

January 9, 2015CS21 Lecture 37 NFA, FA equivalence (  ) L is recognized by a NFA implies L is recognized by a FA. Proof: we will build a FA that simulates the NFA (and thus recognizes the same language). –alphabet will be the same –what are the states of the FA?

January 9, 2015CS21 Lecture 38 NFA, FA equivalence –given NFAM = (Q, Σ, δ, q 0, F) –construct FAM’ = (Q’, Σ’, δ’, q 0 ’, F’) –same alphabet: Σ’ = Σ –states are subsets of M’s states: Q’ =  (Q) –if we are in state R  Q’ and we read symbol a  Σ’, what is the new state? 0,ε11 0,1

January 9, 2015CS21 Lecture 39 NFA, FA equivalence –given NFAM = (Q, Σ, δ, q 0, F) –construct FAM’ = (Q’, Σ’, δ’, q 0 ’, F’) Helpful def’n: E(S) = {q  Q : q reachable from S by traveling along 0 or more ε-transitions} –new transition fn: δ’(R, a) =  r  R E(δ(r, a)) = “all nodes reachable from R by following an a-transition, and then 0 or more ε-transitions” 0,ε11 0,1

January 9, 2015CS21 Lecture 310 NFA, FA equivalence –given NFAM = (Q, Σ, δ, q 0, F) –construct FAM’ = (Q’, Σ’, δ’, q 0 ’, F’) –new start state: q 0 ’ = E({q 0 }) –new accept states: F’ = {R  Q’ : R contains an accept state of M) 0,ε11 0,1

January 9, 2015CS21 Lecture 311 NFA, FA equivalence We have proved (  ) by construction. Formally we should also prove that the construction works, by induction on the number of steps of the computation. –at each step, the state of the FA M’ is exactly the set of reachable states of the NFA M…

January 9, 2015CS21 Lecture 312 So far… Theorem: the set of languages recognized by NFA is closed under union, concatenation, and star. Theorem: a language L is recognized by a FA if and only if L is recognized by a NFA. Theorem: the set of languages recognized by FA is closed under union, concatenation, and star.

January 9, 2015CS21 Lecture 313 Next… Describe the set of languages that can be built up from: –unions –concatenations –star operations Called “patterns” or regular expressions Theorem: a language L is recognized by a FA if and only if L is described by a regular expression.

January 9, 2015CS21 Lecture 314 Regular expressions R is a regular expression if R is –a, for some a  Σ –ε, the empty string –Ø, the empty set –(R 1  R 2 ), where R 1 and R 2 are reg. exprs. –(R 1  R 2 ), where R 1 and R 2 are reg. exprs. –(R 1 *), where R 1 is a regular expression A reg. expression R describes the language L(R).

January 9, 2015CS21 Lecture 315 Regular expressions example: R = (0  1) –if Σ = {0,1} then use “Σ” as shorthand for R example: R = 0  Σ* –shorthand: omit “  ”R = 0Σ* –precedence: *, then , then , unless override by parentheses –in example R = 0(Σ*), not R = (0Σ)*

January 9, 2015CS21 Lecture 316 Some examples {w : w has at least one 1} = Σ*1Σ* {w : w starts and ends with same symbol} = 0Σ*0  1Σ*1  0  1 {w : |w|  5} = (ε  Σ)(ε  Σ)(ε  Σ)(ε  Σ)(ε  Σ) {w : every 3 rd position of w is 1} = (1ΣΣ)*(ε  1  1Σ) alphabet Σ = {0,1}

January 9, 2015CS21 Lecture 317 Manipulating regular expressions The empty set and the empty string: –R  Ø = R –Rε = εR = R –RØ = ØR = Ø –  and  behave like +, x; Ø, ε behave like 0,1 additional identities: –R  R = R (here + and  differ) –(R 1 *R 2 )*R 1 * = (R 1  R 2 )* –R 1 (R 2 R 1 )* = (R 1 R 2 )*R 1

January 9, 2015CS21 Lecture 318 Regular expressions and FA Theorem: a language L is recognized by a FA if and only if L is described by a regular expression. Must prove two directions: (  ) L is recognized by a FA implies L is described by a regular expression (  ) L is described by a regular expression implies L is recognized by a FA.

January 9, 2015CS21 Lecture 319 Regular expressions and FA (  ) L is described by a regular expression implies L is recognized by a FA Proof: given regular expression R we will build a NFA that recognizes L(R). then NFA, FA equivalence implies a FA for L(R).

January 9, 2015CS21 Lecture 320 Regular expressions and FA R is a regular expression if R is –a, for some a  Σ –ε, the empty string –Ø, the empty set a

January 9, 2015CS21 Lecture 321 Regular expressions and FA –(R 1  R 2 ), where R 1 and R 2 are reg. exprs. –(R 1  R 2 ), where R 1 and R 2 are reg. exprs. –(R 1 *), where R 1 is a regular expression ε ε ε ε ε ε ε

January 9, 2015CS21 Lecture 322 Regular expressions and FA (  ) L is recognized by a FA implies L is described by a regular expression Proof: given FA M that recognizes L, we will 1.build an equivalent machine “Generalized Nondeterministic Finite Automaton” (GNFA) 2.convert the GNFA into a regular expression

January 9, 2015CS21 Lecture 323 Regular expressions and FA GNFA definition: –it is a NFA, but may have regular expressions labeling its transitions –GNFA accepts string w  Σ* if can be written w = w 1 w 2 w 3 … w k where each w i  Σ*, and there is a path from the start state to an accept state in which the i th transition traversed is labeled with R for which w i  L(R)

January 9, 2015CS21 Lecture 324 Regular expressions and FA Recall step 1: build an equivalent GNFA Our FA M is a GNFA. We will require “normal form” for GNFA to make the proof easier: –single accept state q accept that has all possible incoming arrows –every state has all possible outgoing arrows; exception: start state q 0 has no self-loop

January 9, 2015CS21 Lecture 325 Regular expressions and FA converting our FA M into GNFA in normal form: M ε ε ε Ø Ø Ø 0,1 0  1 Ø Ø Ø Ø

January 9, 2015CS21 Lecture 326 Regular expressions and FA On to step 2: convert the GNFA into a regular expression –if normal-form GNFA has two states: the regular expression R labeling the single transition describes the language recognized by the GNFA R

January 9, 2015CS21 Lecture 327 Regular expressions and FA –if GNFA has more than 2 states: –select one “q rip ”; delete it; repair transitions so that machine still recognizes same language. –repeat until only 2 states. q rip

January 9, 2015CS21 Lecture 328 Regular expressions and FA –how to repair the transitions: –for every pair of states q i and q j do qiqi qjqj q rip qiqi qjqj (R 1 )(R 2 )*(R 3 )  (R 4 ) R1R1 R2R2 R3R3 R4R4

January 9, 2015CS21 Lecture 329 Regular expressions and FA –summary: FA M → k-state GNFA → (k-1)-state GNFA → (k-2)-state GNFA →…→ 2-state GNFA → R –want to prove that this procedure is correct, i.e. L(R) = language recognized by M FA M equivalent to k-state GNFA i-state GNFA equivalent to (i-1)-state GNFA (we will prove…) 2-state GFNA equivalent to R

January 9, 2015CS21 Lecture 330 Regular expressions and FA –Claim: i-state GNFA G equivalent to (i-1)- state GNFA G’ (obtained by removing q rip ) –Proof: if G accepts string w, then it does so by entering states: q 0, q 1, q 2, q 3, …, q accept if none are q rip then G’ accepts w (see slide) else, break state sequence into runs of q rip : q 0 q 1 …q i q rip q rip …q rip q j …q accept transition from q i to q j in G’ allows all strings taking G from q i to q j using q rip (see slide) thus G’ accepts w

January 9, 2015CS21 Lecture 331 Regular expressions and FA qiqi qjqj q rip qiqi qjqj (R 1 )(R 2 )*(R 3 )  (R 4 ) R1R1 R2R2 R3R3 R4R4

January 9, 2015CS21 Lecture 332 Regular expressions and FA qiqi qjqj q rip qiqi qjqj (R 1 )(R 2 )*(R 3 )  (R 4 ) R1R1 R2R2 R3R3 R4R4

January 9, 2015CS21 Lecture 333 Regular expressions and FA –Proof (continued): if G’ accepts string w, then every transition from q i to q j traversed in G’ corresponds to either a transition from q i to q j in G or transitions from q i to q j via q rip in G In both cases G accepts w. Conclude: G and G’ recognize the same language.

January 9, 2015CS21 Lecture 334 Regular expressions and FA Theorem: a language L is recognized by a FA iff L is described by a regular expr. Languages recognized by a FA are called regular languages. Rephrasing what we know so far: –regular languages closed under 3 operations –NFA recognize exactly the regular languages –regular expressions describe exactly the regular languages