380 likes | 570 Views
Turing Machine accepting { zz | z ∈ {a, b}∗} . Tracing strings aabb & bb by Brian Morales. let’s trace this TM on the string aabb to show rejection. Begin from the initial configuration:. q 0 ∆ aabb. ∆/∆, R input symbol is ∆ / replace it with ∆ and move the state to the right.
E N D
Turing Machine accepting{zz | z ∈ {a, b}∗} Tracing strings aabb & bb by Brian Morales
let’s trace this TM on the string aabbto show rejection. Begin from the initial configuration: q0∆aabb
∆/∆, R input symbol is ∆ / replace it with ∆ and move the state to the right q0∆aabb Ⱶ ∆q1aabb
a/A, R input symbol is a / replace it with A and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb
a/a, R input symbol is a / replace it with aand move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb
b/b, R input symbol is b / replace it with b and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b
b/b, R input symbol is b / replace it with b and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆
∆/∆, L input symbol is ∆ / replace it with ∆ and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b
b/B, L input symbol is b / replace it with Band move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB
b/b, L input symbol is b / replace it with b and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB
a/a, L input symbol is a / replace it with aand move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB
A/A, R input symbol is A / replace it with A and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB
a/A, R input symbol is a / replace it with A and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB
b/b, R input symbol is b / replace it with b and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B
B/B, L input symbol is B / replace it with B and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB
b/B, L input symbol is b / replace it with B and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB
A/A, R input symbol is A / replace it with A and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB
B/B, L input symbol is B / replace it with Band move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB
A/a, L input symbol is A / replace it with a and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB
A/a, L input symbol is A / replace it with a and move the state to the left q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB Ⱶ q5∆aaBB
∆/∆, R input symbol is ∆ / replace it with ∆ and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB Ⱶ q5∆aaBB Ⱶ ∆q6aaBB
a/A, R input symbol is a / replace it with A and move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB Ⱶ q5∆aaBB Ⱶ ∆q6aaBB Ⱶ ∆Aq8aBB
a/a, R input symbol is a / replace it with aand move the state to the right q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB Ⱶ q5∆aaBB Ⱶ ∆q6aaBB Ⱶ ∆Aq8aBB Ⱶ ∆Aaq8BB
There is nowhere to go from q8 with input B, therefore the string aabb is rejected by this TM q0∆aabb Ⱶ ∆q1aabb Ⱶ ∆Aq2abb Ⱶ ∆Aaq2bb Ⱶ ∆Aabq2b Ⱶ ∆Aabbq2∆ Ⱶ ∆Aabq3b Ⱶ ∆Aaq4bB Ⱶ ∆Aq4abB Ⱶ ∆q4AabB Ⱶ ∆Aq1abB Ⱶ ∆AAq2bB Ⱶ ∆AAbq2B Ⱶ ∆AAq3bB Ⱶ ∆Aq4ABB Ⱶ ∆AAq1BB Ⱶ ∆Aq5ABB Ⱶ ∆q5AaBB Ⱶ q5∆aaBB Ⱶ ∆q6aaBB Ⱶ ∆Aq8aBB Ⱶ ∆Aaq8BB Ⱶ ∆AahrBB(reject) Accept only if state ha is reached!
let’s trace this TM on the string bb to show acceptance. Begin from the initial configuration: q0∆bb
∆/∆, R input symbol is ∆ / replace it with ∆ and move the state to the right q0∆bb Ⱶ ∆q1bb
b/B, R input symbol is b / replace it with B and move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b
b/b, R input symbol is b / replace it with b and move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆
∆ / ∆, L input symbol is ∆ / replace it with ∆ and move the state to the left q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b
b / B, L input symbol is b / replace it with B and move the state to the left q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB
B / B, R input symbol is B / replace it with B and move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B
B / B, L input symbol is B / replace it with B and move the state to the left q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB
B / b, L input symbol is B / replace it with b and move the state to the left q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB
∆ / ∆, R input symbol is ∆ / replace it with∆and move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB Ⱶ ∆q6bB
b / B, R input symbol is b / replace it withBand move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB Ⱶ ∆q6bB Ⱶ ∆Bq7B
B / ∆, L input symbol is B / replace it with∆and move the state to the left q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB Ⱶ ∆q6bB Ⱶ ∆Bq7B Ⱶ ∆q9B
B / B, R input symbol is B / replace it withBand move the state to the right q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB Ⱶ ∆q6bB Ⱶ ∆Bq7B Ⱶ ∆q9B Ⱶ ∆Bq6∆
∆ / ∆, S input symbol is ∆ / replace it with∆and halt. String bb is accepted by this TM q0∆bb Ⱶ ∆q1bb Ⱶ ∆Bq2b Ⱶ ∆Bbq2∆ Ⱶ ∆Bq3b Ⱶ ∆q4BB Ⱶ ∆Bq1B Ⱶ ∆q5BB Ⱶ q5∆bB Ⱶ ∆q6bB Ⱶ ∆Bq7B Ⱶ ∆q9B Ⱶ ∆Bq6∆ Ⱶ ∆Bha∆ (accept)