fall 2006costas busch - rpi1 decidable languages
TRANSCRIPT
Fall 2006 Costas Busch - RPI 1
Decidable Languages
Fall 2006 Costas Busch - RPI 2
Recall that:
A language is Turing-Acceptableif there is a Turing machine that accepts
Also known as: Turing-Recognizable or Recursively-enumerable languages
LM
L
Fall 2006 Costas Busch - RPI 3
For any string :
Lw
w
halts in an accept state M
Lw halts in a non-accept stateM
or loops forever
Fall 2006 Costas Busch - RPI 4
Definition:
A language is decidableif there is a Turing machine (decider) which accepts and halts on every input string
Also known as recursive languages
L
LM
Fall 2006 Costas Busch - RPI 5
For any string :
Lw
w
halts in an accept state M
Lw halts in a non-accept stateM
Every decidable language is Turing-Acceptable
Fall 2006 Costas Busch - RPI 6
Sometimes, it is convenient to have Turing machines with single accept and reject states
acceptqrejectq
These are the only halting states
That result to possible halting configurations
Fall 2006 Costas Busch - RPI 7
We can convert any Turing machine to have single accept and reject states
acceptq
Old machine New machine
Rxx ,
Rxx ,
Rxx ,
Multiple accept states
For each tape symbol x
One accept state
Lxx ,
Fall 2006 Costas Busch - RPI 8
iq
iq Rxx ,
For all tape symbols not used for read in the other transitions of
x
iq
Old machine
New machine
rejectq
Multiple reject states One reject state
Do the following for each possible halting state:
For each
Fall 2006 Costas Busch - RPI 9
Inputstring
Accept
Reject
Decider for LDecisionOn Halt:
acceptq
rejectq
For a decidable language : L
For each input string, the computationhalts in the accept or reject state
Fall 2006 Costas Busch - RPI 10
Inputstring
Turing Machine forLacceptq
rejectq
For a Turing-Acceptable language : L
It is possible that for some input string the machine enters an infinite loop
Fall 2006 Costas Busch - RPI 11
} 7, 5, 3, 2, {1, PRIMES
Is number prime? x
Corresponding language:
Problem:
We will show it is decidable
Fall 2006 Costas Busch - RPI 12
On input number :x
Divide with all possible numbersbetween and
If any of them divides Then rejectElse accept
x2 x
Decider for : PRIMES
x
Fall 2006 Costas Busch - RPI 13
(Input string)is prime?
Decider for PRIMES
Input numberxYES
NO
the decider for the languagesolves the corresponding problem
(Accept)
(Reject)
x
acceptq
rejectq
Fall 2006 Costas Busch - RPI 14
Theorem:
If a language is decidable,then its complement is decidable too
LL
Proof:
Build a Turing machine that accepts and halts on every input string
M L
( is decider for )LM
Fall 2006 Costas Busch - RPI 15
M acceptq
M
rejectqacceptq
rejectq
aq
rq
aq
rq
Transform accept state to rejectand vice-versa
Fall 2006 Costas Busch - RPI 16
Accepts and halts on every input string
1. Let be the decider forM
If accepts then rejectIf rejects then accept
MM
M Turing Machine
On each input string do: w
2. Run with input stringM w
L
L
END OF PROOF
Fall 2006 Costas Busch - RPI 17
Undecidable Languages
An undecidable language has no decider:
There is a language which isTuring-Acceptable and undecidable
We will show that:
each Turing machine that acceptsdoes not halt on some input string
L
Fall 2006 Costas Busch - RPI 18
We will prove that there is a language :
• is not Turing-acceptable
(not accepted by any Turing Machine)
• is Turing-acceptable
LL
L
Therefore, is undecidableL
the complement of a decidable language is decidable
Fall 2006 Costas Busch - RPI 19
Decidable
Turing-Acceptable
Non Turing-Acceptable L
L
Fall 2006 Costas Busch - RPI 20
A Language which is not
Turing Acceptable
Fall 2006 Costas Busch - RPI 21
Consider alphabet }{a
,,,, aaaaaaaaaa
1a 2a 3a 4a
}{aStrings of :
Fall 2006 Costas Busch - RPI 22
Consider Turing Machinesthat accept languages over alphabet }{a
They are countable:
,,,, 4321 MMMM
(There is an enumerator that generates them)
Fall 2006 Costas Busch - RPI 23
,,,, 4321 MMMM
Each machine accepts some language over }{a
),(),(),(),( 4321 MLMLMLML
Note that it is possible to have
)()( ji MLML ji Since, a language could be accepted by more than oneTuring machine
for
Fall 2006 Costas Busch - RPI 24
Example language accepted by
},,{)( aaaaaaaaaaaaML i
},,{)( 642 aaaML i
iM
Binary representation
1a 2a 3a 4a 5a 6a 7a
)( iML
0 1 1 10 0 0
Fall 2006 Costas Busch - RPI 25
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Example of binary representations
Fall 2006 Costas Busch - RPI 26
Consider the language
)}(:{ iii MLaaL
L consists of the 1’s in the diagonal
Fall 2006 Costas Busch - RPI 27
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
},,{ 43 aaL
Fall 2006 Costas Busch - RPI 28
Consider the language
)}(:{ iii MLaaL
L consists of the 0’s in the diagonal
)}(:{ iii MLaaL
L
Fall 2006 Costas Busch - RPI 29
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
},,{ 21 aaL
Fall 2006 Costas Busch - RPI 30
Proof:
is Turing-AcceptableL
Assume for contradiction that
There must exist some machinethat accepts :
kML LML k )(
Theorem:
Language is not Turing-AcceptableL
Fall 2006 Costas Busch - RPI 31
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Question: ?1MMk LML k )(
Fall 2006 Costas Busch - RPI 32
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Answer: 1MMk )(
)(
11
1
MLa
MLa k
Fall 2006 Costas Busch - RPI 33
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Question: ?2MMk LML k )(
Fall 2006 Costas Busch - RPI 34
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Answer: 2MMk )(
)(
22
2
MLa
MLa k
Fall 2006 Costas Busch - RPI 35
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Question: ?3MMk LML k )(
Fall 2006 Costas Busch - RPI 36
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
Answer: 3MMk )(
)(
33
3
MLa
MLa k
Fall 2006 Costas Busch - RPI 37
Similarly: ik MM
)(
)(
ii
ki
MLa
MLa
)(
)(
ii
ki
MLa
MLa
for any i
Because either:
or
the machine cannot exist kM
is not Turing-AcceptableLEnd of Proof
Fall 2006 Costas Busch - RPI 38
Decidable
Turing-Acceptable
Non Turing-Acceptable
L
Fall 2006 Costas Busch - RPI 39
A Language which is Turing-Acceptableand Undecidable
Fall 2006 Costas Busch - RPI 40
There is a Turing machine that accepts
Each machinethat accepts doesn’t halt on some input string
Is Turing-Acceptable
Undecidable
)}(:{ iii MLaaL
We will prove that the language
LL
Fall 2006 Costas Busch - RPI 41
1a 2a 3a 4a
)( 1ML
0 1 10
)( 2ML
)( 3ML
01 0 1
0 1 11
)( 4ML 0 10 0
},,{ 43 aaL
Fall 2006 Costas Busch - RPI 42
The languageTheorem:
)}(:{ iii MLaaL
Is Turing-Acceptable
Proof:We will give a Turing Machine thataccepts L
Fall 2006 Costas Busch - RPI 43
Turing Machine that accepts LFor any input string w
• Compute , for which iaw
• Find Turing machine iM(using the enumerator for Turing Machines)
• Simulate on inputiMia
• If accepts, then accept iM w
i
End of Proof
Fall 2006 Costas Busch - RPI 44
Observation:
)}(:{ iii MLaaL
)}(:{ iii MLaaL
Turing-Acceptable
Not Turing-acceptable
(Thus, is undecidable)L
Fall 2006 Costas Busch - RPI 45
Decidable
Turing-Acceptable
Non Turing-Acceptable L
L
L ?
Fall 2006 Costas Busch - RPI 46
Theorem: )}(:{ iii MLaaL
is undecidable
Proof: If is decidable
Then is decidable
L
L
Contradiction!!!!
However, is not Turing-Acceptable!L
the complement of a decidable language is decidable
Fall 2006 Costas Busch - RPI 47
Decidable
Turing-Acceptable
Not Turing-Acceptable L
L
Fall 2006 Costas Busch - RPI 48
Turing acceptable languages and
Enumerators
Fall 2006 Costas Busch - RPI 49
We will prove:
• If a language is decidable then there is an enumerator for it
• A language is Turing-acceptable if and only if there is an enumerator for it
(weak result)
(strong result)
Fall 2006 Costas Busch - RPI 50
Theorem:
if a language is decidable then there is an enumerator for it
L
Proof:
Let be the decider for M L
Use to build the enumerator for M L
Fall 2006 Costas Busch - RPI 51
Example: alphabet is },{ ba
abaaabbabbaaaaab......
(proper order)
Let be an enumerator that printsall strings from input alphabet in proper order
M~
Fall 2006 Costas Busch - RPI 52
Enumerator for
Repeat:
M~1. generates a string
M
w
2. checks if Lw
YES: print to output w
NO: ignore w
L
This part terminates,because is decidable L
Fall 2006 Costas Busch - RPI 53
MM~Enumerator for
string
Give me next stringEnumerates all
strings of
input alphabet
Generates allStrings in alphabet
iwIf acceptsthen print tooutput
M iw
iw
Tests each stringif it is accepted by
L
M
output
All strings
of L
Fall 2006 Costas Busch - RPI 54
Example:
M~
abaaabbabbaaaaab
M
,....},,,{ aaabbabbL Enumeration
Output
b
ab
bbaaa
reject
reject
reject
accept
accept
accept
accept
reject
END OF PROOF
1w
2w3w
Fall 2006 Costas Busch - RPI 55
Theorem:
if language is Turing-Acceptable thenthere is an enumerator for it
L
Proof:
Let be the Turing machine that accepts M L
Use to build the enumerator for M L
Fall 2006 Costas Busch - RPI 56
MM~
Enumerator for
Accepts LEnumerates allstrings of input alphabetin proper order
L
Fall 2006 Costas Busch - RPI 57
Enumerator for
Repeat: M~ generates a string
M
w
checks if Lw
YES: print to output w
NO: ignore w
NAIVE APPROACH
Problem:If machine may loop forever
LwM
L
Fall 2006 Costas Busch - RPI 58
M~
M
1w
executes first step on
BETTER APPROACH
1w
M~ Generates second string 2w
M executes first step on 2w
second step on 1w
Generates first string
Fall 2006 Costas Busch - RPI 59
M~ Generates third string 3w
M executes first step on 3w
second step on 2w
third step on 1w
And so on............
Fall 2006 Costas Busch - RPI 60
1w 2w 3w 4w
1
Step in computationof string
1 1 1
2 2 2 2
3 3 3 3
String:
4 4 4 4
Fall 2006 Costas Busch - RPI 61
If for any string machine halts in an accepting statethen print on the output
Miw
iw
End of Proof
Fall 2006 Costas Busch - RPI 62
Theorem:
If for language there is an enumeratorthen is Turing-Acceptable
L
L
Proof:
Using the enumerator forwe will build a Turing machine that accepts
L
L
Fall 2006 Costas Busch - RPI 63
wInput Tape
Enumeratorfor L
Compare
Turing Machine that accepts Lw
iwIf same, Accept and Halt
Give me thenext stringin the enumeration sequence
Fall 2006 Costas Busch - RPI 64
Turing machine that accepts L
Loop:• Using the enumerator of , generate the next string of L
For any input string w
• Compare generated string with w
If same, accept and exit loop
End of Proof
L
Fall 2006 Costas Busch - RPI 65
By combining the last two theorems,we have proven:
A language is Turing-Acceptableif and only if there is an enumerator for it