CS21 Decidability and Tractability

Slides:



Advertisements
Similar presentations
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
Advertisements

CSCI 2670 Introduction to Theory of Computing September 13, 2005.
January 5, 2015CS21 Lecture 11 CS21 Decidability and Tractability Lecture 1 January 5, 2015.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions 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.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Introduction to Computability Theory
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS355 - Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
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.
1 Introduction to the Theory of Computation Regular Expressions.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Languages and Automata By: Mojtaba Khezrian.
CSE 105 theory of computation
Foundations of Computing Science
Non-regular languages
Standard Representations of Regular Languages
CSE 105 theory of computation
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
CSE 3813 Introduction to Formal Languages and Automata
Intro to Theory of Computation
Hierarchy of languages
Summary.
CS 154, Lecture 4: Limitations on DFAs (I),
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
Non Deterministic Automata
Context-Free Grammars
CSE 105 theory of computation
فصل دوم Context-Free Languages
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
Chapter 4 Properties of Regular Languages
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Decidability and Tractability
CS21 Decidability and Tractability
Chapter 1 Regular Language
CSE 105 theory of computation
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
MA/CSSE 474 Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

CS21 Decidability and Tractability Lecture 4 January 14, 2019 January 14, 2019 CS21 Lecture 4

Outline FA and Regular Expressions Non-regular languages: Pumping Lemma Pushdown Automata Context-Free Grammars and Languages January 14, 2019 CS21 Lecture 4

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 14, 2019 CS21 Lecture 4

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 build an equivalent machine “Generalized Nondeterministic Finite Automaton” (GNFA) convert the GNFA into a regular expression January 14, 2019 CS21 Lecture 4

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 = w1w2w3… wk where each wi ∈ Σ*, and there is a path from the start state to an accept state in which the ith transition traversed is labeled with R for which wi ∈ L(R) January 14, 2019 CS21 Lecture 4

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 qaccept that has all possible incoming arrows every state has all possible outgoing arrows; exception: start state q0 has no self-loop January 14, 2019 CS21 Lecture 4

Regular expressions and FA converting our FA M into GNFA in normal form: 0 ∪ 1 0,1 ε ε Ø Ø ε Ø Ø Ø M Ø Ø January 14, 2019 CS21 Lecture 4

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 14, 2019 CS21 Lecture 4

Regular expressions and FA if GNFA has more than 2 states: select one “qrip”; delete it; repair transitions so that machine still recognizes same language. repeat until only 2 states. qrip January 14, 2019 CS21 Lecture 4

Regular expressions and FA how to repair the transitions: for every pair of states qi and qj do R4 qi qj (R1 )(R2 )*(R3) ∪ (R4) R3 R1 qi qj qrip R2 January 14, 2019 CS21 Lecture 4

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 14, 2019 CS21 Lecture 4

Regular expressions and FA Claim: i-state GNFA G equivalent to (i-1)-state GNFA G’ (obtained by removing qrip) Proof: if G accepts string w, then it does so by entering states: q0, q1, q2, q3, … , qaccept if none are qrip then G’ accepts w (see slide) else, break state sequence into runs of qrip: q0q1…qiqripqrip…qripqj…qaccept transition from qi to qj in G’ allows all strings taking G from qi to qj using qrip (see slide) thus G’ accepts w January 14, 2019 CS21 Lecture 4

Regular expressions and FA qi qj (R1 )(R2 )*(R3) ∪ (R4) R3 R1 qi qj qrip R2 January 14, 2019 CS21 Lecture 4

Regular expressions and FA qi qj (R1 )(R2 )*(R3) ∪ (R4) R3 R1 qi qj qrip R2 January 14, 2019 CS21 Lecture 4

Regular expressions and FA Proof (continued): if G’ accepts string w, then every transition from qi to qj traversed in G’ corresponds to either a transition from qi to qj in G or transitions from qi to qj via qrip in G In both cases G accepts w. Conclude: G and G’ recognize the same language. January 14, 2019 CS21 Lecture 4

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 January 14, 2019 CS21 Lecture 4

Limits on the power of FA Is every language describable by a sufficiently complex regular expression? If someone asks you to design a FA for a language that seems hard, how do you know when to give up? Is this language regular? {w : w has an equal # of “01” and “10” substrings} January 14, 2019 CS21 Lecture 4

Limits on the power of FA Intuition: FA can only remember finite amount of information. They cannot count languages that “entail counting” should be non-regular… Intuition not enough: {w : w has an equal # of “01” and “10” substrings} = 0Σ*0 ∪ 1Σ*1 but {w: w has an equal # of “0” and “1” substrings} is not regular! January 14, 2019 CS21 Lecture 4

Limits on the power of FA How do you prove that there is no Finite Automaton recognizing a given language? January 14, 2019 CS21 Lecture 4

Non-regular languages Pumping Lemma: Let L be a regular language. There exists an integer p (“pumping length”) for which every w ∈ L with |w| ≥ p can be written as w = xyz such that for every i ≥ 0, xyiz ∈ L , and |y| > 0, and |xy| ≤ p. January 14, 2019 CS21 Lecture 4

Non-regular languages Using the Pumping Lemma to prove L is not regular: assume L is regular then there exists a pumping length p select a string w ∈ L of length at least p argue that for every way of writing w = xyz that satisfies (2) and (3) of the Lemma, pumping on y yields a string not in L. contradiction. January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {0n1n : n ≥ 0} is not regular. Proof: let p be the pumping length for L choose w = 0p1p w = 000000000…0111111111…1 w = xyz, with |y| > 0 and |xy| ≤ p. p p January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples 3 possibilities: w = 000000000…0111111111…1 in each case, pumping on y gives a string not in language L. x y z x y z x y z January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {w: w has an equal # of 0s and 1s} is not regular. Proof: let p be the pumping length for L choose w = 0p1p w = 000000000…0111111111…1 w = xyz, with |y| > 0 and |xy| ≤ p. p p January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples 3 possibilities: w = 000000000…0111111111…1 first 2 cases, pumping on y gives a string not in language L; 3rd case a problem! x y z x y z x y z January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples recall condition 3: |xy| ≤ p since w = 0p1p we know more about how it can be divided, and this case cannot arise: w = 000000000…0111111111…1 so we do get a contradiction. conclude that L is not regular. x y z January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {0i1j: i > j} is not regular. Proof: let p be the pumping length for L choose w = 0p+11p w = 000000000…01111111…1 w = xyz, with |y| > 0 and |xy| ≤ p. p+1 p January 14, 2019 CS21 Lecture 4

Pumping Lemma Examples 1 possibility: w = 000000000…0111111111…1 pumping on y gives strings in the language (?) this seems like a problem… Lemma states that for every i ≥ 0, xyiz ∈ L xy0z not in L. So L not regular. x y z January 14, 2019 CS21 Lecture 4

Proof of the Pumping Lemma Let M be a FA that recognizes L. Set p = number of states of M. Consider w ∈ L with |w| ≥ p. On input w, M must go through at least p+1 states. There must be a repeated state (among first p+1). y x z M January 14, 2019 CS21 Lecture 4

FA Summary A “problem” is a language A “computation” receives an input and either accepts, rejects, or loops forever. A “computation” recognizes a language (it may also decide the language). Finite Automata perform simple computations that read the input from left to right and employ a finite memory. January 14, 2019 CS21 Lecture 4

FA Summary The languages recognized by FA are the regular languages. The regular languages are closed under union, concatenation, and star. Nondeterministic Finite Automata may have several choices at each step. NFAs recognize exactly the same languages that FAs do. January 14, 2019 CS21 Lecture 4

FA Summary Regular expressions are languages built up from the operations union, concatenation, and star. Regular expressions describe exactly the same languages that FAs (and NFAs) recognize. Some languages are not regular. This can be proved using the Pumping Lemma. January 14, 2019 CS21 Lecture 4