2. Decidable Languages
EECS 2001 Introduction to Theory of Computation 2
Problem: does a NFA / DFA accept a string?
Problem: does a CFG generate a string?
Problem: does a PDA accept a string?
Problem: does TM accept a string?
We need a yes or no answer. However, to get that answer, we
need the string to go through the DFA/NFA/CFG/PDA/TM
We can reword our problem as a problem of acceptance
3. Decidable Languages
EECS 2001 Introduction to Theory of Computation 3
The problem of acceptance for DFAs of testing whether a
particular string is accepted by a particular DFA can be
presented as a language.
Such a language will contain pairs of DFA and its
corresponding acceptable strings
ADFA = {(w, D) | D is a DFA which accepts the string w}
w3= 100, Donly one 1
w1= 1100, Dequal 0s and 1s
w2= 001100, Dequal 0s begin/end
4. Decidable Languages
EECS 2001 Introduction to Theory of Computation 4
Is ADFA Decidable?
Can we have an algorithm which takes a DFA D and a string w
and decide whether w is accepted by D?
If yes, then ADFA is decidable
How can we achieve this?
5. Decidable Languages
EECS 2001 Introduction to Theory of Computation 5
Recap
Remember that we explored how one TM variant can be converted to
the other…
Let us call that technique as “simulating TM1 on TM 2”
6. Decidable Languages
EECS 2001 Introduction to Theory of Computation 6
Is ADFA Decidable?
Let us make a TM (algorithm)
1. Simulate the DFA D on the TM and consume w
2. If D ends in the accept state, accept. If D ends in reject
state, reject.
7. Decidable Languages
EECS 2001 Introduction to Theory of Computation 7
Is ADFA Decidable?
Let us make a TM (algorithm)
1. Simulate the DFA D on the TM and consume w
a. keep track of D’s current state
b. keep track of where (the current position) the
machine is while reading w i.e. input
2. If D ends in the accept state, accept. If D ends in reject
state, reject.
8. Decidable Languages
EECS 2001 Introduction to Theory of Computation 8
Is ADFA Decidable?
Implementation details of the TM TDFA.
Check the input, it should be a pair (D, w)
D can be represented as Q, Σ, δ, q0, and F. If input is correct, move to the
next step, otherwise reject.
Start the simulation of D on TDFA.
Current state of D and current position on the input string w, are stored on the tape
of T.
Example: at the beginning, the current state would be ___ and the current input
symbol would be the ___________________
The state and current position keep getting updated based on _________
When the last input symbol is consumed:
AND D is in the final state (current state is in F), TDFA accepts.
If D is not in the final state, TDFA rejects.
9. Decidable Languages
EECS 2001 Introduction to Theory of Computation 9
Is ADFA Decidable?
Implementation details of the TM TDFA.
Check the input, it should be a pair (D, w)
D can be represented as Q, Σ, δ, q0, and F. If input is correct, move to the
next step, otherwise reject.
Start the simulation of D on TDFA.
Current state of D and current position on the input string w, are stored on the
tape of T.
Example: at the beginning, the current state would be q0 and the current input
symbol would be the leftmost symbol of w
The state and current position keep getting updated based on δ
When the last input symbol is consumed AND:
D is in the final state (current state is in F), TDFA accepts.
D is not in the final state, TDFA rejects.
10. Decidable Languages
EECS 2001 Introduction to Theory of Computation 10
Is ANFA Decidable?
TM (algorithm)
Convert NFA N into DFA D
Check the input, it should be a pair (D, w)
D can be represented as Q, Σ, δ, q0, and F. If input is correct, move to the
next step, otherwise reject.
Start the simulation of D on TDFA.
Current state of D and current position on the input string w, are stored on the tape
of T.
Example: at the beginning, the current state would be q0 and the current input
symbol would be the leftmost symbol of w
The state and current position keep getting updated based on δ
When the last input symbol is consumed AND:
D is in the final state (current state is in F), TDFA accepts.
D is not in the final state, TDFA rejects.
11. Decidable Languages
EECS 2001 Introduction to Theory of Computation 11
Is AREX Decidable?
TM (algorithm)
Convert Regular Expression REX into NFA N and NFA N into DFA D
Check the input, it should be a pair (D, w)
D can be represented as Q, Σ, δ, q0, and F. If input is correct, move to the
next step, otherwise reject.
Start the simulation of D on TREX.
Current state of D and current position on the input string w, are stored on the tape
of T.
Example: at the beginning, the current state would be q0 and the current input
symbol would be the leftmost symbol of w
The state and current position keep getting updated based on δ
When the last input symbol is consumed AND:
D is in the final state (current state is in F), TREX accepts.
D is not in the final state, TREX rejects.
12. Decidable Languages
EECS 2001 Introduction to Theory of Computation 12
In all previous three examples, once we make the TDFA , it can
be used to develop other TMs.
Think of it as a function call (in programming language terms).
TDFA would be the called function
13. Decidable Languages
EECS 2001 Introduction to Theory of Computation 13
Is the language Aempty Decidable? Also called emptiness testing
Language which contains no strings
How to represent it?
EDFA = {⟨A⟩| A is a DFA and L(A) = ∅}.
14. Decidable Languages
EECS 2001 Introduction to Theory of Computation 14
Is the language EDFA Decidable?
EDFA = {⟨A⟩| A is a DFA and L(A) = ∅}.
TM (algorithm)
Start with labelling the initial state of A
Label any state that can be reached from the already labelled states
using one of the valid transitions
Repeat this step until no new states can be labelled
Check whether among all the labelled states, if there is a final state. If
yes, then that means that through some valid sequence of transitions
(which an input string can use), we can get to the final state from the
initial state, reject.
Remember: we want a DFA which does not accept any string.
15. Decidable Languages
EECS 2001 Introduction to Theory of Computation 15
Can we decide whether two given DFAs are equal?
EQDFA = {⟨A,B⟩| A and B are DFAs and L(A) = L(B)}.
Any ideas?
16. Decidable Languages
EECS 2001 Introduction to Theory of Computation 16
Can we decide whether two given DFAs are equal?
EQDFA = {⟨A,B⟩| A and B are DFAs and L(A) = L(B)}.
Design a new language L(C)
Has all the strings in L(A) which are not in L(B)
Has all the strings in L(B) which are not in L(A)
L(C) = L(A) ∩ L(B)’ ∪ L(A)’ ∩ L(B)
this is also called symmetric difference of L(A) and L(B)
L(C) = ∅ iff L(A) = L(B).
17. Decidable Languages
EECS 2001 Introduction to Theory of Computation 17
Can we decide whether two given DFAs are equal?
EQDFA = {⟨A,B⟩| A and B are DFAs and L(A) = L(B)}.
Design a new language L(C)
TM (algorithm)
Construct DFA for L(C)
Use TM for EDFA from the previous slides on the input
If L(C) is empty, i.e., there are no acceptable string, then L(A) = L(B), accept.
If L(C) is non-empty, i.e., there is at least one acceptable string, then L(A) ≠
L(B), reject.
18. Decidable Languages
EECS 2001 Introduction to Theory of Computation 18
Is ACFG decidable?
Similar to ADFA , here we aim to see whether a string w can be generated by a CFG.
Any ideas?
19. Decidable Languages
EECS 2001 Introduction to Theory of Computation 19
Is ACFG decidable?
Similar to ADFA , here we aim to see whether a string w can be generated by a CFG.
Any ideas?
Can we go though all the different derivations?
We might have to try infinitely many possibilities
Especially, if the w is not an acceptable string, the TM will never stop. We will
never not if it is stuck or just processing.
20. Decidable Languages
EECS 2001 Introduction to Theory of Computation 20
Is ACFG decidable?
Similar to ADFA , here we aim to see whether a string w can be generated by a CFG.
Any ideas?
Can we go though all the different derivations?
We might have to try infinitely many possibilities
Especially, if the w is not an acceptable string, the TM will never stop. We will
never not if it is stuck or just processing.
We need to convert the problem into one where there are only finite
derivations
Any ideas?
21. Decidable Languages
EECS 2001 Introduction to Theory of Computation 21
Is ACFG decidable?
Similar to ADFA , here we aim to see whether a string w can be generated by a CFG.
Any ideas?
Can we go though all the different derivations?
We might have to try infinitely many possibilities
Especially, if the w is not an acceptable string, the TM will never stop. We will
never not if it is stuck or just processing.
We need to convert the problem into one where there are only finite
derivations
Any ideas? Chomsky Normal Form. If a CFG is in CNF, any derivation of w
has 2n-1 steps where n = |w|
22. Decidable Languages
EECS 2001 Introduction to Theory of Computation 22
Is ACFG decidable?
Similar to ADFA , here we aim to see whether a string w can be generated by a CFG.
TM(algorithm)
Convert CFG G into CNF
List all the derivations of G with 2n-1 steps such that n = |w|
If n = 0, list those derivations with one step
If any of the above derivations generate w, accept, if not, reject.
23. Decidable Languages
EECS 2001 Introduction to Theory of Computation 23
Is ECFG decidable?
Similar to EDFA , here we aim to see whether any string at all can be generated by a
CFG.
Ideas? Let us use the TM from ACFG
24. Decidable Languages
EECS 2001 Introduction to Theory of Computation 24
Is ECFG decidable?
Similar to EDFA , here we aim to see whether any string at all can be generated by a
CFG.
Ideas? Let us use the TM from ACFG
Try all the possible words?
Infinite possibilities
S AB
A a
BB
25. Decidable Languages
EECS 2001 Introduction to Theory of Computation 25
Is ECFG decidable?
Similar to EDFA , here we aim to see whether any string at all can be generated by a
CFG.
Ideas?
Can we find whether all variables terminate? i.e., generate terminal symbols
26. Decidable Languages
EECS 2001 Introduction to Theory of Computation 26
Is ECFG decidable?
Similar to EDFA , here we aim to see whether any string at all can be generated by
a CFG.
TM (algorithm)
Mark all the terminal symbols
Mark any variable A if there is a rule in the grammar AX1X2X3…Xk and all
symbols on the RHS have already been marked.
Keep repeating this until we cannot mark anymore variables
If we were able to mark the start variable, reject (we were able to reach from the
start variable from terminals).
If we were not able to mark the start variable, accept (we were not able to reach
the start variable from any of the terminals)
27. References
EECS 2001 Introduction to Theory of Computation 27
Ideas, problems and their solutions in this lecture/tutorial have been taken from
• Prof. Jeffery Edmonds’ Lecture notes for EECS 2001 at York University
• Prof. Suprakash Datta’ Lecture notes for EECS 2001 at York University
• Introduction to the Theory of Computation (3rd edition) by Michael Sipser
• Introduction to Theory of Computation by Anil Maheshwari and Michiel Smid
• Wikipedia and other webpages of different professors/universities