CS21 Decidability and Tractability

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

Variants of Turing machines
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Lecture 5 Turing Machines
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
Normal forms for Context-Free Grammars
January 23, 2015CS21 Lecture 81 CS21 Decidability and Tractability Lecture 8 January 23, 2015.
CS 310 – Fall 2006 Pacific University CS310 Variants of Turing Machines Section 3.2 November 8, 2006.
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
CS21 Decidability and Tractability
1 Turing Machines. 2 A Turing Machine Tape Read-Write head Control Unit.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
Costas Busch - LSU1 Turing’s Thesis. Costas Busch - LSU2 Turing’s thesis (1930): Any computation carried out by mechanical means can be performed by a.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
1 Introduction to Turing Machines
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
February 1, 2016CS21 Lecture 121 CS21 Decidability and Tractability Lecture 12 February 1, 2016.
Turing’s Thesis.
Turing’s Thesis Costas Busch - LSU.
Theory of Computation Pushdown Automata pda Lecture #10.
PDAs Accept Context-Free Languages
CSE 105 theory of computation
Busch Complexity Lectures: Reductions
Linear Bounded Automata LBAs
CS21 Decidability and Tractability
Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,
PDAs Accept Context-Free Languages
Pushdown Automata.
CSE 105 theory of computation
BCS 2143 Theory of Computer Science
CS154, Lecture 7: Turing Machines.
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
NPDAs Accept Context-Free Languages
Turing Machines Acceptors; Enumerators
Intro to Theory of Computation
Intro to Theory of Computation
Decidable Languages Costas Busch - LSU.
Deterministic PDAs - DPDAs
CS21 Decidability and Tractability
Decidable and undecidable languages
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CSE 105 theory of computation
CS21 Decidability and Tractability
Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CSE 105 theory of computation
Recap lecture 40 Recap of example of PDA corresponding to CFG, CFG corresponding to PDA. Theorem, HERE state, Definition of Conversion form, different.
Variants of Turing machines
Automata, Grammars and Languages
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
Intro to Theory of Computation
Intro to Theory of Computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

CS21 Decidability and Tractability Lecture 8 January 25, 2019 January 25, 2019 CS21 Lecture 8

Outline deterministic PDAs deciding CFLs Turing Machines and variants multitape TMs nondeterministic TMs Church-Turing Thesis January 25, 2019 CS21 Lecture 8

Deterministic PDA A NPDA is a 6-tuple (Q, Σ, Γ, δ, q0, F) where: δ:Q x (Σ ∪ {ε}) x (Γ∪ {ε}) → P (Q x (Γ∪ {ε})) is a function called the transition function A deterministic PDA has only one option at every step: for every state q ∈ Q, a ∈ Σ, and t ∈Γ, exactly 1 element in δ(q, a, t), or exactly 1 element in δ(q, ε, t), and δ(q, a, t) empty for all a ∈ Σ January 25, 2019 CS21 Lecture 8

Deterministic PDA A technical detail: we will give our deterministic machine the ability to detect end of input string add special symbol ■ to alphabet require input tape to contain x■ language recognized by a deterministic PDA is called a deterministic CFL (DCFL) January 25, 2019 CS21 Lecture 8

Example deterministic PDA 0, ε → 0 ε, ε → $ Σ = {0, 1} Γ = {0, 1, $} 1, 0 → ε ■, $ → ε 1, 0 → ε L = {0n1n : n ≥ 0} (unpictured transitions go to a “reject” state and stay there) January 25, 2019 CS21 Lecture 8

(complement of L in Σ* is (Σ* - L) ) Deterministic PDA Theorem: DCFLs are closed under complement (complement of L in Σ* is (Σ* - L) ) Proof attempt: swap accept/non-accept states problem: might enter infinite loop before reading entire string machine for complement must accept in these cases, and read to end of string January 25, 2019 CS21 Lecture 8

Example of problem Language of this DPDA is 0Σ* 1, ε → ε 0, ε → ε ■, ε → ε ■, ε → ε 1, ε → ε ε, ε → $ ε, ε → $ Language of this DPDA is 0Σ* January 25, 2019 CS21 Lecture 8

Example of problem Language of this DPDA is {𝜖} 1, ε → ε 0, ε → ε ■, ε → ε ■, ε → ε 1, ε → ε ε, ε → $ ε, ε → $ Language of this DPDA is {𝜖} January 25, 2019 CS21 Lecture 8

Deterministic PDA Proof: convert machine into “normal form” always reads to end of input always enters either an accept state or single distinguished “reject” state step 1: keep track of when we have read to end of input step 2: eliminate infinite loops January 25, 2019 CS21 Lecture 8

Deterministic PDA step 1: keep track of when we have read to end of input q0 q1 q0’ q1’ ■, ? → ? ■, ? → ? q3 q3’ q2 q2’ January 25, 2019 CS21 Lecture 8

Deterministic PDA step 1: keep track of when we have read to end of input ■, ? → ? q0 q1 q0’ q1’ ■, ? → ? q3 q3’ q2 q2’ for accept state q’: replace outgoing “ε, ? → ?” transition with self-loop with same label January 25, 2019 CS21 Lecture 8

Deterministic PDA step 2: eliminate infinite loops add new “reject” states a, t →t (for all a, t) ε, t → t (for all t) r r’ ■, t → t (for all t) January 25, 2019 CS21 Lecture 8

Deterministic PDA step 2: eliminate infinite loops on input x, if infinite loop, then: stack height time i0 i1 i2 i3 infinite sequence i0< i1< i2< … such that for all k, stack height never decreases below ht(ik) after time ik January 25, 2019 CS21 Lecture 8

Deterministic PDA step 2: eliminate infinite loops infinite seq. i0< i1< … such that for all k, stack height never decreases below ht(ik) after time ik infinite subsequence j0< j1< j2< … such that same transition is applied at each time jk never see any stack symbol below t from jk on we are in a periodic, deterministic sequence of stack operations independent of the input p ε, t → s January 25, 2019 CS21 Lecture 8

Deterministic PDA step 2: eliminate infinite loops infinite subsequence j0< j1< j2< … such that same transition is applied at each time jk safe to replace: a, t →t (for all a, t) ε, t → t (for all t) ε, t → s p r r’ ε, t → s or ε, t → s ■, t → t (for all t) p’ ε, t → s January 25, 2019 CS21 Lecture 8

Deterministic PDA finishing up… have a machine M with no infinite loops therefore it always reads to end of input either enters an accept state q’, or enters “reject” state r’ now, can swap: make r’ unique accept state to get a machine recognizing complement of L January 25, 2019 CS21 Lecture 8

Chomsky Normal Form Useful to deal only with CFGs in a simple normal form Most common: Chomsky Normal Form (CNF) Definition: every production has form A → BC or S → ε or A → a where A, B, C are any non-terminals (and B, C are not S) and a is any terminal. January 25, 2019 CS21 Lecture 8

Chomsky Normal Form Theorem: Every CFL is generated by a CFG in Chomsky Normal Form. Proof: exercise or in book… January 25, 2019 CS21 Lecture 8

Deciding CFLs Useful to have an efficient algorithm to decide whether string x is in given CFL e.g. programming language often described by CFG. Determine if string is valid program. If CFL recognized by deterministic PDA, just simulate the PDA. but not all CFLs are (homework)… Can simulate NPDA, but this takes exponential time in the worst case. January 25, 2019 CS21 Lecture 8

Deciding CFLs Convert CFG into Chomsky Normal Form parse tree for string x generated by nonterminal A: If A →k x (k > 1) then there must be a way to split x: x = yz A → BC is a production and B →i y and C ⇒j z for i, j < k A B C x January 25, 2019 CS21 Lecture 8

Deciding CFLs An algorithm: worst case running time? IsGenerated(x, A) if |x| = 1, then return YES if A → x is a production, else return NO for all n-1 ways of splitting x = yz for all ≤ m productions of form A → BC if IsGenerated(y, B) and IsGenerated(z, C), return YES return NO worst case running time? January 25, 2019 CS21 Lecture 8

{A: A nonterminal such that A →* x[i,j]} Deciding CFLs worst case running time exp(n) Idea: avoid recursive calls build table of YES/NO answers to calls to IsGenerated, in order of length of substring example of general algorithmic strategy called dynamic programming notation: x[i,j] = substring of x from i to j table: T(i, j) contains {A: A nonterminal such that A →* x[i,j]} January 25, 2019 CS21 Lecture 8

Deciding CFLs IsGenerated(x = x1x2x3…xn, G) for i = 1 to n T[i, i] = {A: “A → xi” is a production in G} for k = 1 to n - 1 for i = 1 to n - k for k splittings x[i, i+k] = x[i,i+j]x[i+j+1, i+k] T[i, i+k] = {A: “A → BC” is a production in G and B ∈ T[i,i+j] and C ∈ T[i+j+1,i+k] } output “YES” if S ∈ T[1, n], else output “NO” January 25, 2019 CS21 Lecture 8

Deciding CFLs IsGenerated(x = x1x2x3…xn, G) for i = 1 to n O(nm) steps T[i, i] = {A: “A → xi” is a production in G} for k = 1 to n - 1 for i = 1 to n - k for k splittings x[i, i+k] = x[i,i+j]x[i+j+1, i+k] T[i, i+k] = {A: “A → BC” is a production in G and B ∈ T[i,i+j] and C ∈ T[i+j+1,i+k] } output “YES” if S ∈ T[1, n], else output “NO” O(nm) steps O(n3m3) steps January 25, 2019 CS21 Lecture 8