0% found this document useful (0 votes)
26 views54 pages

Chapter 3 Decidable 2023 Final

Chapter 3 discusses decidability and decidable problems, defining a language as decidable if a Turing machine can accept it and halt for every input. It explores examples of decidable problems, such as finding odd numbers, and introduces the concept of recursively enumerable languages. The chapter also covers various decidable languages and theorems related to decidability, alongside undecidable problems that cannot be solved by any algorithm.

Uploaded by

yiyegoc814
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views54 pages

Chapter 3 Decidable 2023 Final

Chapter 3 discusses decidability and decidable problems, defining a language as decidable if a Turing machine can accept it and halt for every input. It explores examples of decidable problems, such as finding odd numbers, and introduces the concept of recursively enumerable languages. The chapter also covers various decidable languages and theorems related to decidability, alongside undecidable problems that cannot be solved by any algorithm.

Uploaded by

yiyegoc814
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Chapter 3:

Decidability and Decidable


Problems

1
Decidable Languages

2
Recall that:
A language L is Turing-Acceptable
if there is a Turing machine M
that accepts L

Also known as: Turing-Recognizable


or
Recursively-enumerable
languages
3
For any string w :
w L M halts in an accept state

w L M halts in a non-accept state


or loops forever

4
What is Decidability

• A problem is called decidable, when there is a


solution to that problem and also can
construct algorithms corresponding to that

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.

• In terms of Turing Machine (TM), if a problem


is decidable, then the Turing machine halts
whether or not it accepts its input.

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

w L M halts in a non-accept state

Every decidable language is Turing-Acceptable

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

These are the only halting states

That result to possible


halting configurations
14
We can convert any Turing machine to
have single accept and reject states

Old machine New machine

x  x ,R qaccept
x  x ,R x  x ,L

x  x ,R

For each tape symbol x


Multiple
One accept state
accept states 15
Do the following for each possible
halting state:
New machine
Old machine qreject
qi x  x, R
For each
qi For all tape symbols x
not used for read in the
other transitions of qi

Multiple
reject states One reject state
16
For a decidable language L:
Decision
Decider for L On Halt:
qaccept
Accept
Input
string
Reject
qreject

For each input string, the computation


halts in the accept or reject state
17
For a Turing-Acceptable language L:

Turing Machine for L


qaccept
Input
string
qreject

It is possible that for some input string


the machine enters an infinite loop
18
Problem: Is number x prime?

Corresponding language:

PRIMES;{2,3,5,7,…}

We will show it is decidable

19
Decider for PRIMES :
On input number x :
Divide x with all possible numbers
between 2 and x

If any of them divides x


Then reject
Else accept

20
the decider for the language
solves the corresponding problem

Decider for PRIMES


qaccept
YES
(Accept)
Input number x is x prime?
(Input string)
NO
qreject (Reject)

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:

1. Let M be the decider for L

2. Run M with input string w


If M accepts then reject
If M rejects then accept

Accepts L and halts on every input string

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.

• Is this problem solvable?

• Let’s turn this problem into a language and build


a TM to decide it.
ADFA= {<D,W>| D is a DFA that accepts W}
ADFA is the language of all strings that represent a
valid encoding of all pairs D and W,where D is an
encoding of some DFA, w is the string ,and D
accepts it.
26
The machine to decide ADFA is :
M=“On input <D,W> where D is a DFA and w
is a string
1. Simulate D on w
2. Accept if the simulation ends in the
accept state,
reject otherwise.

27
Theorem : ADFA is decidable

Proof: The TM M constructed above decides


ADFA
M halts on every input, since a DFA always halts,
so the simulator will halt too.

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}

Proof: Convert N into the representation


equivalent to DFA(such algorithm exists), and
run the machine for ADFA , on <D,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)= ∅}

Proof: Algorithm (or TM) to decide it:


Given a DFA <D>, can we go from the initial state to a
final state ?
If so, the DFA could generate some string.
Is there any final state reachable from the initial state?
A graph problem.
30
• Repeat until no new state get marked.
mark any state where there is a transition
from an already marked state to a previously
unmarked state.
Check to see if any final state got marked.

If a final state is marked, the language is not


empty.So, reject.
Else
The language is empty, So, reject.

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.

Proof: Let C be the Symmetric difference between A


and B.
(Any thing in A or B, but not in both).
32
C= A\B U B\A
C=( A n B’ ) u (A’ n B)
Note: If A=B, then the symmetric difference is ∅.

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)

Build DFA C to accept the symmetric difference.


33
• Use the TM from the previous theorem (EDFA =
Empty language) to test.

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.

• Accept if so; Reject otherwise.

34
Emptiness Problem of CFG
• Given a CFG, is the language it generates
empty?

• This is a decidable problem

• ECFG= {<G> | G is a CFG and L(G) =∅}

• ECFG is a decidable language.

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”

1. Mark all terminal symbols of G


2. Repeat until no new variable get marked:
Mark any variable A where G has a rule
A -> u1 u2…..uk has already been marked
3. If the start symbol of G is not marked, accept;
otherwise reject

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

Problem: For a given CFG grammar (N,T,P,S) and


string w ∈ Σ* , does G generates w (i.e., is
S=*>W true?)

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

Theorem (Closure Properties of Decidable Languages)


• The class of decidable languages is closed under intersection,
union, complement, concatenation and Kleene star.

• If L1 and L2 are decidable languages, then L1 ∩ L2, L1 ∪ L2,


L1’, L1.L2 and L 1* are decidable too.

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.

• Let M1 be a decider for L1.

• Consider a TM M:

”On input x:
M= 1. run M1 on x

2. if M1 accepted then M rejects else M accepts.”

• The machine M is a decider, and it accepts a string x iff M1 rejects


x. Hence M decides L1
45
undecidable problems
• The problems for which we can’t construct an algorithm that
can answer the problem correctly in the finite time are termed
as Undecidable Problems.

• A problem is undecidable if there is no Turing machine that


will always halt in a finite amount of time to answer as ‘yes’
or ‘no’.

46
47
The examples of undecidable problems:

1. Given two context-free languages, there is no Turing machine


that will always halt in a finite amount of time and give an
answer whether two context-free languages are equal or not.

2. Equivalence For Context-Free Grammars is undecidable.


EQCFG ={<G1,G2> | G1 and G2 are CFGs and L(G1)=L(G2)}

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?

– Finiteness of a Turing Machine?

– Emptiness of a Turing Machine?

– Whether the language accepted by Turing Machine is


regular or CFL?

50
Undecidable Languages

An undecidable language has no decider:


each Turing machine that accepts L
does not halt on some input string

There is a language which is


Turing-Acceptable and undecidable

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

You might also like