0% found this document useful (0 votes)
11 views3 pages

10 TM Sols

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)
11 views3 pages

10 TM Sols

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/ 3

Languages and Automata #10

Turing machines

1. Give the state diagram or transition function of a Turing machine which recognizes L = {w#w |
w ∈ {0,1}∗ }.
Solution:

reading writing
state 1st tape 2nd tape 1st tape 2nd tape new state
q0 0 * 0 S X R q1
1 * 1 S X R q1
* * * S * S q5
q1 0 * 0 R 0 R q1
1 * 1 R 1 R q1
δ:
# * # S X L q2
q2 # 0 # S 0 L q2
# 1 # S 1 L q2
# X # R X R q3
q3 0 0 0 R 0 R q3
1 1 1 R 1 R q3
* X * S X S qF

2. Give the state diagram or transition function of a Turing machine which recognizes L = {w#wR |
w ∈ {0,1}∗ }, where wR is the reverse of w.
Solution:

reading writing
state 1st tape 2nd tape 1st tape 2nd tape new state
q0 0 * 0 S X R q1
1 * 1 S X R q1
* * * S * S q5
δ: q1 0 * 0 R 0 R q1
1 * 1 R 1 R q1
# * # R X L q2
q2 0 0 0 R 0 L q2
1 1 1 R 1 L q2
* X * S X S qF
3. Let M be the following 2-tape Turing machine: M = (Q,Σ,Γ,δ, ∗ ,q0 ,F ), where
Q = {q0 ,q1 ,q2 ,q3 ,q4 ,q5 }, Σ = {0,1}, Γ = {X,0,1,∗}, F = {q5 },

reading writing
state 1st tape 2nd tape 1st tape 2nd tape new state
q0 0 * 0 S X R q1
1 * 1 S X R q1
* * * S * S q5
q1 0 * 0 R 0 R q1
1 * 1 R 1 R q1
* * * S * L q2
q2 * 0 * S 0 L q2
δ: * 1 * S 1 L q2
* X * L X R q3
q3 0 0 0 S 0 R q4
1 1 1 S 1 R q4
q4 0 0 0 L 0 S q3
0 1 0 L 1 S q3
1 0 1 L 0 S q3
1 1 1 L 1 S q3
0 * 0 S * S q5
1 * 1 S * S q5

Which 0–1 sequences are accepted by M ? (By our definition if δ is not defined and the current state
is not in F , then M rejects.)
Solution: The Turing machine accepts palindromes.
4. Let the language L ⊂ {a, b}∗ contain the strings s that start with a, and in s the ith block of letters
is at least i. (For example abbbbaaa ∈ L, because the first block has length 1, the second has length
4 ≥ 2, the third has length 3.) Design a Turing machine M that accepts L. You can use more than
one tape if it is convenient. (Describe in English the idea how your machine works, then specify the
TM according to the definition or by a diagram.)
Solution: The Turing machine have i letters on it’s second tape, and checks if the ith block is at
least that long.

reading writing
state 1st tape 2nd tape 1st tape 2nd tape new state
q0 a * a S X R q1
b * b S X R q1
* * * S * S qF
q1 a * a S a L qr
b * b S a L qr
qr a a a S a L qr
b a b S a L qr
δ: a X a S X R qa
b X b S X R qb
qa a a a R a R qa
a * a R * S qa
b * b S a L qr
* * * S * S qF
qb b a b R a R qb
b * b R * S qb
a * a S a L qr
* * * S * S qF

5. Let L1 , L2 be two languages. Prove that L1 , L2 ∈ R implies that L1 ∪ L2 ∈ R.


Solution: Run the Turing machines for L1 and L2 on the input. If either or both accepts, accept.
If both rejects, reject.

You might also like