Introduction
Deciding Kleene Algebra with converse
is PSpace-complete
Talk at the PACE meeting
Paul Brunet & Damien Pous
ENS de Lyon
February 9th , 2014
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
1 / 23
Introduction
Introduction
Kleene Algebra (i) : Abstraction for proving the equivalence of regular expressions.
(i). Conway, J. H. (1971). Regular algebra and finite machines.
Chapman and Hall Mathematics Series
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
2 / 23
Introduction
Introduction
Kleene Algebra (i) : Abstraction for proving the equivalence of regular expressions.
The equivalence is PSpace-complete.
(i). Conway, J. H. (1971). Regular algebra and finite machines.
Chapman and Hall Mathematics Series
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
2 / 23
Introduction
Introduction
Kleene Algebra (i) : Abstraction for proving the equivalence of regular expressions.
The equivalence is PSpace-complete.
What if we add a converse operation to regular expressions ?
(i). Conway, J. H. (1971). Regular algebra and finite machines.
Chapman and Hall Mathematics Series
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
2 / 23
Introduction
Introduction
e, f ∈ RegX
KA ⊢ e = f
e ≡Rel f
~e = ~f
e, f ∈ RegX ∨
KAC ⊢ e = f
e ≡Rel∨ f
cl (~e) = cl (~f)
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
3 / 23
Introduction
Introduction
e, f ∈ RegX
KA ⊢ e = f
e ≡Rel f
~e = ~f
e, f ∈ RegX ∨
KAC ⊢ e = f
e ≡Rel∨ f
cl (~e) = cl (~f)
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
3 / 23
Introduction
Introduction
e, f ∈ RegX
KA ⊢ e = f
e ≡Rel f
~e = ~f
e, f ∈ RegX ∨
KAC ⊢ e = f
e ≡Rel∨ f
cl (~e) = cl (~f)
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
3 / 23
Introduction
Introduction
e, f ∈ RegX
KA ⊢ e = f
e ≡Rel f
~e = ~f
e, f ∈ RegX ∨
KAC ⊢ e = f
e ≡Rel∨ f
cl (~e) = cl (~f)
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
3 / 23
Introduction
Introduction
e, f ∈ RegX
KA ⊢ e = f
e ≡Rel f
~e = ~f
e, f ∈ RegX ∨
KAC ⊢ e = f
e ≡Rel∨ f
cl (~e) = cl (~f)
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
3 / 23
Introduction
Plan
1
Introduction
2
From Kleene Algebra with Converse to regular languages
Kleene Algebra wih converse
Reduction to an automaton problem
3
Closure of an automaton
4
The PSpace algorithm.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
4 / 23
KAC
Plan
1
Introduction
2
From Kleene Algebra with Converse to regular languages
Kleene Algebra wih converse
Reduction to an automaton problem
3
Closure of an automaton
4
The PSpace algorithm.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
5 / 23
KAC
Kleene Algebra wih converse
Regular expressions with converse
Regular expressions with converse over X
Let X be a finite set, the set of regular expressions over X (written RegX ∨ ) are
obtained with the grammar :
e, f F 0|1|x ∈ X |e + f |e · f |e ∗ |e ∨
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
6 / 23
KAC
Kleene Algebra wih converse
Regular expressions with converse
Regular expressions with converse over X
Let X be a finite set, the set of regular expressions over X (written RegX ∨ ) are
obtained with the grammar :
e, f F 0|1|x ∈ X |e + f |e · f |e ∗ |e ∨
A relational interpretation of regular expressions with converse over X can be
specified by a domain S and a map
σ : X −→ P S 2
We will write
σ̂ : RegX ∨ −→ P S 2
for the unique morphism equal to σ on X .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
6 / 23
KAC
Kleene Algebra wih converse
Relational equivalence
For e, f ∈ RegX ∨ :
e ≡Rel∨ f
means that
∀S, ∀σ : X → P S 2 , σ̂(e) = σ̂(f ).
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
7 / 23
KAC
Kleene Algebra wih converse
A hint from the equational theory.
∨
(a + b) = a∨ + b ∨
∨
∨
(a · b) = b · a
∗ ∨
(1)
∨
(2)
∨ ∗
(3)
(a ) = (a )
a
∨∨
(4)
=a
a 6 aa∨ a
Paul Brunet (ENS de Lyon)
KAC is PSpace
(5)
February 9th , 2014
8 / 23
KAC
Kleene Algebra wih converse
A hint from the equational theory.
∨
(a + b) = a∨ + b ∨
∨
∨
(a · b) = b · a
∗ ∨
(1)
∨
(2)
∨ ∗
(3)
(a ) = (a )
a
∨∨
(4)
=a
a 6 aa∨ a
Paul Brunet (ENS de Lyon)
KAC is PSpace
(5)
February 9th , 2014
8 / 23
KAC
Reduction
From RegX ∨ to RegX
Let X be a finite alphabet. For e ∈ RegX , we write ~e ⊆ X ∗ for the language
denoted by e.
X ′ ≔ {x ′ | x ∈ X } is a disjoint copy of X ,
and X ≔ X ∪ X ′ .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
9 / 23
KAC
Reduction
From RegX ∨ to RegX
Let X be a finite alphabet. For e ∈ RegX , we write ~e ⊆ X ∗ for the language
denoted by e.
X ′ ≔ {x ′ | x ∈ X } is a disjoint copy of X ,
and X ≔ X ∪ X ′ .
1
We see equations (1)-(4) as rewriting rules :
∨
(a + b)
∨
(a · b)
∗ ∨
(a )
∨
a∨
∨
1
0∨
Paul Brunet (ENS de Lyon)
7 →a∨ + b ∨
−
7−→b ∨ · a∨
7−→(a∨ )∗
7−→a
7−→1
7−→0
KAC is PSpace
February 9th , 2014
9 / 23
KAC
Reduction
From RegX ∨ to RegX
Let X be a finite alphabet. For e ∈ RegX , we write ~e ⊆ X ∗ for the language
denoted by e.
X ′ ≔ {x ′ | x ∈ X } is a disjoint copy of X ,
and X ≔ X ∪ X ′ .
1
We see equations (1)-(4) as rewriting rules :
∨
(a + b)
∨
(a · b)
∗ ∨
(a )
∨
a∨
∨
1
0∨
2
7 →a∨ + b ∨
−
7−→b ∨ · a∨
7−→(a∨ )∗
7−→a
7−→1
7−→0
We substitute x ∨ with x ′ in the result. We get e ∈ RegX .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
9 / 23
KAC
Reduction
Reduction relation
a 6 aa∨ a
w
For a word w ∈ X∗ , we define inductively w :
∀x ∈ X ,
∀x ′ ∈ X ′ ,
Paul Brunet (ENS de Lyon)
x ≔ x′
x′ ≔ x
KAC is PSpace
ǫ≔ǫ
wx ≔ x w
February 9th , 2014
10 / 23
KAC
Reduction
Reduction relation
a 6 aa∨ a
w
For a word w ∈ X∗ , we define inductively w :
∀x ∈ X ,
∀x ′ ∈ X ′ ,
u
x ≔ x′
x′ ≔ x
ǫ≔ǫ
wx ≔ x w
v
u1 · w w w · u2
u1 · w · u2
Example :
abbabb ′ a′ abbaa′
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
10 / 23
KAC
Reduction
Reduction relation
a 6 aa∨ a
w
For a word w ∈ X∗ , we define inductively w :
∀x ∈ X ,
∀x ′ ∈ X ′ ,
u
x ≔ x′
x′ ≔ x
ǫ≔ǫ
wx ≔ x w
v
u1 · w w w · u2
u1 · w · u2
Example :
abbabb ′ a′ abbaa′ = abb · ab · b ′ a′ · ab · baa′
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
10 / 23
KAC
Reduction
Reduction relation
a 6 aa∨ a
w
For a word w ∈ X∗ , we define inductively w :
∀x ∈ X ,
∀x ′ ∈ X ′ ,
u
x ≔ x′
x′ ≔ x
ǫ≔ǫ
wx ≔ x w
v
u1 · w w w · u2
u1 · w · u2
Example :
abbabb ′ a′ abbaa′ = abb · ab · b ′ a′ · ab · baa′ = abb · ab · ab · ab · baa′
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
10 / 23
KAC
Reduction
Reduction relation
a 6 aa∨ a
w
For a word w ∈ X∗ , we define inductively w :
∀x ∈ X ,
∀x ′ ∈ X ′ ,
u
x ≔ x′
x′ ≔ x
ǫ≔ǫ
wx ≔ x w
v
u1 · w w w · u2
u1 · w · u2
Example :
abbabb ′ a′ abbaa′ = abb · ab · b ′ a′ · ab · baa′ = abb · ab · ab · ab · baa′
Paul Brunet (ENS de Lyon)
KAC is PSpace
abb · ab · baa′
February 9th , 2014
10 / 23
KAC
Reduction
Closure
cl (L)
cl (L) ≔ {v | ∃u ∈ L : u
Paul Brunet (ENS de Lyon)
KAC is PSpace
∗
v}
February 9th , 2014
11 / 23
KAC
Reduction
Closure
cl (L)
cl (L) ≔ {v | ∃u ∈ L : u
∗
v}
Theorem a
a. Bloom, S. L., Ésik, Z., and Stefanescu, G. (1995). Notes on equational theories
of relations.
Algebra Universalis, 33(1) :98–126
e ≡Rel∨ f
Paul Brunet (ENS de Lyon)
⇔
cl (~e) = cl (~f)
KAC is PSpace
February 9th , 2014
11 / 23
Construction
Plan
1
Introduction
2
From Kleene Algebra with Converse to regular languages
Kleene Algebra wih converse
Reduction to an automaton problem
3
Closure of an automaton
4
The PSpace algorithm.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
12 / 23
Construction
Problem
Input : an automaton A
Output : an automaton A ′ such that L(A ′ ) = cl (L(A )).
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
13 / 23
Construction
Intuition
0
a
1
a′
Paul Brunet (ENS de Lyon)
2
a
3
KAC is PSpace
February 9th , 2014
14 / 23
Construction
Intuition
a
0
a
1
a′
Paul Brunet (ENS de Lyon)
2
a
3
KAC is PSpace
February 9th , 2014
14 / 23
Construction
Intuition
a
0
a
1
0
a
1
a′
b
Paul Brunet (ENS de Lyon)
2
2
a
b′
3
3
a′
4
a
KAC is PSpace
5
b
6
February 9th , 2014
14 / 23
Construction
Intuition
a
0
a
1
a′
2
a
3
b
0
a
1
b
Paul Brunet (ENS de Lyon)
2
b′
3
a′
4
a
KAC is PSpace
5
b
6
February 9th , 2014
14 / 23
Construction
Intuition
a
0
a
1
a′
2
a
3
b
0
a
1
b
2
b′
3
a′
4
a
5
b
6
b
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
14 / 23
Construction
Intuition
a
0
a′
a
1
a
1
b
2
b
1
b
2
2
0
Paul Brunet (ENS de Lyon)
a
b′
b′
3
b
3
3
a′
a′
4
a
5
b
6
4
a
5
a
6
KAC is PSpace
February 9th , 2014
14 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
15 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
We give an alternative construction, much lighter. The states of our
automaton will be pairs of
◮
◮
a state of the initial automaton
and some history.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
15 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
We give an alternative construction, much lighter. The states of our
automaton will be pairs of
◮
◮
a state of the initial automaton
and some history.
u
x
w
If : q0 −−→ q1 −−→ q3 −−→ q2
With : ∃u2 ∈ suffixes(ux ) : w
Paul Brunet (ENS de Lyon)
KAC is PSpace
∗
u 2 u2
February 9th , 2014
15 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
We give an alternative construction, much lighter. The states of our
automaton will be pairs of
◮
◮
a state of the initial automaton
and some history.
u
x
w
If : q0 −−→ q1 −−→ q3 −−→ q2
With : ∃u2 ∈ suffixes(ux ) : w
Meaning : uxw
Paul Brunet (ENS de Lyon)
∗
ux u 2 u2 = u1 u2 u 2 u2
KAC is PSpace
∗
u 2 u2
u1 u2 = ux
February 9th , 2014
15 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
We give an alternative construction, much lighter. The states of our
automaton will be pairs of
◮
◮
a state of the initial automaton
and some history.
u
x
w
If : q0 −−→ q1 −−→ q3 −−→ q2
With : ∃u2 ∈ suffixes(ux ) : w
Meaning : uxw
∗
ux u 2 u2 = u1 u2 u 2 u2
u
∗
u 2 u2
u1 u2 = ux
x
Then : (q0 , γ(ǫ)) −
→ (q1 , γ(u)) −
→ (q2 , γ(ux ))
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
15 / 23
Construction
General idea
Bloom, Ésik and Stefanescu give a construction, using the transitions monoid
n2
of the initial automaton, building a deterministic automaton with size 22 (if
the initial automaton has size n).
We give an alternative construction, much lighter. The states of our
automaton will be pairs of
◮
◮
a state of the initial automaton
and some history.
u
x
w
If : q0 −−→ q1 −−→ q3 −−→ q2
With : ∃u2 ∈ suffixes(ux ) : w
Meaning : uxw
∗
ux u 2 u2 = u1 u2 u 2 u2
u
∗
u 2 u2
u1 u2 = ux
x
Then : (q0 , γ(ǫ)) −
→ (q1 , γ(u)) −
→ (q2 , γ(ux ))
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
15 / 23
Construction
Γ(w )
Definition : Γ(w )
Γ(ǫ) = {ǫ}
Γ(wx ) = ({x ′ } · Γ(w ) · {x })
∗
Lemma
u ∈ Γ(w ) ⇔ ∃v ∈ suffixes(w ) : u
∗
vv
Γ(xn · · · x1 ) is recognised by the automaton :
0
Paul Brunet (ENS de Lyon)
x1′
x1
1
x2′
x2
KAC is PSpace
2
x3′
x3
xn′
xn
n
February 9th , 2014
16 / 23
Construction
γ(w )
Consider an automaton A = hQ, A, I, T , ∆i, we write
x
∆x ≔ {(p, q) | p −
→ q ∈ ∆}.
Definition : γ(w )
γ(ǫ) = IdQ
γ(wx ) = (∆x ′ · γ(w ) · ∆x )
∗
Lemma
u
(p, q) ∈ γ(w ) ⇔ ∃u ∈ Γ(w ) : p −
→q
u
⇔ ∃u : ∃v ∈ suffixes(w ) : p −
→q∧u
∗
vv
Histories
The set of histories is G ≔ r ∈ P Q 2 | ∃w ∈ X∗ : r = γ(w ) .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
17 / 23
Construction
Closure Automaton
cl (A )
cl (A ) ≔ hQ × G, X, I × γ(ǫ), F × G, ∆′ i with transitions ∆′ :
x
(q1 , γ(w )) −−→cl (A ) (q2 , γ(wx )) if (q1 , q2 ) ∈ ∆x ◦ γ(wx )
Theorem
L (cl (A )) = cl (L(A ))
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
18 / 23
Construction
Closure Automaton
cl (A )
cl (A ) ≔ hQ × G, X, I × γ(ǫ), F × G, ∆′ i with transitions ∆′ :
x
(q1 , γ(w )) −−→cl (A ) (q2 , γ(wx )) if (q1 , q2 ) ∈ ∆x ◦ γ(wx )
Theorem
L (cl (A )) = cl (L(A ))
x
(p, γ(u)) −−→ (q, γ(ux )) ,
Paul Brunet (ENS de Lyon)
∃r ∈ Q
∃w ∈ Γ(ux )
KAC is PSpace
x
w
: p −−→ r −−→ q
February 9th , 2014
18 / 23
Construction
Closure Automaton
cl (A )
cl (A ) ≔ hQ × G, X, I × γ(ǫ), F × G, ∆′ i with transitions ∆′ :
x
(q1 , γ(w )) −−→cl (A ) (q2 , γ(wx )) if (q1 , q2 ) ∈ ∆x ◦ γ(wx )
Theorem
L (cl (A )) = cl (L(A ))
∃r ∈ Q
x
(p, γ(u)) −−→ (q, γ(ux )) , ∃v ∈ suffixes(ux )
∃w ∗ v v
Paul Brunet (ENS de Lyon)
KAC is PSpace
x
w
: p −−→ r −−→ q
February 9th , 2014
18 / 23
Construction
Size
∆′ : {((q1 , γ(w )) , x , (q2 , γ(wx ))) | (q1 , q2 ) ∈ ∆x ◦ γ(wx ) }
We can see that this construction produces a non-deterministic automaton of size
at most n × 2n×(n−1) .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
19 / 23
Construction
Size
∆′ : {((q1 , γ(w )) , x , (q2 , γ(wx ))) | (q1 , q2 ) ∈ ∆x ◦ γ(wx ) }
We can see that this construction produces a non-deterministic automaton of size
at most n × 2n×(n−1) .
Futhurmore, it can be easily determinized :
δ ′ : ((Q1 , γ(w )), x ) 7→ (Q1 · (∆x ◦ γ(wx )) , γ(wx ))
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
19 / 23
Construction
Size
∆′ : {((q1 , γ(w )) , x , (q2 , γ(wx ))) | (q1 , q2 ) ∈ ∆x ◦ γ(wx ) }
We can see that this construction produces a non-deterministic automaton of size
at most n × 2n×(n−1) .
Futhurmore, it can be easily determinized :
δ ′ : ((Q1 , γ(w )), x ) 7→ (Q1 · (∆x ◦ γ(wx )) , γ(wx ))
2
This deterministic automaton has at most 2n × 2n×(n−1) = 2n states, which is
n2
significantely smaller than 22 , the size of the automaton from the original
construction.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
19 / 23
PSpace algorithm
Plan
1
Introduction
2
From Kleene Algebra with Converse to regular languages
Kleene Algebra wih converse
Reduction to an automaton problem
3
Closure of an automaton
4
The PSpace algorithm.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
20 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
Automaton equivalence
Let A and B be two deterministic automata over some alphabet Σ.
Theorem
L(A ) , L(B) ⇔ ∃w ∈ (L(A ) \ L(B)) ∪ (L(B) \ L(A )) : |w | 6 |A | × |B|.
input : A1 = hQ1 , Σ, i1 , T1 , δ1 i
input : A2 = hQ2 , Σ, i2 , T2 , δ2 i
output: A Boolean, saying whether or not A1 and A2 recognise the same language.
1
2
3
4
5
6
7
8
9
10
11
12
N ← (|Q1 | × |Q2 |) ;
(p1 , p2 ) ← (i1 , i2 ) ;
while N > 0 do
N ← N − 1;
f1 ← is_in(p1 , T1 );
f2 ← is_in(p2 , T2 );
if f1 = f2 then
x ←random(Σ) ;
(p1 , p2 ) ← (δ1 (p1 , x ), δ2 (p2 , x )) ;
else
return false;
end
/* N bounds the recursion depth */
/* Non-deterministic choice */
/* A difference appeared for some word, L(A1 ) , L(A2 ) */
13
14
15
end
return true;
Paul Brunet (ENS de Lyon)
/* There was no difference, L(A1 ) = L(A2 ) */
KAC is PSpace
February 9th , 2014
21 / 23
PSpace algorithm
A PSpace algorithm for KAC
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
n2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
2 × m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
O n2 + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
Paul Brunet (ENS de Lyon)
KAC is PSpace
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
O n2 + m2
2
O n + m2
February 9th , 2014
22 / 23
PSpace algorithm
A PSpace algorithm for KAC
Let’s write n and m for the sizes of e and f .
input : Two regular expressions with converse e, f ∈ RegX ∨
output: A Boolean, saying whether or not KAC ⊢ e = f .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
A1 = hQ1 , X, I1 , T1 , ∆1 i ← Glushkov’ automaton recognising ~e ;
A2 = hQ2 , X, I2 , T2 , ∆2 i ← Glushkov’ automaton recognising ~f ;
2
2
N ← (2(|e|+1) × 2(|f |+1) ) ;
((P1 , R1 ), (P2 , R2 )) ← ((I1 , IdQ1 ), (I2 , IdQ1 )) ;
while N > 0 do
N ← N − 1;
f1 ← is_empty(P1 ∩ T1 );
f2 ← is_empty(P2 ∩ T2 );
if f1 = f2 then
x ←random(X);
(R1 , R2 ) ← ((∆1 (x ′ ) ◦ R1 ◦ ∆1 (x ))⋆ , (∆2 (x ′ ) ◦ R2 ◦ ∆2 (x ))⋆ ) ;
(P1 , P2 ) ← (P1 · (∆1 (x ) ◦ R1 ), P2 · (∆2 (x ) ◦ R2 )) ;
else
return false
end
end
return true
O (n + m)
2
2
∼ log 2n × 2m ∼ O n2 + m2
∼ log(n) + log(m) + n2 + m2 ∼ O n2 + m2
O (log(n))
O n2 + m2
2
O n + m2
So we get a space complexity O n2 + m2 .
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
22 / 23
PSpace algorithm
Plan
1
Introduction
2
From Kleene Algebra with Converse to regular languages
Kleene Algebra wih converse
Reduction to an automaton problem
3
Closure of an automaton
4
The PSpace algorithm.
Paul Brunet (ENS de Lyon)
KAC is PSpace
February 9th , 2014
23 / 23
© Copyright 2026 Paperzz