Chapter 3 Decidable 2023 Final
Chapter 3 Decidable 2023 Final
1
Decidable Languages
2
Recall that:
A language L is Turing-Acceptable
if there is a Turing machine M
that accepts L
4
What is Decidability
5
Example of Decidable Problem
• Find all the odd numbers in the range from 1
to 50.
• For this problem, we can easily find a solution
by constructing an algorithm.
6
• In terms of finite automata (FA), decidable
refers to the problem of testing whether a
deterministic finite automata (DFA) accepts an
input string. A decidable language
corresponds to algorithmically solvable
decision problems
7
Definition:
A language L is decidable
if there is a Turing machine (decider) M
which accepts L
and halts on every input string
8
• Decidability
For the Recursive Language
• A language ‘L’ is said to be recursive if there
exists a Turing Machine which will accept all
the strings in ‘L’ and reject all the strings not in
‘L’.
• The TM will halt every time and give an
answer either accepted or rejected for each
and every input.
9
For any string w:
w L M halts in an accept state
10
Recursively Enumerable languages −
• A language ‘L’ is said to be recursively
enumerable if there exists a TM which accepts
and halt for all input in ‘L’.
• But may or may not halt for all input, which
are not in ‘L’.
11
• A Language ‘L’ is decidable if it is a recursive
language.
• All decidable languages are recursive
languages and vice versa.
• The diagram given below explains the
decidable language −
12
13
Sometimes, it is convenient to have Turing
machines with single accept and reject states
qaccept
qreject
x x ,R qaccept
x x ,R x x ,L
x x ,R
Multiple
reject states One reject state
16
For a decidable language L:
Decision
Decider for L On Halt:
qaccept
Accept
Input
string
Reject
qreject
Corresponding language:
PRIMES;{2,3,5,7,…}
19
Decider for PRIMES :
On input number x :
Divide x with all possible numbers
between 2 and x
20
the decider for the language
solves the corresponding problem
21
Theorem:
If a language L is decidable,
then its complement L is decidable too
Proof:
Build a Turing machine M that
accepts L and halts on every input string
( M is decider for L )
22
Transform accept state to reject
and vice-versa
M M
qaccept qreject
qa qa
qreject qaccept
qr qr
23
Turing Machine M
On each input string w do:
END OF PROOF 24
Which Languages are decidable?
• There are 4 types of Languages which we will
define further:
– Language ADFA
– Language ANFA
– Language ACFG
– Language ATM
25
Acceptance Problem for DFA
Given a DFA D and the input string w, determine if
D accepts w.
27
Theorem : ADFA is decidable
28
Acceptance Problem for NFSAs
• Given A NFA N and the input string w,
determine if N accepts W.
• The language
ANFA = {<N,W> | N is a NFA that accepts w}
29
Emptiness Problem for DFAs is decidable
• Given a DFA D, determine if D accepts any string at
all.
i.e, if L(D)= ∅
• The language
EDFA= { <D> | D is a DFA and L(D)= ∅}
31
Theorem : Equivalence Problem for DFAs is decidable
Given two DFAs A and B, determine if they recognize
the same language.
i.e: L(A) = L(B)
The language
EQDFA :{<A,B> | A and B are DFAs and L(A)=L(B)}
Is decidable.
Given
A= DFA to accept L(A)
B= DFA to accept L(B)
We know how to construct DFA,
L(A)
L(A) n L(B)
L(A) n L(B)
Summary:
• Construct a TM
• Input: <A,B> ( two DFAs)
• Construct a DFA C to accept
L(C ) = (L(A) n L(B)) U (L(A) n L(B))
• Use the previous TM to test whether the
language that C accepts is empty.
34
Emptiness Problem of CFG
• Given a CFG, is the language it generates
empty?
35
• To test whether L(G) is empty, we need to test
whether G can generate a string of terminals
• Determining for each variable whether that variable
can generate a string of terminals
• When the algorithm determines that a variable can
generate a string of terminals the algorithm marks
that variable.
• The algorithm starts by marking first all terminals.
Then it marks variables that have on their right hand
side in some rules only terminals, i.e., marked
symbols, and so
36
Algorithm (a marking Algorithm)
input : A CFG “G”
37
• Example:
Consider the following grammar:
S ABCD
A BCA
A xyz
B CA
B AB
B BBBw
C CB
C ww
D DD
B BD
Is L(G) = ∅ ? 38
Solution:
• Mark A everywhere it occurs since it generates all
terminals
• Mark C, since it generates string of terminals
Consider:
B->CA
Since both C and A generate string of terminals, B can
also generate string of terminals. So mark B.
Can D generate string of terminals? No.
D cannot be marked.
S cannot be marked since D cannot be marked.
So, L(G) is empty.
39
Acceptance problem of CFG :
• Checking if a CFG generates a particular string
Language:
ACFG= { <G,w> | G a CFG that generates string w}
• ACFG is Decidable
40
Fact :
• If G is a CFG in Chomsky normal form then for any
w ∈ L(G) where |w| = n ,exactly 2n-1 steps are
required for any derivation of w.
41
The TM that decide ACFG
is:
S= "On input <G,w> , where is a CFG and w is a string:
1. Convert G to an equivalent grammar in Chomsky normal
form
2. List all derivations with 2n-1 steps, except if n<=1;
for n<=1,list all derivations with 1 step
3. If any of the derivations listed above generates w, accept; if
not reject
42
Closure Properties of Decidable Languages
43
Proof:
Closure of Decidable Languages under Intersection
• Let L1 and L2 be decidable. We show that L1 ∩ L2 is decidable
too.
• Let M1 be a decider for L1 and M2 be a decider for L2.
• Consider a 2-tape TM M:
– ”On input x:
1. copy x on the second tape
2. on the first tape run M1 on x
3. if M1 accepted then goto 4. else M rejects
M= 4. on the second tape run M2 on x
5. if M2 accepted then M accepts else M rejects.”
– The machine M is a decider and it accepts a string x iff
both M1 and M2 accept x.
44
Proof: Closure of Decidable Languages under
Complement
• Let L1 be a decidable language. We show that L1’ is decidable too.
• Consider a TM M:
”On input x:
M= 1. run M1 on x
46
47
The examples of undecidable problems:
48
3. Whether a CFG generates all the strings or not?
As a CFG generates infinite strings, we can’t ever reach up to the
last string and hence it is Undecidable.
4. Ambiguity of CFG?
There exist no algorithm which can check whether for the
ambiguity of a CFL.
49
Undecidable Problems related to Turing machine:
– Membership problem of a Turing Machine?
50
Undecidable Languages
51
there is a language L :
• L is not Turing-acceptable
(not accepted by any Turing Machine)
• L is Turing-acceptable
the complement of a
decidable language is decidable
Therefore, L is undecidable
52
Non Turing-Acceptable L
Turing-Acceptable L
Decidable
53
Non Turing-Acceptable
L
Turing-Acceptable
Decidable
54