Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Theory of Computation

Similar presentations


Presentation on theme: "Intro to Theory of Computation"— Presentation transcript:

1 Intro to Theory of Computation
LECTURE 14 Last time Turing Machine Variants Church-Turing Thesis Today Universal TM Decidable languages Designing deciders CS 464 Homework 5 due Homework 6 out Sofya Raskhodnikova 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

2 L is recognized by a program
The Church-Turing Thesis (1936) L is recognized by a program for some computer* L is recognized by a TM History 23 Hilbert’s problems (1900) stated at International Congress of Mathematicians 10th problem: Give a procedure for determining if a polynomial in k variables has an integral root. * The computer must be “reasonable” 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

3 I-clicker problem (frequency: AC)
The language corresponding to Hilbert’s 10th problem is not Turing-recongnizable Turing-recognizable, but not decidable decidable regular More than one choice above works. {madam, dad, but, tub, book}

4 Sofya Raskhodnikova; based on slides by Nick Hopper
A universal Turing Machine Since TMs and programming languages are equivalent, we can think of TMs as programs. Since programs are strings, we can consider languages whose elements are programs. 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

5 Sofya Raskhodnikova; based on slides by Nick Hopper
Can we encode a Turing Machine as a string of 0s and 1s? 〈O〉denotes an encoding of object O as a string start state reject state states Q={0,1,…,n-1} 0n10m10k10s10t10r10u1…〈  〉 tape symbols Γ={0,1…,m-1} (first k are input symbols) blank symbol accept state  :〈(p,a), (q,b,L)〉 = 0p10a10q10b10 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

6 Sofya Raskhodnikova; based on slides by Nick Hopper
A universal Turing Machine Since TMs and programming languages are equivalent, we can think of TMs as programs. Since programs are strings, we can consider languages whose elements are programs. 〈M〉denotes an encoding of a TM M as a string Theorem. We can make a Universal TM, a TM that takes any TM description〈M〉 and any string w as input and simulates the computation of M on w. FINITE CONTROL tape contents state encoding of M 〈w〉 〈M〉 〈q0〉 〈w〉= 〈w1,…,wn〉 = 0w110w21…0wn 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

7 Sofya Raskhodnikova; based on slides by Nick Hopper
Encodings of DFAs, NFAs, CFGs, etc Similarly, we can encode DFAs, NFAs, regular expressions, PDAs, CFGs, etc into strings of 0s and 1s. We can define the following languages: ADFA = { 〈D,w〉 | D is a DFA that accepts string w } ANFA = { 〈N,w〉 | N is an NFA that accepts string w } ACFG = { 〈G,w〉 | G is a CFG that generates string w } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

8 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. ADFA is decidable. Proof: The following TM M decides ADFA. M = `` On input 〈𝑫,𝑤〉, where 𝑫 is a DFA and 𝑤 is a string: Check if input (to M) is legal, reject if not. Simulate 𝑫 on 𝑤. Accept if 𝐷 ends in an accept state. O.w. reject.’’ (This step is assumed to be the first step of every algorithm.) 𝐷 𝑤 M Current state of 𝐷 Corollary. ANFA is decidable. (1. Convert input NFA 𝑵 to an equivalent DFA 𝑫.) 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

9 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. ACFG is decidable. ACFG = { 〈G,w〉 | G is a CFG that generates string w } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

10 Sofya Raskhodnikova; based on slides by Nick Hopper
Chomsky Normal Form for CFGs Can have a rule 𝑆→ε. All remaining rules are of the form 𝐴→ 𝐵𝐶 𝐴, 𝐵, 𝐶∈ 𝑉 𝐴→𝑎 𝑎∈Σ Cannot have 𝑆 on the RHS of any rule. Lemma. Any CFG can be converted into an equivalent CFG in Chomsky normal form. (Proof in Sipser.) Lemma. If G is in Chomsky normal form, any derivation of string w of length 𝑛 in G has 2𝑛−1 steps. 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

11 Sofya Raskhodnikova; based on slides by Nick Hopper
Chomsky Normal Form for CFGs Lemma. If G is in Chomsky normal form, any derivation of string 𝑤 of length 𝑛 in G has 2𝑛−1 steps. Proof idea: Only rules of the form 𝐴→ 𝐵𝐶 increase the number of symbols: need to apply rules of this form 𝑛−1 times. Only rules of the form 𝐴→𝑎 replace variables with terminals: need to apply rules of this form 𝑛 times. 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

12 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. ACFG is decidable. ACFG = { 〈G,w〉 | G is a CFG that generates string w } Proof: The following TM M decides ACFG. M = `` On input 〈𝑮,𝑤〉, where 𝑮 is a CFG and 𝑤 is a string: Convert G to Chomsky normal form. Let 𝑛=|𝑤|. Test all derivations with 2𝑛−1 steps. Accept if any derived 𝒘. O.w. reject.’’ 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

13 Sofya Raskhodnikova; based on slides by Nick Hopper
Examples of decidable languages ADFA = { 〈D,w〉 | D is a DFA that accepts string w } ANFA = { 〈N,w〉 | N is an NFA that accepts string w } ACFG = { 〈G,w〉 | G is a CFG that generates string w } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

14 Sofya Raskhodnikova; based on slides by Nick Hopper
More decidable languages EDFA = { 〈D〉 | D is a DFA that recognizes the empty language } EQDFA = { 〈 𝐷 1 , 𝐷 2 〉 | 𝐷 1 , 𝐷 2 are DFAs and 𝐿(𝐷 1 )=𝐿( 𝐷 2 ) } ECFG = { 〈G〉 | G is a CFG that generates the empty language} 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

15 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. EDFA is decidable. EDFA = { ⟨𝑫⟩ | 𝑫 is a DFA that recognizes ∅.} Proof: The following TM M decides EDFA. M = `` On input 〈𝑫〉, where 𝑫 is a DFA: Use BFS to determine if an accepting state of D is reachable from from its start state. Accept if not. O.w. reject.’’ 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

16 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. EQDFA is decidable. EQDFA = { ⟨ 𝑫 𝟏 , 𝑫 𝟐 ⟩| 𝑫 𝟏 , 𝑫 𝟐 are DFAs & 𝑳 𝑫 𝟏 =𝑳( 𝑫 𝟐 )} Proof: The following TM M decides EQDFA. M = `` On input 〈 𝑫 𝟏 , 𝑫 𝟐 〉, where 𝑫 𝟏 , 𝑫 𝟐 are DFAs: Construct a DFA D that recognizes the set difference of 𝑳 𝑫 𝟏 and 𝑳( 𝑫 𝟐 ). Run the decider for EDFA on <D>. If it accepts, accept. O.w. reject.’’ (on the board) 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

17 Sofya Raskhodnikova; based on slides by Nick Hopper
Theorem. ECFG is decidable. ECFG = { ⟨𝑮⟩ | 𝑮 is a CFG that recognizes ∅.} Proof: The following TM M decides ECFG. M = `` On input 〈𝑮〉, where 𝑮 is a CFG: Mark all terminals in G. Repeat until no new variable is marked: Mark any variable A where G has a rule A→… and each variable/terminal on the RHS is already marked. Accept if the start variable is unmarked. O.w. reject.’’ 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

18 Sofya Raskhodnikova; based on slides by Nick Hopper
Exercises Prove that the following language is decidable: Formulate the following problem as a language and prove that it is decidable: Given a PDA and a string, determine if the PDA accepts the string. Can a TM just simulate P on w, accept if it accepts and reject o.w.? RDFA = { 〈D,w〉 | D is a DFA that rejects string w } APDA = { 〈P,w〉 | P is a PDA that accepts string w } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

19 I-clicker problem (frequency: AC)
A decider for APDA can, on input <P, w> simulate P on w, accept if it accepts and reject o.w. convert P to an equivalent CFG G and then run a decider for ACFG, accept if it accepts and reject o.w. convert P to an equivalent CFG G and then run a decider for ACFG, accept if it rejects and accept o.w. None of the above. More than one choice above works. {madam, dad, but, tub, book}


Download ppt "Intro to Theory of Computation"

Similar presentations


Ads by Google