Professional Documents
Culture Documents
Nicolò Felicioni1
1
Mostly based on Nicholas Mainardi’s material.
The ultimate computing model
Definition
Willing to further extend the capabilities of the PDA we
substitute the stack with one (or more) tapes
The resulting automaton is the Turing Machine, which is able
to do anything we define as computablea
The TM is able to choose whether to advance, go back or
stand still with the cursor on the tape
Multiple tapes can be added, but they do not increase the
computing power
a
or, at least, Alonso Church believed so, and we pretty much agree
The ultimate computing model
Definition
For greater comfort, we use a marker symbol Z0 to indicate
the beginning of the tape (in case it’s not there, we can add
it)
We assume that the input is positioned on the input tape
All the other tapes, if any, are filled with the blank symbol ␢
All the actions on the tapes contents are driven by a state
machine
Notation:<input tape><tape1 >, . . . , <tapen > | <tape1 >
, . . . , <tapen >, (R | S | L)n+1
Formalization
Definition
A k-tapes recognizer TM is formally defined as a 6-tuple
(Q, I, Γ, δ, q0 , F), where:
Q, is the set of states of the automata
I ∪ {␢} is the alphabet of the input string which will be checked
Γ ∪ {␢} is the alphabet of the symbols on the tapes
δ : Q × I × Γk 7→ Q × Γk × {R, S, L}k+1 the transition function
q0 ∈ Q the (unique) initial state from where the automaton
starts
F ⊆ Q the set of final accepting states of the automaton
A first example
L = an b n c n , n ≥ 1
The trick is that we can sweep over the memory tape as many
times as we want
␢␢|␢, (S, S)
q4
A bit more complex
L = an b n÷2 c n÷2 , n ≥ 1
A slight deviation from the common idea of counting
More than a single solution possible (it’s the same as saying :
“devise a program that writes such strings”)
One method to perform division: stop on the input tape,
continue in memory
Other methods involve writing twice the symbols on the tape
A bit more complex
q3 q6
cA|A, (S, R)
␢A|A, (S, R)
␢A|A, (S, L)
q7 q8
The Parrot Language
c␢ | Z0 , (R, R)
cZ0 | Z0 , (R, R)
␢␢ | ␢, (S, S)
q3 qf
bB | B, (R, R)
aA | A, (R, R)
An Enriched Parrot Language
)
,S )
cA, ␢ | A, ␢, (S, L, S) ,R ,S
bB, B | B, B, (R, R, L) R
,( ,R ␢␢, D | ␢, D, (S, S, S)
cB, ␢ | B, ␢, (S, L, S) aA, A | A, A, (R, R, L) , D , (R
| A ,D
,B | B
cZ0 , ␢ | Z0 , ␢, (R, R, L) aA , A
q2 q3 bB qf
␢␢, Z0 | ␢, Z0 , (S, S, S)
No! Recall that all types of TMs are equivalent. A recognizer for L
can be built with only 1 tape, it is just more complex than using an
additional tape. How?
The TM starts recognizing the sublanguage L1 , using the tape
as a stack
In case of a failure, the head of the tape is moved back to the
first cell, while the head of the input tape is moved back to
the first cell after the one containing the c character.
The tape can now be used as a queue to recognize the parrot
language.
An Enriched Parrot Language
aA | A, (L, L)
aB | B, (L, L)
L, L)
aZ0 | Z0 , (L, S)
␢Z0 | Z0 , (S, S)
,( ,
L)
c␢ | Z0 , (R, R)
A (L
bA | A, (L, L)
| B,
bB | B, (L, L)
bA |
bZ0 | Z0 , (L, S)
aB
bB | B, (R, R) q4 q3 cA | A, (S, L) qf
aA | A, (R, R) cZ0 | Z0 , (R, R) cB | B, (S, L)
␢␢ | ␢, (S, S)
A Powerful Computational Model
2
L = {an b n , n ≥ 1} with a 1 tape TM
Basic Idea: At each iteration, we read n times b by employing the
tape as a stack. We keep track of how many iterations have been
performed through a marker symbol M, which replaces the A
symbol used to count.
b␢ | ␢, (S, L)
bA | A, (R, L) bA | A, (S, R)
bM | M, (S, R)
␢M | M, (S, S)
b␢ | ␢, (S, L)
a␢ | Z0 , (S, R) a␢ | A, (R, R)
start q0 q1 qf
Complement
2
L = {an b n , n ≥ 1}C
We can see L as
L1 ∪ L2 , L1 = {an b m | m 6= n2 , m ≥ 0, n ≥ 1}, L2 = (a+ b ∗ )C Then,
we can build an automaton for L1 starting from the original one,
and merge it with the FSA recognizing L2
Complement
b␢ | ␢, (S, L)
q5
bA | A, (S, R)
bA | A, (R, L) bA | A, (S, R)
bM | M, (S, R)
␢M bM | ␢, (R, S)
␢A
␢A | ␢, |
␢,
| ␢ (S (
,( ,S S,
␢A | ␢, (S, S)
S, )
b␢ | ␢, (S, L)
S)
S)
start q0 q1 qf q7
a␢ | Z0 , (S, R) ␢␢ | ␢, (S, S) ␢␢ | ␢, (S, S)
a␢ | A, (R, R) b␢ | ␢, (R, S)
Complement
a
b
a
a, b
qf
b␢ | ␢, (S, L)
q5
bA | A, (S, R)
bA | A, (R, L) bA | A, (S, R)
bM | M, (S, R)
bZ0 | Z0 , (S, R)
bA | M, (R, L) ␢Z0 | Z0 , (S, R)
bM | M, (R, L) q2 q3 q4 q6
␢M | M, (S, S)
aZ A |
␢M
0
a
|
␢A | ␢,
␢ , (R
bM | ␢, (R, S)
␢A
␢
| ␢ (S ,
(R S
,
|
, (S S )
,S )
␢,
, S aM
,
)
(S
)a
A | | ␢, ( ␢A | ␢, (S, S)
,S
b␢ | ␢, (S, L) ␢, R , S
)
(R
,S )
) a␢ | ␢, (R, S)
start q0 q1 qf q7
a␢ | Z0 , (S, R) ␢␢ | ␢, (S, S) ␢␢ | ␢, (S, S)
a␢ | A, (R, R)
a␢ | ␢, (R, S) b␢ | ␢, (R, S)
b␢ | ␢, (R, S) b␢ | ␢, (R, S)
Complement
2
TM for L = {an b n , n ≥ 1}C ?
b␢ | ␢, (S, L)
q5
bA | A, (S, R)
bA | A, (R, L) bA | A, (S, R)
bM | M, (S, R)
bZ0 | Z0 , (S, R)
bA | M, (R, L) ␢Z0 | Z0 , (S, R)
bM | M, (R, L) q2 q3 q4 q6
␢M | M, (S, S)
aZ A |
␢M
0
a
|
␢A | ␢,
␢ , (R
bM | ␢, (R, S)
␢A
␢
| ␢ (S ,
(R S
,
|
, (S S )
,S )
␢,
, S aM
,
)
(S
)a
A | | ␢, ( ␢A | ␢, (S, S)
,S
b␢ | ␢, (S, L) ␢, R , S
)
(R
,S )
) a␢ | ␢, (R, S)
start q0 q1 qf q7
a␢ | Z0 , (S, R) ␢␢ | ␢, (S, S) ␢␢ | ␢, (S, S)
a␢ | A, (R, R)
a␢ | ␢, (R, S) b␢ | ␢, (R, S)
b␢ | ␢, (R, S) b␢ | ␢, (R, S)
b␢ | ␢, (S, L)
q5
bA | A, (S, R)
bA | A, (R, L) bA | A, (S, R)
bM | M, (S, R)
bZ0 | Z0 , (S, R)
bA | M, (R, L) ␢Z0 | Z0 , (S, R)
bM | M, (R, L) q2 q3 q4 q6
␢M | M, (S, S)
aZ A |
␢M
0
a
|
␢A | ␢,
␢ , (R
bM | ␢, (R, S)
␢A
␢
| ␢ (S ,
(R S
,
|
, (S S )
,S )
␢,
, S aM
,
)
(S
)a
A | | ␢, ( ␢A | ␢, (S, S)
b␢ | ␢, (S, L) ␢, R , S ,S
)
(R
,S )
) a␢ | ␢, (R, S)
start q0 q1 qf q7
a␢ | Z0 , (S, R) ␢␢ | ␢, (S, S) ␢␢ | ␢, (S, S)
a␢ | A, (R, R)
b␢ | ␢, (R, S)
b␢ | ␢, (R, S)
␢␢ | ␢, (S, S)
Single Tape TM
Definition
A k-tapes transducer TM is formally defined as a 8-tuple
(Q, I, Γ, δ, q0 , F, η, O), where:
Q, is the set of states of the automata
I ∪ {␢} is the alphabet of the input string which will be read
Γ ∪ {␢} is the alphabet of the symbols on the tapes
δ : Q × I × Γk 7→ Q × Γk × {R, S, L}k+1 the transition function
q0 ∈ Q the (unique) initial state from where the automaton
starts
F ⊆ Q the set of final accepting states
O the output alphabet (may coincide with I)
η : Q × I × Γk 7→ O∗ × {R, S}, the translation function, which
emits characters on the output tape of the automaton
Notation: hinput tapeihtape1 i . . . htapek i |
htape1 i, . . . , htapek i, houtput tapei, (R | S | L)k + 1(R | S)
An Example
τ (an b k c m ) = d min(n,m,k) | n, m, k ≥ 1
bA | A, ␢, (R, L, S)
a␢ | A, ␢, (R, R, S) bZ0 | Z0 , ␢, (R, S, S)
a␢ | Z0 , ␢, (S, R, S) b␢ | ␢, ␢, (S, L, S)
start q0 q1 q2
cA | A, ␢, (S, R, S)
cZ0 | Z0 , ␢, (S, R, S)
c␢ | ␢, ␢, (R, S, S)
qf q4 q3 cA | A, d, (R, R, R)
␢␢ | ␢, ␢, (S, S, S) c␢ | ␢, ␢, (R, S, S)
␢A | A, ␢, (S, S, S)
␢, ␢ | ␢, ␢, (S, S, S)
A Surprising Development
0␢ | Z0 , (S, R) a␢ | ␢, (R, L)
␢0 | 0, (S, L)
1␢ | Z0 , (S, R)
␢Z0 | Z0 , (S, S)
start q0 q5 qf
␢0 | 0, (S, L)
A Surprising Development
L = Nbin aN , |Nbin | = 2
start q0
0
1
q2 q1
1 1
0 0
q3 q5
a a a
q4 qf
L = Nbin aN , |Nbin | = 3
0Z0 | 0Z0 00 | 00 00 | 00
start q0 q1 q2 qf
1Z0 | 1Z0
10 | 10 Z0 | Z0
10 | 10
00 | 00 01 | 01 a1 |
q4 q11 q13
10 | 10 11 | 11
0 |
a1 |
|
|
1
a0
|0
a0 |
0
q01 1 q12
qa
1 | 10 1 | 001
|
0
q02 1 | 110
Identifying Minimum Computational Power Required For a
Language