a modified presentation of the decidability proof for ... · a modified presentation of the...
TRANSCRIPT
A modified presentation of the decidability prooffor language equivalence
on deterministic pushdown automata
Petr Jancar
Dept of Computer ScienceTechnical University Ostrava (FEI VSB-TU)
Czech Republicwww.cs.vsb.cz/jancar
ABCDays on List Automata, Forgetting Automata, and RestartingAutomata
Prague, March 27-29, 2009
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 1 / 31
DPDA results
Senizergues G.:L(A)=L(B)? Decidability results from complete formal systems.Theoretical Computer Science 251(1-2): 1-166 (2001)(a preliminary version appeared at ICALP’97; Godel prize 2002)
Stirling C.: Decidability of DPDA equivalence.Theoretical Computer Science 255, 1-31, 2001
Senizergues G.: L(A)=L(B)? A simplified decidability proof.Theoretical Computer Science 281(1-2): 555-608 (2002)
Stirling C.: Deciding DPDA equivalence is primitive recursive.ICALP 2002, Lecture Notes in Computer Science 2380, 821-832,Springer 2002 (longer draft paper, 38 pages)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 2 / 31
Example of a DPDA M
q0Z0a
−→ q0A
q0Z0b
−→ q0B
q0Aa
−→ q0AA
q0Ab
−→ q0BA
q0Ba
−→ q0AB
q0Bb
−→ q0BB
q0Ac
−→ q1A
q0Bc
−→ q1B
q1Aa
−→ q1
q1Bb
−→ q1
q0Ad
−→ q2
q0Bd
−→ q2
q2Aε
−→ q2
q2Bε
−→ q2
Q = {q0, q1, q2}, A = {a, b, c , d}, V = {Z0, A, B}
q0Z0
⊥
q0A
⊥
a
q0B
A
⊥
b
q1B
A
⊥
c
C0a
−→ C1b
−→ C2c
−→ C3
C0 = q0Z0⊥,C1 = q0A⊥,
C2 = q0BA⊥,C3 = q1BA⊥
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 3 / 31
Example of a DPDA M
q0Z0a
−→ q0A
q0Z0b
−→ q0B
q0Aa
−→ q0AA
q0Ab
−→ q0BA
q0Ba
−→ q0AB
q0Bb
−→ q0BB
q0Ac
−→ q1A
q0Bc
−→ q1B
q1Aa
−→ q1
q1Bb
−→ q1
q0Ad
−→ q2
q0Bd
−→ q2
q2Aε
−→ q2
q2Bε
−→ q2
Q = {q0, q1, q2}, A = {a, b, c , d}, V = {Z0, A, B}
q0Z0
⊥
q1B
A
⊥
abcq1A
⊥
b
q1⊥
a
L(M) = L(C0) where C0 = q0Z0⊥, i.e.
{w ∈ A∗ | q0Z0⊥w
−→ q⊥ for some q}
(M accepts by the empty stack)We have shown abcba ∈ L(M).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 4 / 31
Example of a DPDA M
q0Z0a
−→ q0A
q0Z0b
−→ q0B
q0Aa
−→ q0AA
q0Ab
−→ q0BA
q0Ba
−→ q0AB
q0Bb
−→ q0BB
q0Ac
−→ q1A
q0Bc
−→ q1B
q1Aa
−→ q1
q1Bb
−→ q1
q0Ad
−→ q2
q0Bd
−→ q2
q2Aε
−→ q2
q2Bε
−→ q2
Q = {q0, q1, q2}, A = {a, b, c , d}, V = {Z0, A, B}
q0Z0
⊥
q0B
A
⊥
abq2A
⊥
d
q2⊥
ε
So q0Z0⊥abd−→ q2⊥, which means abd ∈ L(M).
(We could find out that L(M) ={wcwR | w ∈ {a, b}+} ∪ {wd | w ∈ {a, b}+})
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 5 / 31
Problem DPDA-Lang-Eq
Instance : Q, A, V, a finite set ∆ of rules pXa
−→ qα where a ∈ A∪ {ε},p.q ∈ Q, X ∈ V, α ∈ V∗, satisfying the determinism conditions:
if pXa
−→ qα and pXa
−→ q′α′ are in ∆ then qα = q′α′;
if pXε
−→..,i.e., if pX is unstable, then ∀a ∈ A : pX 6a
−→,
and two configurations, say C0 = q0Z0⊥, C′0 = q′
0Z′0⊥.
Question : Is L(C0) = L(C′0) ?
——————————————————————————————–
Note:
Disjoint union of two DPDAs is a DPDA.
L1 = L2 iff L1 · {$} = L2 · {$} for a fresh endmarker $.(Thus restricting to prefix-free DCFL [recognized by the empty stack]does not mean losing generality.)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 6 / 31
Normalized dpda
pX
α
⊥
We say that a dpda M is normalized if
all ε-moves are popping, i.e., of the type pXε
−→ r ,
pXa
−→ r or pXa
−→ rZα for a stable rZ (a ∈ A)
each stable pX (other than p⊥) has a rulepX
a−→ . . . for each a ∈ A.
Proposition. Each dpda M can be transformed (by a quick algorithm) to anormalized dpda M ′ so that each configuration C of M is (easily) mappedto C′ of M ′ such that L(C) = L(C′).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 7 / 31
Configurations as trees
Configuration C has a corresponding c-tree TC ;
we assume Q = {q1, q2, q3}, a rule q3Aε
−→ q2, and q1B, q1A, q2A arestable.
q1B
A
⊥ q1⊥ q2⊥ q3⊥ q1⊥ q2⊥ q3⊥
q1A q2A q2⊥
q1Bq1
q2q3
A c-tree is a [finite or infinite] ordered |Q|-branching tree, with the innernodes labelled from Vnew = {qX | qX is stable}, and the leaves from{⊥, ℓ1, ℓ2, . . . }.
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 8 / 31
Transitions T1a
−→ T2
A rule pXa
−→ qα (e.g., pXa
−→ q1BA), for a stable pX , can be presentedas TpX
a−→ Tqα
ℓ1 ℓ2 ℓ3
pX a−→
ℓ1 ℓ2 ℓ3 ℓ1 ℓ2 ℓ3
q1A q2A ℓ2
q1B
and it entails that for all T1, . . . ,Tb, where b = |Q|, we have
TpX (T1, . . . ,Tb)a
−→ Tqα(T1, . . . ,Tb)
TpX
T1 . . .Tba
−→Tqα
T1 . . .Tb
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 9 / 31
Stratified equivalence (induced by words upto a given length)
Given a normalized dpda M = (Q,A,V, ∆),and c-trees T1, T2, we put
T1 ∼m T2 (m ∈ N)
iff T1w
−→ ⇔ T2w−→ for all w ∈ A∗, |w | ≤ m
(Thus T1 6∼m T2 iff T1u
−→ ⊥, T2u
−→ T 6= ⊥, or vice versa,for some u, |u| < m . )
Note:
L(T1) = L(T2) iff ∀m : T1 ∼m T2, denoted T1 ∼ T2.
(Relations ∼m and ∼ are equivalences.)
We define eq-lev(T1, T2) as the maximal m such that T1 ∼m T2;
for T1 ∼ T2 we put eq-lev(T1, T2) = ω.Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 10 / 31
A first idea to try to decide if T0 ∼ T ′0 (for A = {a, b})
Breadth-first construction of TreeA∗ = {ε, a, b, aa, ab, ba, bb, aaa, . . . }where lab(ε) = (T0, T
′0) and (only) the following instruction is used:
Basic labelling instruction:
if lab(u) = (T1, T2) then lab(ua) = (T ′1, T
′2) where T1
a−→ T ′
1, T2a
−→ T ′2.
T0, T′0
Ta, T′a Tb, T
′b
Taa, T′aa Tab, T
′ab Tba, T
′ba Tbb, T
′bb
a b
a b a b
a b a b a b a b
If lab(u) = (⊥,⊥), the branch u is terminated succesfully.If lab(u) = (⊥, T ) or lab(u) = (T ,⊥) for T 6= ⊥, algorithm returns NO.
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 11 / 31
Semidecidability of the negative case T0 6∼ T ′0
If T0 6∼ T ′0 then there is a word w = a1a2 . . . am such that
TreeA∗
(T0, T′0)
w
(⊥, T ′w )
w is anoffending branch :eq-lev decreasesat each step on w
eq-lev(T0, T′0)
eq-lev(Ta1 , T′a1
)eq-lev(Ta1a2 , T
′a1a2
)· · ·eq-lev(Ta1a2...am , T ′
a1a2...am−1)
eq-lev(Ta1a2...am , T ′a1a2...am
)
= m
= m−1= m−2· · ·= 1= 0
∼m
∼m−1
∼m−2
· · ·∼1
∼0
6∼m+1
6∼m
6∼m−1
· · ·6∼2
6∼1
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 12 / 31
Positive case T0 ∼ T ′0 needs a sound branch termination
In the positive case T0 ∼ T ′0, our construction of TreeA∗ labels
all nodes w by pairs of equivalent trees (Tw ∼ T ′w ), and can go forever.
Butwe can terminate branch u whenever we find (somehow effectively)that u is not (a prefix of) an offending branch.E.g.:
u is labelled by (T , T ) (the pair (⊥,⊥) is a special case)a pair appears on branch u for the second time.
(E , F )
(E , F )
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 13 / 31
Two steps to get the decidability of T0 ∼ T ′0
A safe (modification of the basic) labelling of TreeA∗ :
we keep equivalence in the positive case (when T0 ∼ T ′0):
if lab(w) = (T , T ′) then T ∼ T ′;
we do not ‘correct’ an offending branch (when T0 6∼ T ′0):
each (originally) offending w remains offending(eq-lev can even decrease by more than 1 in a step)
A sound and complete (and effective) branch termination condition:
each terminated branch w is guaranteed to be not offending(eq-lev does not decrease in some step).
termination of any branch will be guaranteed (when T0 ∼ T ′0).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 14 / 31
A safe relabelling option (a subtree replacement)
TreeA∗
C B
T1
T
T ′
v
C B
T2
T
T ′
v
C
T1
u
B
T2
u
|u| < |v |
eq-lev(T1, T2) ≥ eq-lev(C , B) − |u|)(congruence:) T1 ∼k T2 implies T (T1) ∼k T (T2).T1 ∼k T2 and eq-lev(T (T1), T
′) < k
implies eq-lev(T (T1), T′) = eq-lev(T (T2), T
′).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 15 / 31
An (infinite) sequence of substitutions
Given tree D = D(ℓ1, ℓ2, . . . , ℓn), where D 6= ℓn, by
Dn-lim = Dn-lim(ℓ1, ℓ2, . . . , ℓn−1)
we mean D(ℓ1, ℓ2, . . . , ℓn−1, D(ℓ1, ℓ2, . . . , ℓn−1, D(ℓ1, ℓ2, . . . , ℓn−1, . . . )))
D
ℓ1. . . ℓn−1
D
ℓ1. . . ℓn−1
D
ℓ1. . . ℓn−1 ·
··Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 16 / 31
A useful solution of a recursive equation
Tn ∼k
D
T1 . . . Tn−1 Tnimplies Tn ∼k
Dn-lim
T1 . . . Tn−1
IfE
T1 . . .Tn ∼m
F
T1 . . .Tn andE
T ′1 . . .T ′
n 6∼m
F
T ′1 . . .T ′
n
then for some j , 1 ≤ j ≤ n, some k ≤ m and some D 6= ℓj , not dependingon T1, . . . ,Tn, we have
Tj ∼k
D
T1 . . .Tn and T ′j 6∼k
D
T ′1 . . .T ′
n
By reordering Q we achieve j = n and thus Tn ∼k
Dn-lim
T1 . . . Tn−1
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 17 / 31
Aim of balancing (to terminate each branch of TreeA∗)
E0
G1 . . .Gn
F0
G1 . . .Gn
. . .
E1
e11 . . . e1
n
G1 . . .Gn
F1
e11 . . . e1
n
G1 . . .Gn
. . .
. . .
Er+1
er+11 . . . er+1
n
. . .
e21 . . . e2
n
e11 . . . e1
n
G1 . . .Gn
Fr+1
er+11 . . . er+1
n
. . .
e21 . . . e2
n
e11 . . . e1
n
G1 . . .Gn
Branch-termination rule:if the pairs of heads are thesame (E0 = E1 = . . .Er+1,F0 = F1 = . . .Fr+1) and theword er+1er . . . e1 of extensionsis of type n then terminate thebranch.(for n = 0 it is just a repeat)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 18 / 31
Soundness for n = 1 (1 tail, 4 pairs)
E
G1
F
G1 ,
E
e11
G1
F
e11
G1 ,
E
e21
e11
G1
F
e21
e11
G1 ,
E
e11
e21
e11
G1
F
e11
e21
e11
G1
If pair0, pair1, pair2 are in ∼m while pair3 is in 6∼m then
G1
D
G1 ,e11
G1
D
e11
G1 ,
e21
e11
G1
D
e21
e11
G1 ,
e11
e21
e11
G1
D
e11
e21
e11
G1
pair ′0, pair ′1, pair ′2 are in ∼k while pair ′3 is in 6∼k . Thus
e11 ∼k
D
e11 and e1
1 6∼k
D
e11
where e11 = e1
1(Dn-lim) – a contradiction (reduced to n = 0).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 19 / 31
n = 2 (2 tails, 8 pairs)
E
G1G2
F
G1G2 ,. . . ,
E
e11e1
2
e21e2
2
e11e1
2
G1G2
F
e11e1
2
e21e2
2
e11e1
2
G1G2 ,. . . ,
E
e11e1
2
e21e2
2
e11e1
2
e31e3
2
e11e1
2
e21e2
2
e11e1
2
G1G2
F
e11e1
2
e21e2
2
e11e1
2
e31e3
2
e11e1
2
e21e2
2
e11e1
2
G1G2
Using G2 ∼k Dn-lim(G1), denoting e ij = e i
j (ℓ1, Dn-lim(ℓ1)), etc., we reduce:
e12
G1
D
e11 e1
2G1 ,
e12
e21
G1
D
e11 e1
2e21
G1 ,
e12
e31
e21
G1
D
e11 e1
2e31
e21
G1 ,
e12
e21
e31
e21
G1
D
e11 e1
2e21
e31
e21
G1
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 20 / 31
Patterns for extensions
E
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e31e3
2e33e3
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e41e4
2e43e4
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e31e3
2e33e3
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
G1G2G3G4
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 21 / 31
Patterns for extensions - shrinking
E
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e31e3
2e33e3
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e41e4
2e43e4
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
e31e3
2e33e3
4
e11e1
2e13e1
4
e21e2
2e23e2
4
e11e1
2e13e1
4
G1G2G3G4
E
e11 e1
2 e13
e21 e2
2 e32
e11 e1
2 e13
e31 e3
2 e33
e11 e1
2 e13
e21 e2
2 e32
e11 e1
2 e13
G1G2G3
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 22 / 31
Word patterns
Given a (maybe infinite) alphabet Σ, we say that a word w ∈ Σ∗ is
of type 0 if |w | ≥ 1,
of type n + 1 if w = vuv for some v of type n and some u, |u| ≥ 1.
Proposition. For a finite Σ, |Σ| = h,every word w ∈ Σ∗ with |w | ≥ fh(n) contains a subword of type n.
It suffices if in the word of length fh(n + 1) we surely findtwo equal separated subwords of length fh(n):
· · · · · · · · · · · · · · · · · · · · ·
Given h ∈ N, we define
fh(0) = 1, fh(n + 1) = (1 + fh(n)) · hfh(n) (fh(n) ≤ cc·· n-tower)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 23 / 31
Successive bounded extensions guarantee termination
E0
G1 . . .Gn
F0
G1 . . .Gn
. . .
E1
e11 . . . e1
n
G1 . . .Gn
F1
e11 . . . e1
n
G1 . . .Gn
. . .
. . .
Er+1
er+11 . . . er+1
n
. . .
e21 . . . e2
n
e11 . . . e1
n
G1 . . .Gn
Fr+1
er+11 . . . er+1
n
. . .
e21 . . . e2
n
e11 . . . e1
n
G1 . . .Gn
It is sufficient that(r is large enough and)the word
E1
e11 . . . e1
n
F1
e11 . . . e1
n
E2
e21 . . . e2
n
F2
e21 . . . e2
n
E3
e31 . . . e3
n
F3
e31 . . . e3
n
. . .
is from a fixed alphabet.
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 24 / 31
Recall the safe relabelling option (a subtree replacement)
TreeA∗
C B
T1
T
T ′
v
C B
T2
T
T ′
v
C
T1
u
B
T2
u
|u| < |v |
eq-lev(T1, T2) ≥ eq-lev(C , B) − |u|)(congruence:) T1 ∼k T2 implies T (T1) ∼k T (T2).T1 ∼k T2 and eq-lev(T (T1), T
′) < k
implies eq-lev(T (T1), T′) = eq-lev(T (T2), T
′).
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 25 / 31
d -prefix form of a tree (with prefix Pd of depth d)
The (d + 1)-th node of each branch (if the branch is not shorter)is replaced by a variable-leaf ...
Pd
T1 T2. . . Tn
d levels
at most bd var-leaves(b ... branching degree)
IfPd
T1 · · ·Tn
u−→ T
where |u| < d
then T =E
T1 · · ·Tn where 1 ≤ height(E ) < 2d
(Assuming (wlog) that the tree-height can only increase by 1 in a step)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 26 / 31
Words w(X , j), number M
Given the set of rules TX (ℓ1, . . . , ℓb)a
−→ T (ℓ1, . . . , ℓb),we can attach to each X ∈ Vnew = {qY | qY is stable}and each j , 1 ≤ j ≤ b
a shortest word w(X , j) such that
X
ℓ1 . . . ℓbw(X ,j)−→ ℓj
if there is one.
Let
M = 1 + max{ length(w(X , j)) | X ∈ V, 1 ≤ j ≤ b }
(M is (can be) exponential in the size of the DPDA-Lang-Eq instance)
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 27 / 31
Balancing
TreeA∗
C B
T T ′
v
XT1 . . .Tb
PM
T ′1 . . .T ′
n
ET1 . . .Tb
FT ′
1 . . .T ′n
v
suppose the trees are in the depicted form,
Cv
−→ T avoiding T1 . . .Tb , and |v | = M .
Then replace each Tj by(
B =PM
T ′1 . . .T ′
n
w(X ,j)−→
)
Fj
T ′1 . . .T ′
n.
(or by B when there is no w(X , j)). We thus get:Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 28 / 31
Balancing
XT1 . . .Tb
PM
T ′1 . . .T ′
n
ET1 . . .Tb
FT ′
1 . . .T ′n
v
XT1 . . .Tb
PM
T ′1 . . .T ′
n=B
E
F1 . . .Fb
T ′1 . . .T ′
n
F
T ′1 . . .T ′
n
v
The height of E , F1, . . . ,Fb, F is bounded (by 2M).
Balancing strategy: do rhs or lhs balancing when possible but you canswitch the sides only if some Fj(T
′1 . . .T ′
n) has been ‘exposed’.Note: ‘shortly’ after a balancing step
a new balancing happens or both-side pivots are allowed.Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 29 / 31
Balancing pivots from an (infinite) branch are on a ‘path’
B1u1−→ B2
u2−→ B3u3−→ · · ·
Let D1 =X1
T1 . . .Tb =
X1
P11M . . .P1b
M
G1 . . .Gn
be the subtree of B1 which is used in B1u1u2u3...−→ but its proper subtrees are
avoided (it is possible that D1 = B1).
We take Bi1 as the first pivot behind D1, so Bi1 =
H1
P11M . . .P1b
M
G1 . . .Gn ;
height(H1) is bounded (by M3).Let D2 be the (first) subtree of Bi1 which
is used by Bi1
ui1ui1+1ui1+2−→ . . . but its proper
subtrees are avoided. We take Bi2 as thefirst pivot behind D2, etc. D2 =
X2
P21M . . .P2b
M
e11 . . . e1
n
G1 . . .Gn
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 30 / 31
Successive bounded extensions
The pairs resulting from balancing with
Bi1 =
H1
P11M . . .P1b
M
G1 . . .Gn , Bi2 =
H2
P21M . . .P2b
M
e11 . . . e1
n
G1 . . .Gn , Bi3 =
H3
P31M . . .P3b
M
e21 . . . e2
n
e11 . . . e1
n
G1 . . .Gn , . . .
create the required sequence of ‘boundedly extended pairs’
E0
G1 . . .Gn
F0
G1 . . .Gn ,
E1
e11 . . . e1
n
G1 . . .Gn
F1
e11 . . . e1
n
G1 . . .Gn ,. . .
Petr Jancar (TU Ostrava) DPDA - decidability ABCDays’09, March 2009 31 / 31