Queue Memory Automata

Queue Memory Automata
by
Adrian ATANASIU
Faculty of Mathematics, Bucharest University
Str. Academiei 14, sector 1
70109 Bucharest, Romania
E-mail: [email protected]
Abstract. The automata with queue memory (QM A) are constructed in
a similar way as the pushdown automata; however, the new type of memory
of QM A augments their generative capacity to L0 . The pushdown (P DA)
and finite automata can be regarded as particular cases of QM A.
AMS CLASSIFICATIONS: 03D05.
C.R. CATEGORIES; F.4.3.
The definition of queue memory automata is very similar to that of pushdown
automata; the difference concerns the type of memory: F IF O (First In First Out)
instead of LIF O (Last In First Out). Other types of extensions for pushdown
automata are proposed in [2], [3] and [4].
Definition 1 A queue memory automata (QM A) is a sextuple
M = (Q, Σ, Γ, δ, q0 , Z0 ), where the notations are the same as for pushdown automata ([1], pp. 167 - 176).
For the definition of the language accepted, we use the triples (q, α, β), where
q ∈ Q is a state, α ∈ Σ∗ is a pushdown list with left top, β ∈ Γ∗ is a queue with
the top in the left hand and the positions for memorization in the right hand.
One defines the relation ` between such triples as follows:
(q, aα, xβ) ` (p, α, βγ)
if and only if (p, γ) ∈ δ(q, a, x), where p, q ∈ Q, a ∈ Σ ∪ {λ} (λ – the empty
sentence), x ∈ Γ, α ∈ Σ∗ , β, γ ∈ Γ∗ .
If card(δ(q, a, x)) ≤ 1 for all q ∈ Q, a ∈ Σ ∪ {λ}, x ∈ Γ, the QM A M is
deterministic. Otherwise, M is a nondeterministic QM A.
∗
By denoting ` the reflexive and transitive closure of `, the language accepted
by a QM A can be defined as follows:
∗
LQM A (M ) = {w | w ∈ Σ∗ , (q0 , w, Z0 ) ` (q, λ, λ)}
1
Example 1 The language L1 = {an bn cn | n ≥ 1} is accepted by deterministic
QM A M = (Q, Σ, Γ, δ, a0 , Z0 ) where Q = {q0 , q1 , q2 }, Σ = {a, b, c}, Γ =
{Z0 , A, B}, δ(q0 , a, Z0 ) = (q0 , A), δ(q0 , b, A) = (q1 , B), δ(q1 , c, B) =
(q2 , λ), δ(q0 , a, A) = (q0 , AA), δ(q1 , b, A) = (q1 , B), δ(q2 , c, B) = (q2 , λ).
Instead of proving the equality LQM A (M ) = L1 , we prefer to show how the
automaton works in a peculiar case:
(q0 , a2 b2 c2 , Z0 ) ` (q0 , ab2 c2 , A) ` (q0 , b2 c2 , AA) ` (q1 , bc2 , AB) ` (q1 , c2 , BB) `
(q2 , c, B) ` (q2 , λ, λ)
Example 2 The nondeterministic QM A defined by
Q = {q0 , q1 }, Σ = {a}, Γ = {Z0 , A} and
δ(q0 , a, Z0 ) = {(q0 , Z0 AA), (q1 , λ)}, δ(q0 , a, A) = {(q0 , A)}, δ(q1 , a, A) = {(q1 , λ)}
2
accepts the language L2 = {an | n ≥ 1}.
For example, (q0 , a9 , Z0 ) ` (q0 , a8 , Z0 AA) ` (q0 , a7 , AAZ0 AA) `
∗
(q0 , a6 , AZ0 AAA) ` (q0 , a5 Z0 A5 ) ` (q0 , a4 , Z0 A4 ) ` (q0 , λ, λ).
Example 3
n
For the language L3 = {a2 | n ≥ 1}, the next QM A can be constructed(only
the mapping δ will be detailed): δ(q0 , a, Z0 ) = {(q1 , Z0 A)}, δ(q0 , λ, a) =
{(q0 , A)}, δ(q2 , λ, B) = {(q2 , B)}, δ(q1 , a, Z0 ) = {(q0 , Z0 ), (q0 , B)}, δ(q0 , λ, B) =
{(q2 , B), (q4 , B)}, δ(q1 , λ, A) = {(q1 , A)}, δ(q2 , λ, A) = {(q3 , λ)}, δ(q3 , λ, A) =
{(q2 , A)}, δ(q3 , λ, B) = {(q4 , λ)}.
Proposition 1 Any P DA can be simulated by a QM A.
Proof: Let us consider a pushdown automaton Mp = (Qp , Σp , Γp , δp , q0 , Z0 ). We
shall construct the QM A Mc = (Qc , Σc , Γc , δc , q0 , Z0 ) as follows:
Σc = Σp , Qc = Qp ∪ {qc }, Γc = Γp ∪ {Zi0 | qi ∈ Qp }, (qc 6∈ Qp , Zi0 6∈ Γp ).
For every (qj , α) ∈ δp (qi , a, x) one defines
δc (qi , a, x) = {(qc , Zj0 , α)}, δc (qc , λ, Zj0 ) = {(qj , λ)}.
Finally, (δc , λ, x) = {(qc , x)}, ∀x ∈ Γp .
The equality L(Mp ) = LQM A (Mc ) is immediate. We remark that Mc is deterministic if and only if Mp is deterministic.
2
Corollary 1 Any finite automaton (F A) can be simulated by a queue memory
automaton.
Proposition 2 L is a regular language if and only if it is accepted by a QM A
with queue length at most 1.
Proof: ”=⇒”: Obvious.
”⇐=”: Let us consider a QM A M = (Q, Σ, Γ, δ, q0 , Z0 ) where the mapping
δ is defined as follows:
(p, y) ∈ δ(q, a, x) with y ∈ Γ ∪ {λ}
2
The use of a rule with y = λ will empty the queue, so this rule have to be applied
only once, at the last step.
We shall construct the regular grammar G = (VN , VT , S, P ) where VN = Q ×
Γ, VT = Σ, S = [q0 , Z0 ] and [q, x] −→ a[p, y] if and only if (p, y) ∈ δ(q, a, x).
The equality L(G) = LQM A (M ) is immediate.
2
Remark 1 It seems that the class of languages accepted by queue memory automata with card(Q) = 1 is L3 , but this assertion is not true. Indeed, for example, the QM A with δ defined as follows: δ(q0 , a, Z0 ) = (q0 , Z1 Z1 ), δ(q0 , b, Z1 ) =
(q0 , Z0 Z0 ), δ(q0 , a, Z1 ) = (q0 , λ), δ(q0 , b, Z0 ) = (q0 , λ) accepts the language
n
n
n
n
L = {ab2 a4 b8 . . . a2 b2 |n ≥ 0} ∪ {ab2 . . . b2 a2 | n ≥ 0}.
Let Lq be the class of languages accepted by queue memory automata. We have
Theorem 1 Lq = L0 .
Proof: Let G = (VN , VT , S, P ) be a grammar of type 0 with L(G) = L. We shall
divide the set of rules P into two sets P1 ∪ P2 , where P1 = {i : x1 x2 . . . xni −→
y1 y2 . . . yk | ni ≥ 0, k ≥ 0, 1 ≤ i ≤ p} (the productions which are not context free are labelled) and P2 = P \ P1 .
The QM A M = (Q, Σ, Γ, δ, q0 , Z0 ) is build as follows:
Σ = VT ,
Q = {q0 , q1 , q2 } ∪
p
[
{qir | 1 ≤ r ≤ ni − 1},
Γ = VN ∪ VT ∪ {Z0 , ·}.
i=1
For every rule i : x1 x2 . . . xni −→ y1 y2 . . . yk ∈ P1 we define
δ(q0 , λ, x1 ) = {(q0 , x1 ), (qi1 , λ)}
δ(qir , λ, xr+1 ) = {(qir+1 , λ)}
1 ≤ r ≤ ni − 2
ni −1
δ(qi , λ, xni ) = {(q1 , y1 y2 , . . . yk )}
For every production x −→∈ P2 ,
Further on one define
δ(q0 , λ, x) = {(q0 , x), (q1 , α)}
δ(q0 , λ, Z0 ) = {(q0 , S·)}, δ(q0 , λ, a) = {(q0 , a)}, ∀a ∈ VT
δ(q1 , λ, ·) = {(q0 , ·)},
δ(q0 , λ, ·) = {(q2 , λ)},
δ(q2 , a, a) = {(q2 , λ)},
δ(q1 , λ, x) = {(q1 , x)} ∀a ∈ VT , x ∈ Γ \ {·}
The equality LQM A (M ) = L results from the following facts:
• If no production is applied, then the automaton reaches the state q0 .
• The application of a production passes the automaton in a state q1 . Now,
the queue is turned around until the delimitator ’·’ reaches the top (the goal
is the realization of the same sentential form as in grammar derivation). So,
the derivation in G is simulated step by step in M .
• If the automaton reaches the state q0 with ’·’ in the queue top, the no rule
has to be applied in the last turning round. So, in QM A memory there is
a terminal word. Now, ’·’ is erased and the automaton passes in the state
q2 .
3
• The state q2 reduces the word from memory, character by character, ticking
it with the input. That is, the recognition part of the QM A automaton.
• The 0 - type grammars with left-derivations do not cover the class of L0
languages. Accordingly, this restriction was avoided in the queue automata
by (q0 , u) ∈ δ(q0 , λ, u), u ∈ {x, x1 }.
The inclusion Lq ⊆ L0 is obtained by Church’s thesis.
2
References
[1] A.V. Aho, J.D. Ullman - The Theory of Parsing, Translation and Compiling,
Prentice Hall Englewood Cliffs N.J. 1972, 1973.
[2] M.D. Davis, E.J. Weyuker - Computability, Complexity and Languages, Academic press Inc. 1983.
[3] J. Hopcroft, A.V. Ulmann - The Formal languages and their relation to automata, Addison Wesley Reading, Mass. 1969.
[4] - Automata, Languages and Programming, Proceedings of a symposium IRIA,
July 3-7 (1972), North Holland Publ. Co, 1973.
4