Coinductive Specification of k-Regular Sequences

advertisement
Coinductive Specification of k-Regular Sequences
Helle Hvid Hansen
Delft University of Technology
Scottish Theorem Proving Seminar
Dundee, 7 Oct 2015
Introduction
• Joint work with: Clemens Kupke, Jan Rutten, Joost Winter.
• About: k-regular sequences (Allouche-Shallit, 1992).
• Goal: Coalgebraic understanding of k-regular sequences.
I
Clear semantics (in terms of automata).
I
Coinductive specification format.
I
Relationship to other classes of streams
(rational, k-automatic).
• Main observation: Final k-Automaton of Streams.
Overview (UPDATE)
1. Streams and SDEs
2. Final k-automaton of streams.
3. Weighted automata and streams.
4. Characterisation of k-regular (and k-automatic) sequences
Streams
Let B be a set.
• Streams over B: B ω = {σ : N → B}.
• We write: σ = (σ(0), σ(1), σ(2), . . .)
• “head” or “initial value”: hd(σ) = σ(0),
• “tail” or “derivative”:
tl(σ) = σ 0 = (σ(1), σ(2), . . .),
A Simple Stream Specification Format
• A system of simple stream differential equations (simple SDE)
(B = {0, 1}), example:
x0 = y
y0 = x
z0 = y
x(0) = 1,
y (0) = 0,
z(0) = 1,
• Corresponds to automaton with output in B:
x|1 g
'
y |0
w
z|1
• Solution for x is the stream observed from x, etc.
x
y
z
= (1, 0, 1, 0, 1, 0, . . .)
= (0, 1, 0, 1, 0, 1, . . .)
= (1, 0, 1, 0, 1, 0, . . .)
The 1-Automaton of Streams
• A 1-automaton with output in B and state space X is a map
ho, di : X → B × X
1-automaton: hhd, tli : B ω → B × B ω
• Streams are a
∃![[−]]
X
∀ho,di
B ×X
idB ×[[−]]
concretely,
/ Bω
hhd,tli
/ B × Bω
∀x ∈ X :
∀x ∈ X :
[[x]](0) = o(x)
[[x]]0
= [[d(x)]]
[[x]](n) = o(d n (x)) ∀n ∈ N.
• The stream [[x]] is “defined by coinduction”.
The 1-Automaton of Streams
• A 1-automaton with output in B and state space X is a map
ho, di : X → B × X
• Streams are a final 1-automaton: hhd, tli : B ω → B × B ω
∃![[−]]
X
∀ho,di
B ×X
idB ×[[−]]
concretely,
/ Bω
hhd,tli
/ B × Bω
∀x ∈ X :
∀x ∈ X :
[[x]](0) = o(x)
[[x]]0
= [[d(x)]]
[[x]](n) = o(d n (x)) ∀n ∈ N.
• The stream [[x]] is “defined by coinduction”.
Characterisation of Eventually Periodic Streams
Theorem. TFAE
• A stream σ is the solution to a finite system of simple SDEs.
• σ is generated by a finite 1-automaton.
• σ ∈ B ω is eventually periodic.
Zip by Coinduction
• Zipping two streams together:
zip(σ, τ ) = (σ(0), τ (0), σ(1), τ (1), . . .).
• Define zip by an SDE:
zip(σ, τ )(0) = σ(0)
zip(σ, τ )0
= zip(τ, σ 0 )
• By coinduction:
(σ, τ )
_
(σ(0), (τ, σ 0 ))
∈
Bω × Bω
zip
/ Bω
hhd,tli
B × (B ω × B ω )
idB ×zip
/ B × Bω
Zip by Coinduction
• Zipping two streams together:
zip(σ, τ ) = (σ(0), τ (0), σ(1), τ (1), . . .).
• Define zip by an SDE:
zip(σ, τ )(0) = σ(0)
zip(σ, τ )0
= zip(τ, σ 0 )
• By coinduction:
(σ, τ )
_
(σ(0), (τ, σ 0 ))
∈
Bω × Bω
zip
/ Bω
hhd,tli
B × (B ω × B ω )
idB ×zip
/ B × Bω
k-Automata and Languages
• A k-automaton with output in B and state space X is a map:
X → B × XA
where the alphabet A is any set of cardinality k.
• B-valued languages over alphabet A:
L
:=
∗
B A = {L : A∗ → B}
• The (left-)derivative of language L wrt a ∈ A is La ∈ L
where
La (w ) = L(aw )
for all w ∈ A∗
k-Automata and Languages
• A k-automaton with output in B and state space X is a map:
X → B × XA
where the alphabet A is any set of cardinality k.
• B-valued languages over alphabet A:
L
:=
∗
B A = {L : A∗ → B}
• The (left-)derivative of language L wrt a ∈ A is La ∈ L
where
La (w ) = L(aw )
for all w ∈ A∗
The Final k-Automaton of Languages
• The k-automaton of languages
λ : L → B × LA
L 7→ hL(ε), a 7→ La i
. . . is final:
X
ho,di
B×
[[−]]
/L
idB ×[[−]]A
XA
λ
/ B × LA
∀x ∈ X , ∀a ∈ A :
[[x]](ε) = o(x)
[[x]]a
= [[d(x)(a)]]
where behaviour map is language semantics:
∀x ∈ X :
[[x]](w ) = o(d ∗ (x)(w )) ∀w ∈ A∗ .
The Final k-Automaton of Languages
• The k-automaton of languages
λ : L → B × LA
L 7→ hL(ε), a 7→ La i
. . . is final:
X
ho,di
B×
[[−]]
/L
idB ×[[−]]A
XA
λ
/ B × LA
∀x ∈ X , ∀a ∈ A :
[[x]](ε) = o(x)
[[x]]a
= [[d(x)(a)]]
where behaviour map is language semantics:
∀x ∈ X :
[[x]](w ) = o(d ∗ (x)(w )) ∀w ∈ A∗ .
Zipping and Unzipping k Streams
• Zipping k streams together:
zip k (σ0 , . . . , σk−1 )(i + nk) = σi (n)
∀n, i ∈ N, 0 ≤ i < k
or equivalently (by the stream differential equation):
zip k (σ0 , . . . , σk−1 )(0) = σ0 (0)
zip k (σ0 , . . . , σk−1 )0
= zip k (σ1 , . . . , σk−1 , σ00 ).
• Unzipping a stream into k streams: For k, j ∈ N with j < k:
unzip j,k (σ)(n) = σ(j + nk)
∀n ∈ N
• The k-kernel of σ ∈ B ω is the set of streams obtained by
closing {σ} under unzip j,k for all j < k.
Zipping and Unzipping k Streams
• Zipping k streams together:
zip k (σ0 , . . . , σk−1 )(i + nk) = σi (n)
∀n, i ∈ N, 0 ≤ i < k
or equivalently (by the stream differential equation):
zip k (σ0 , . . . , σk−1 )(0) = σ0 (0)
zip k (σ0 , . . . , σk−1 )0
= zip k (σ1 , . . . , σk−1 , σ00 ).
• Unzipping a stream into k streams: For k, j ∈ N with j < k:
unzip j,k (σ)(n) = σ(j + nk)
∀n ∈ N
• The k-kernel of σ ∈ B ω is the set of streams obtained by
closing {σ} under unzip j,k for all j < k.
Zipping and Unzipping k Streams
• Zipping k streams together:
zip k (σ0 , . . . , σk−1 )(i + nk) = σi (n)
∀n, i ∈ N, 0 ≤ i < k
or equivalently (by the stream differential equation):
zip k (σ0 , . . . , σk−1 )(0) = σ0 (0)
zip k (σ0 , . . . , σk−1 )0
= zip k (σ1 , . . . , σk−1 , σ00 ).
• Unzipping a stream into k streams: For k, j ∈ N with j < k:
unzip j,k (σ)(n) = σ(j + nk)
∀n ∈ N
• The k-kernel of σ ∈ B ω is the set of streams obtained by
closing {σ} under unzip j,k for all j < k.
Zip-Unzip Bijection
• Ex. unzip 0,2 (σ) = even(σ) = (σ(0), σ(2), σ(4), . . .)
unzip 1,2 (σ) = odd(σ) = (σ(1), σ(3), σ(5), . . .)
• We have:
zip 2 (even(σ), odd(σ)) = σ
even(zip 2 (σ, τ ))
odd(zip 2 (σ, τ ))
= σ
= τ
• In general,
zip k (unzip 0,k (σ), . . . , unzip k−1,k (σ)) = σ
unzip i,k (zip k (σ0 , . . . , σk−1 )) = σi
∀i < k
• In other words, zip k : (B N )k → B N is a bijection with inverse
unzip k = hunzip 0,k , . . . , unzip k−1,k i : B N → (B N )k .
Zip-Unzip Bijection
• Ex. unzip 0,2 (σ) = even(σ) = (σ(0), σ(2), σ(4), . . .)
unzip 1,2 (σ) = odd(σ) = (σ(1), σ(3), σ(5), . . .)
• We have:
zip 2 (even(σ), odd(σ)) = σ
even(zip 2 (σ, τ ))
odd(zip 2 (σ, τ ))
= σ
= τ
• In general,
zip k (unzip 0,k (σ), . . . , unzip k−1,k (σ)) = σ
unzip i,k (zip k (σ0 , . . . , σk−1 )) = σi
∀i < k
• In other words, zip k : (B N )k → B N is a bijection with inverse
unzip k = hunzip 0,k , . . . , unzip k−1,k i : B N → (B N )k .
Zip-Unzip Bijection
• Ex. unzip 0,2 (σ) = even(σ) = (σ(0), σ(2), σ(4), . . .)
unzip 1,2 (σ) = odd(σ) = (σ(1), σ(3), σ(5), . . .)
• We have:
zip 2 (even(σ), odd(σ)) = σ
even(zip 2 (σ, τ ))
odd(zip 2 (σ, τ ))
= σ
= τ
• In general,
zip k (unzip 0,k (σ), . . . , unzip k−1,k (σ)) = σ
unzip i,k (zip k (σ0 , . . . , σk−1 )) = σi
∀i < k
• In other words, zip k : (B N )k → B N is a bijection with inverse
unzip k = hunzip 0,k , . . . , unzip k−1,k i : B N → (B N )k .
The k-Automaton of Streams
(Case k = 3)
• Define k-automaton structure on B ω ,
β = Bω
hhd,tli
∼
=
idB ×unzip 3
/
∼
=
/ B × Bω
B × (B ω ){1,2,3}
σ|σ(0)
1
w
unzip 0,3 (σ 0 )
..
.
2
3
unzip 1,3 (σ 0 )
..
.
'
unzip 2,3 (σ 0 )
..
.
The k-Automaton of Streams
(Case k = 3)
• Define k-automaton structure on B ω ,
β = Bω
hhd,tli
∼
=
idB ×unzip 3
/
∼
=
/ B × Bω
B × (B ω ){1,2,3}
σ|σ(0)
1
w
unzip 0,3 (σ 0 )
..
.
2
3
unzip 1,3 (σ 0 )
..
.
'
unzip 2,3 (σ 0 )
..
.
From Streams to Languages by Finality
• By finality of (L, λ), there is unique h : (B ω , β) → (L, λ):
Bω
∃!h
hhd,unzip 3 ◦tli
λ
B×
/L
(B ω ){1,2,3}
idB ×h{1,2,3}
/ B × L{1,2,3}
Bijective k-Adic Numeration
Concretely,
h(σ)(w ) = σ(ν(w )) ∀w ∈ {1, 2, 3}∗
∼
=
where ν : {1, 2, 3}∗ −→ N is bijective 3-adic numeration
(least significant digit first, reverse).
defined by:
ν(ε) = 0,
ν(aw ) = a + 3 · ν(w )
Bijective k-Adic Numeration
Concretely,
h(σ)(w ) = σ(ν(w )) ∀w ∈ {1, 2, 3}∗
∼
=
where ν : {1, 2, 3}∗ −→ N is bijective 3-adic numeration
(least significant digit first, reverse).
defined by:
ν(ε) = 0,
ν(aw ) = a + 3 · ν(w )
w
ε
1
2
3
11
21
31
12
..
.
ν(w )
0
1 + 3 · ν(ε) = 1
2 + 3 · ν(ε) = 2
3 + 3 · ν(ε) = 3
1 + 3 · ν(1) = 4
2 + 3 · ν(1) = 5
3 + 3 · ν(1) = 6
1 + 3 · ν(2) = 7
..
.
The Final k-Automaton of Streams
•
⇒
⇒
⇒
• We get coinduction
ν bijective
h : B ω → L bijective
h is isomorphism of k-automata
(B ω , β = hhd, unzip 3 ◦ tli) is also final.
principle:
[[−]]
X
ho,di
B × X {1,2,3}
i.e., ∀x ∈ X :
idB
×[[−]]{1,2,3}
/ Bω
hhd,unzip 3 ◦tli
/ B × (B ω ){1,2,3}
[[x]](0)
unzip 0,3 ([[x]]0 )
unzip 1,3 ([[x]]0 )
unzip 2,3 ([[x]]0 )
=
=
=
=
o(x)
[[d(x)(1)]]
[[d(x)(2)]]
[[d(x)(3)]]
The Final k-Automaton of Streams
•
⇒
⇒
⇒
• We get coinduction
ν bijective
h : B ω → L bijective
h is isomorphism of k-automata
(B ω , β = hhd, unzip 3 ◦ tli) is also final.
principle:
[[−]]
X
ho,di
B × X {1,2,3}
i.e., ∀x ∈ X :
idB
×[[−]]{1,2,3}
/ Bω
hhd,unzip 3 ◦tli
/ B × (B ω ){1,2,3}
[[x]](0)
unzip 0,3 ([[x]]0 )
unzip 1,3 ([[x]]0 )
unzip 2,3 ([[x]]0 )
=
=
=
=
o(x)
[[d(x)(1)]]
[[d(x)(2)]]
[[d(x)(3)]]
The Final k-Automaton of Streams
•
⇒
⇒
⇒
• We get coinduction
ν bijective
h : B ω → L bijective
h is isomorphism of k-automata
(B ω , β = hhd, unzip 3 ◦ tli) is also final.
principle:
[[−]]
X
ho,di
B × X {1,2,3}
i.e., ∀x ∈ X :
idB
×[[−]]{1,2,3}
/ Bω
hhd,unzip 3 ◦tli
/ B × (B ω ){1,2,3}
[[x]](0)
unzip 0,3 ([[x]]0 )
unzip 1,3 ([[x]]0 )
unzip 2,3 ([[x]]0 )
=
=
=
=
o(x)
[[d(x)(1)]]
[[d(x)(2)]]
[[d(x)(3)]]
Zip-Stream Differential Equations
. . . or equivalently (using zip-unzip isomorphism):
[[x]](0) = o(x),
[[x]]0 = zip 3 ([[d(x)(1)]], [[d(x)(2)]], [[d(x)(3)]])
Example of a (finite) system of zip 3 -SDEs over X = {x, y , z} with
B = {a, b}:
x(0) = a,
y (0) = b,
z(0) = b,
x 0 = zip 3 (y , x, x),
y 0 = zip 3 (x, y , x),
z 0 = zip 3 (y , z, y ),
Lemma Every system of zip k -SDEs has a unique stream solution.
Zip-Stream Differential Equations
. . . or equivalently (using zip-unzip isomorphism):
[[x]](0) = o(x),
[[x]]0 = zip 3 ([[d(x)(1)]], [[d(x)(2)]], [[d(x)(3)]])
Example of a (finite) system of zip 3 -SDEs over X = {x, y , z} with
B = {a, b}:
x(0) = a,
y (0) = b,
z(0) = b,
x 0 = zip 3 (y , x, x),
y 0 = zip 3 (x, y , x),
z 0 = zip 3 (y , z, y ),
Lemma Every system of zip k -SDEs has a unique stream solution.
Zip-Stream Differential Equations
. . . or equivalently (using zip-unzip isomorphism):
[[x]](0) = o(x),
[[x]]0 = zip 3 ([[d(x)(1)]], [[d(x)(2)]], [[d(x)(3)]])
Example of a (finite) system of zip 3 -SDEs over X = {x, y , z} with
B = {a, b}:
x(0) = a,
y (0) = b,
z(0) = b,
x 0 = zip 3 (y , x, x),
y 0 = zip 3 (x, y , x),
z 0 = zip 3 (y , z, y ),
Lemma Every system of zip k -SDEs has a unique stream solution.
2-Automatic Sequences: Example
• Consider automaton (with input and output in 2 = {0, 1}):
+
0
1
x|0 g
'
y |1 k
0
1
• Language semantics: for all w ∈ 2∗ , [[x]](w ) = o(d ∗ (x)(w ))
• Define the stream σ ∈ 2ω :
σ(n) = [[x]](base2 (n)) = #1 (base2 (n)) mod 2
σ = (0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, ...)
Thue-Morse Sequence is 2-automatic
• Alternative def. as system of zip-equations:
x(0) = 0,
y (0) = 1,
x = zip 2 (x, y )
y = zip 2 (y , x)
2-Automatic Sequences: Example
• Consider automaton (with input and output in 2 = {0, 1}):
+
0
1
x|0 g
'
y |1 k
0
1
• Language semantics: for all w ∈ 2∗ , [[x]](w ) = o(d ∗ (x)(w ))
• Define the stream σ ∈ 2ω :
σ(n) = [[x]](base2 (n)) = #1 (base2 (n)) mod 2
σ = (0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, ...)
Thue-Morse Sequence is 2-automatic
• Alternative def. as system of zip-equations:
x(0) = 0,
y (0) = 1,
x = zip 2 (x, y )
y = zip 2 (y , x)
2-Automatic Sequences: Example
• Consider automaton (with input and output in 2 = {0, 1}):
+
0
1
x|0 g
'
y |1 k
0
1
• Language semantics: for all w ∈ 2∗ , [[x]](w ) = o(d ∗ (x)(w ))
• Define the stream σ ∈ 2ω :
σ(n) = [[x]](base2 (n)) = #1 (base2 (n)) mod 2
σ = (0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, ...)
Thue-Morse Sequence is 2-automatic
• Alternative def. as system of zip-equations:
x(0) = 0,
y (0) = 1,
x = zip 2 (x, y )
y = zip 2 (y , x)
k-Automatic Sequences (Allouche and J. Shallit, 2003)
Def. A sequence σ ∈ B ω is k-automatic if one of the following
equivalent conditions hold:
• σ is generated by a finite k-automaton, i.e.,
∀n ∈ N :
σ(n) = o(d ∗ (x)(basek (n)))
where basek (n) is base k expansion of n.
• the k-kernel of σ is finite, i.e.,
there is Σ = {τ1 , . . . , τn } ⊆ B ω such that σ ∈ Σ and
unzip j,k (τi ) ∈ Σ
∀i ≤ n ∀j < k
• σ is solution to a finite system of zip-equations:
x1 = zip k (x1,1 , . . . , x1,k )
..
..
.
.
xn = zip k (xn,1 , . . . , xn,k )
Characterisation of k-Automatic Sequences
Theorem. TFAE
• A sequence σ ∈ B ω is k-automatic.
• σ is generated by a finite k-automaton.
• σ is the solution to a finite system of zip k -SDEs.
(cf. [Endrullis-Grabmayer-Hendriks-Klop-Moss, 2011])
From k-Automata to Weighted k-Automata
(S is a set)
(deterministic) 1-automata
X →S ×X
(eventually periodic
streams)
(deterministic) k-automata
X → S × Xk
(regular languages)
(k-automatic streams)
From k-Automata to Weighted k-Automata
(S is a set)
(S is a semiring)
(deterministic) 1-automata
X →S ×X
(eventually periodic
streams)
weighted 1-automata
X → S × S(X )
(rational streams)
(deterministic) k-automata
X → S × Xk
(regular languages)
(k-automatic streams)
weighted k-automata
X → S × S(X )k
Weighted k-Automata
Let S = (S, +, ·, 0, 1) be a semiring.
• An S-weighted k-automaton with state space X is a map:
X → S × S(X )k
where
S(X ) = {φ : X → S | supp(φ) finite}
= {s1 x1 + · · · + sn xn | s1 , . . . , sn ∈ S, x1 , . . . , xn ∈ X }
• In fact: S(X ) is free S-semimodule over X (S is a monad).
Specifying Weighted k-Automata
• For example, S = (N, +, ·, 0, 1), k = {a, b}):
X → N × S(X ){a,b}
• Weighted k-automaton example:
a,2
b,3
+
a,1
'
x|1 g
y |0 k
a,3
b,1
a,1
b,1
• ... in BDE format,
x(0) = 1,
y (0) = 0,
xa = 2x + y ,
ya = x + 3y ,
xb = 3x
yb = y
Weighted Languages as Formal Power Series
• S-weighted languages are formal power series
(in k noncommuting variables with coefficients in S)
Shhkii = {ρ : k ∗ → S}
• Note: Shhkii is S-semimodule with pointwise operations.
• Note: Final morphism into Shhkii is S-linear.
(Shhkii, λ) final k-automaton in category of S-semimodules.
Language Semantics of Weighted k-Automata
• Language semantics via “linearisation”:
η
X
ho,di
|
S × S(X )k
/ S(X )
ˆ
hô,di
/ Shhkii
λ
/ S × Shhkiik
ˆ : S(X ) → S × S(X )k is (deterministic)
• Note: hô, di
k-automaton in category of S-semimodules.
• A formal power series ρ is rational if generated by finite
weighted k-automaton.
Stream Semantics of Weighted k-Automata
• Stream semantics via “linearisation” and k-adic numeration:
η
X
ho,di
|
S × S(X )k
/ S(X )
ˆ
hô,di
[[−]]S
/ Sω
hhd,unzip k ◦tli
/ S × (S ω )k
[[−]]S is the unique S-linear map such that
Jη(x)KS (0) = o(x)
Jη(x)K0S
= zip k (Jδ(x)(1)KS , . . . , Jδ(x)(k)KS ).
Linear Stream Specifications
Streams specified in linear BDE format:
x(0) = 1,
y (0) = 0,
x1 = 2x + y ,
y1 = x + 3y ,
x2 = 3x
y2 = y
equivalent with linear even-odd specification:
x(0) = 1, even(x 0 ) = 2x + y ,
y (0) = 0, even(y 0 ) = x + 3y ,
odd(x 0 ) = 3x
odd(y 0 ) = y
equivalent with linear zip-stream differential equations:
x(0) = 1,
y (0) = 0,
x 0 = zip 2 (2x + y , 3x)
y 0 = zip 2 (x + 3y , y )
Lemma A system of linear zip-SDEs has a unique solution.
Linear Stream Specifications
Streams specified in linear BDE format:
x(0) = 1,
y (0) = 0,
x1 = 2x + y ,
y1 = x + 3y ,
x2 = 3x
y2 = y
equivalent with linear even-odd specification:
x(0) = 1, even(x 0 ) = 2x + y ,
y (0) = 0, even(y 0 ) = x + 3y ,
odd(x 0 ) = 3x
odd(y 0 ) = y
equivalent with linear zip-stream differential equations:
x(0) = 1,
y (0) = 0,
x 0 = zip 2 (2x + y , 3x)
y 0 = zip 2 (x + 3y , y )
Lemma A system of linear zip-SDEs has a unique solution.
Linear Stream Specifications
Streams specified in linear BDE format:
x(0) = 1,
y (0) = 0,
x1 = 2x + y ,
y1 = x + 3y ,
x2 = 3x
y2 = y
equivalent with linear even-odd specification:
x(0) = 1, even(x 0 ) = 2x + y ,
y (0) = 0, even(y 0 ) = x + 3y ,
odd(x 0 ) = 3x
odd(y 0 ) = y
equivalent with linear zip-stream differential equations:
x(0) = 1,
y (0) = 0,
x 0 = zip 2 (2x + y , 3x)
y 0 = zip 2 (x + 3y , y )
Lemma A system of linear zip-SDEs has a unique solution.
Linear Stream Specifications
Streams specified in linear BDE format:
x(0) = 1,
y (0) = 0,
x1 = 2x + y ,
y1 = x + 3y ,
x2 = 3x
y2 = y
equivalent with linear even-odd specification:
x(0) = 1, even(x 0 ) = 2x + y ,
y (0) = 0, even(y 0 ) = x + 3y ,
odd(x 0 ) = 3x
odd(y 0 ) = y
equivalent with linear zip-stream differential equations:
x(0) = 1,
y (0) = 0,
x 0 = zip 2 (2x + y , 3x)
y 0 = zip 2 (x + 3y , y )
Lemma A system of linear zip-SDEs has a unique solution.
k-Regular Sequences
Def. (cf. Allouche-Shallit)
A sequence σ ∈ S ω is k-regular if one of the following equivalent
conditions hold:
• the k-kernel of σ is contained in a finitely generated
S-semimodule, i.e., there is Σ = {τ1 , . . . , τn } ⊆ S ω such that
σ ∈ Σ and for all i = 1, . . . , n
unzip j,k (τi ) ∈ S(Σ)
∀j < k
(S(Σ) = S-linear combinations over τ1 , . . . , τn )
• σ is solution to finite system of linear zip-equations:
x1 = zip k (γ1,1 , . . . , γ1,k )
..
..
.
.
xn = zip k (γn,1 , . . . , γn,k )
where γi,j ∈ S({x1 , . . . , xn }), x1 , . . . , xn ∈ S ω .
Example of k-Regular Sequence
The sequence of numbers whose base 3 representation does not
contain the digit ‘2’
σ = (0, 1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, . . .)
is solution to
σ = zip 2 (3σ, 3σ + ones)
ones = zip 2 (ones, ones)
Hence is 2-regular.
Characterisation of k-Regular Sequences
Theorem. TFAE
• A sequence σ ∈ S ω is k-regular.
• σ is generated by a finite weighted k-automaton.
• h(σ) is a rational power series.
• σ is the solution to a finite system of linear zip k -SDEs.
Corollary. There is a bijective correspondence between k-regular
sequences and rational power series.
Proof sketch
Transform linear zip-equations into linear zip-SDEs. E.g., for earlier
system:
σ 0 = zip(3σ + ones, 3σ 0 )
σ 00 = zip(3σ 0 , 3σ 0 + ones0 )
ones0 = zip(ones, ones0 )
ones00 = zip(ones0 , ones0 )
introduce variables and add initial values:
w (0)
x(0)
y (0)
z(0)
=
=
=
=
3 · σ(0),
3 · σ(0) + 1,
1,
1,
w0
x0
y0
z0
=
=
=
=
zip(3w + y , 3x)
zip(3x, 3x + z)
zip(y , z)
zip(z, z)
Proof sketch
Transform linear zip-equations into linear zip-SDEs. E.g., for earlier
system:
σ 0 = zip(3σ + ones, 3σ 0 )
σ 00 = zip(3σ 0 , 3σ 0 + ones0 )
ones0 = zip(ones, ones0 )
ones00 = zip(ones0 , ones0 )
introduce variables and add initial values:
w (0)
x(0)
y (0)
z(0)
=
=
=
=
3 · σ(0),
3 · σ(0) + 1,
1,
1,
w0
x0
y0
z0
=
=
=
=
zip(3w + y , 3x)
zip(3x, 3x + z)
zip(y , z)
zip(z, z)
Application: Divide and Conquer Recurrences
On the Online Encyclopedia of Integer Sequences (OEIS), some
formats for divide and conquer recurrences are given. E.g.
a(2n) = Ca(n) + Ca(n − 1) + P(n)
a(2n + 1) = 2Ca(n) + Q(n)
where C ∈ Z, P and Q are expressible by a rational g.f.
Question (asked on oeis.org/somedcgf.html): ‘An open
question would be whether all sequences here discussed are
2-regular.’
Answer: if you replace the condition ‘expressible by a rational g.f.’
by ‘2-regular’ then yes (includes all their examples), otherwise no.
Application: Divide and Conquer Recurrences
On the Online Encyclopedia of Integer Sequences (OEIS), some
formats for divide and conquer recurrences are given. E.g.
a(2n) = Ca(n) + Ca(n − 1) + P(n)
a(2n + 1) = 2Ca(n) + Q(n)
where C ∈ Z, P and Q are expressible by a rational g.f.
Question (asked on oeis.org/somedcgf.html): ‘An open
question would be whether all sequences here discussed are
2-regular.’
Answer: if you replace the condition ‘expressible by a rational g.f.’
by ‘2-regular’ then yes (includes all their examples), otherwise no.
From k-Automata to Weighted k-Automata
(S is a set)
(S is a semiring)
(deterministic) 1-automata
X →S ×X
(eventually periodic
streams)
weighted 1-automata
X → S × S(X )
(rational streams)
(deterministic) k-automata
X → S × Xk
(regular languages)
(k-automatic streams)
weighted k-automata
X → S × S(X )k
(rational power series)
(k-regular sequences)
Conclusion
Summary:
k-regular
weighted automata
rational streams
=
=
k-automatic
determ. automata
event.per. streams
• Isomorphism between final k-automaton of languages and final
k-automaton of streams (via bijective k-adic numeration).
• Bijective correspondence between rational power series and
k-regular sequences.
• Characterisation of k-regular sequences as solutions to
finite systems of linear zip k -SDEs.
Conclusion
Paper:
A final coalgebra for k-regular sequences,
Helle Hvid Hansen, Clemens Kupke, Jan Rutten, Joost Winter.
Horizons of the Mind: A Tribute to Prakash Panangaden.
LNCS 8464, Springer, 2014.
Future work:
• (constructively) algebraic power series
(in BDEs, replace linear comb’s with polynomials).
Connection: algebraic power series and context-free
sequences?
• other numeration systems?
Download