0% found this document useful (0 votes)
7 views

Csci471 Intro Lecture 5

The document discusses the following topics: 1. It introduces the concept of a universal Turing machine that can simulate the computation of any other Turing machine. 2. It discusses encodings of different formal language models like DFAs, NFAs, CFGs as strings that can be used as inputs to Turing machines. 3. It proves that several language recognition problems like determining if a DFA/NFA accepts a string (ADFA/ANFA), if a CFG generates a string (ACFG), if a DFA recognizes the empty language (EDFA), or if two DFAs recognize the same language (EQDFA) are decidable by constructing Turing machines to solve each problem.

Uploaded by

Dokin Nikod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Csci471 Intro Lecture 5

The document discusses the following topics: 1. It introduces the concept of a universal Turing machine that can simulate the computation of any other Turing machine. 2. It discusses encodings of different formal language models like DFAs, NFAs, CFGs as strings that can be used as inputs to Turing machines. 3. It proves that several language recognition problems like determining if a DFA/NFA accepts a string (ADFA/ANFA), if a CFG generates a string (ACFG), if a DFA recognizes the empty language (EDFA), or if two DFAs recognize the same language (EQDFA) are decidable by constructing Turing machines to solve each problem.

Uploaded by

Dokin Nikod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CSCI 471: Complexity and Computability

LECTURE 5
Today:
• Universal TM
• Decidable Languages

1
Meiram Murzabulatov
TM variant: enumerator
FINITE tape
CONTROL

printer

• Starts with a blank tape


• Prints strings
L(E) = set of strings that E eventually prints.
May print the same string many times.
May never terminate even if the language is finite.
TMs are equivalent to enumerators

Theorem. A language is recognizable



some enumerator enumerates it.
Proof. The If-part: If an enumerator E enumerates the language A then a
TM M recognizes A.
M = “On input w
1. Run E. Everytime E outputs a string, compare it with w.
2. If w ever appears in the output of E, accept.”

Clearly M accepts only those strings that appear on E’s list.


TMs are equivalent to enumerators
Theorem. A language is recognizable

some enumerator enumerates it.
Proof. The Only-if-part: If a TM M recognizes a language A, we can
construct the following enumerator for A.
Assume s1, s2, s3, . . . is a list of possible strings in Σ ∗ .
E = “Ignore the input
1. Repeat the following for 𝑖 = 1, 2, 3, . . .
2. Run M for 𝑖 steps on each input s1, s2, s3, . . . s𝑖 .
3. If a computation accepts, print out the corresponding s𝑗.”
If M accepts a particular string, it will appear on the list generated by
E (in fact infinitely many times)
DESCRIBING TMs AND THEIR INPUTS

• For the rest of the course we will have a rather standard way
of describing TMs and their inputs.
• The input to TMs have to be strings.
• Every object O that enters a computation will be represented
with a string 〈O〉, encoding the object.
• E.g., if G is a 4 node undirected graph below,

1 4
G=
2 3

〈G〉 = (1,2,3,4)((1,2),(2,3),(3,1),(1,4))
〈T〉= (1,2,3,…,n) (a,b,c,d)(a,b,c,d,B,x) ((1,a,n,a,R), (n,b,2,c,L), ())
A universal Turing Machine
• Since TMs and programs 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. 〈M,w〉
〈M〉 encoding of M
FINITE
CONTROL
〈 w〉 tape contents 〈w〉= 〈w1,…,wn〉
〈 q 0〉 state
Encodings of DFAs, NFAs, CFGs, etc

• 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 }


Theorem. ADFA is decidable.

Proof: The following TM M decides ADFA.


M = `` On input 〈𝑫, 𝑤〉, where 𝑫 is a DFA and 𝑤 is a string:
1. Check if input (to M) is legal, reject if not.
(This step is assumed to be the first step of every algorithm.)
2. Simulate 𝑫 on 𝑤.
𝐷 𝑤
M Current state of 𝐷

3. Accept if 𝐷 ends in an accept state. O.w. reject.’’


Corollary. ANFA is decidable.
(1. Convert input NFA 𝑵 to an equivalent DFA 𝑫.)
Theorem. ACFG is decidable.

ACFG = { 〈G,w〉 | G is a CFG that generates string w }


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.
Chomsky Normal Form for CFGs

Lemma. If G is in Chomsky normal form, any derivation


of string w 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.
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:
1. Convert G to Chomsky normal form.
2. Let 𝑛 = |𝑤|.
3. Test all derivations with 2𝑛 − 1 steps.
4. Accept if any derived 𝒘. Otherwise, reject.’’
EDFA = { 〈D〉 | D is a DFA that recognizes the empty language }

EQDFA = { 〈𝐷", 𝐷#〉 | 𝐷", 𝐷# are DFAs and 𝐿(𝐷") = 𝐿(𝐷#) }

ECFG = { 〈G〉 | G is a CFG that generates the empty language}


EDFA is decidable

EDFA ={ 𝑫 ∣ D is a DFA and L(D)=∅}


Proof Idea: A DFA accepts a string iff reaches an accept
state from the start state.
A = “On input 〈𝑫〉, where 𝑫 is a DFA:
1. Mark the start state of 𝑫.
2. Repeat until no new states get marked:
3. Mark any state that has a transition coming into it
from any state that is already marked.
4. Accept if no accept state is marked; ow, reject.”
EQDFA is decidable
EQDFA = { 𝑫𝟏 , 𝑫𝟐 ∣ 𝑫𝟏 , 𝑫𝟐 DFAs and 𝑳(𝑫𝟏 ) = 𝑳(𝑫𝟐 )}
Proof Idea: Construct a new DFA D3 that recognizes
the symmetric difference of 𝐿(𝐷! ) and 𝐿(𝐷# ).
B = “On input 〈𝑫𝟏 , 𝑫𝟐 〉, where 𝑫𝟏 and 𝑫𝟐 are DFAs:
1. Construct DFA 𝑫𝟑 , as described.
2. Run TM A on 〈𝑫𝟑 〉.
3. If A accepts, accept; ow, reject.”

8/25/23 Meiram Murzabulatov; based on slides by Sofya Raskhodnikova 15


ECFG is decidable

ECFG ={ 𝑮 ∣ G is a CFG and L(G)=∅}


Proof Idea: Test whether the start variable can generate a
string of terminals.
C = “On input 〈𝑮〉, where 𝑮 is a CFG:
1. Mark all terminals in 𝑮.
2. Repeat until no new variables get marked:
3. Mark any variable V where 𝑮 has a rule V U1U2…Uk
and each of U1 ,U2 , … , Uk has already been marked.
4. Accept if the start variable is not marked; ow, reject.”

8/25/23 Meiram Murzabulatov; based on slides by Sofya Raskhodnikova 16

You might also like