Natsuki Urabe (U. Tokyo)
/ 29
Categorical Liveness Checking
by
Corecursive Algebras
Natsuki Urabe, Masaki Hara & Ichiro Hasuo June 20, 2017
1
Categorical Liveness Checking by Corecursive Algebras Natsuki - - PowerPoint PPT Presentation
Categorical Liveness Checking by Corecursive Algebras Natsuki Urabe, Masaki Hara & Ichiro Hasuo June 20, 2017 Natsuki Urabe (U. Tokyo) 1 / 29 Motivation ranking function nondeterministic system Natsuki Urabe (U.
Natsuki Urabe (U. Tokyo)
/ 29
Natsuki Urabe, Masaki Hara & Ichiro Hasuo June 20, 2017
1
Natsuki Urabe (U. Tokyo)
/ 29
2
nondeterministic system
ranking function
Natsuki Urabe (U. Tokyo)
/ 29
2
nondeterministic system
ranking function
generalization
categorically generalized system
“categorical ranking function”
Natsuki Urabe (U. Tokyo)
/ 29
2
nondeterministic system
ranking function
probabilistic system
concretization
“probabilistic ranking function”?
generalization
categorically generalized system
“categorical ranking function”
Natsuki Urabe (U. Tokyo)
/ 29
3
Natsuki Urabe (U. Tokyo)
/ 29
3
Natsuki Urabe (U. Tokyo)
/ 29 4
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 4
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
○
nonaccepting
○ ○ ○
b
accepting
arbitrary
≥ min{a, b, c} + 1 min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
1
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
∞
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 5
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
∞ ∞ ∞
Def: A function is a ranking function if:
for each nonaccepting state x b : X → N∞ N ∪ {∞} N∞ =
( )
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29 6
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
∞ ∞ ∞
b(x) ≥ distance to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29 6
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
∞ ∞ ∞
Thm: (see e.g. [Floyd, PSAM ’67])
b(x) < ∞ b is a ranking function and an accepting state is reachable from x b(x) ≥ distance to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29 6
x0 x1 x2 x3 x4 u x5 / / O / O
/
1 2
∞ ∞ ∞
Thm: (see e.g. [Floyd, PSAM ’67])
b(x) < ∞ b is a ranking function and an accepting state is reachable from x
under-approximates the reaching set
b(x) ≥ distance to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29
7
Natsuki Urabe (U. Tokyo)
/ 29
8
categorical generalization of ranking function
Natsuki Urabe (U. Tokyo)
/ 29
9
: a functor
F
X 7! F X
(f : X → Y )
(F f : F X → F Y )
Natsuki Urabe (U. Tokyo)
/ 29
9
: a functor
F
X 7! F X
(f : X → Y )
(F f : F X → F Y )
Natsuki Urabe (U. Tokyo)
/ 29 10
Example I: Nondeterministic Transition System with Accepting States
where PX = {A ⊆ X}
F = P( ) × {0, 1} c : X → PX × {0, 1}
Natsuki Urabe (U. Tokyo)
/ 29 10
Example I: Nondeterministic Transition System with Accepting States
an accepting state
x0 x1 x2 x3 x4 u x5 / / O / O
/
where PX = {A ⊆ X}
F = P( ) × {0, 1} c : X → PX × {0, 1}
Natsuki Urabe (U. Tokyo)
/ 29 10
Example I: Nondeterministic Transition System with Accepting States
an accepting state
x0 x1 x2 x3 x4 u x5 / / O / O
/
where PX = {A ⊆ X}
F = P( ) × {0, 1} c : X → PX × {0, 1} X = {x0, x1, x2, x3, x4, x5} c : x0 7! ({x1, x2}, 0) x1 7! ({x3}, 0) . . . x4 7! ({x5}, 1) . . .
Natsuki Urabe (U. Tokyo)
/ 29 11
Example II: Probabilistic Transition System with Accepting States
where
c : X → DX × {0, 1}
DX = {d : X → [0, 1] | P
x d(x) = 1}
F = D( ) × {0, 1}
Natsuki Urabe (U. Tokyo)
/ 29 11
Example II: Probabilistic Transition System with Accepting States
x0 x1 x2 x3 x4
u
x5
0.3 / 0.4
O /
1
O
0.7 1
O
0.6 /
where
c : X → DX × {0, 1}
DX = {d : X → [0, 1] | P
x d(x) = 1}
F = D( ) × {0, 1}
Natsuki Urabe (U. Tokyo)
/ 29 11
Example II: Probabilistic Transition System with Accepting States
x0 x1 x2 x3 x4
u
x5
0.3 / 0.4
O /
1
O
0.7 1
O
0.6 /
where
c : X → DX × {0, 1}
DX = {d : X → [0, 1] | P
x d(x) = 1}
F = D( ) × {0, 1} X = {x0, x1, x2, x3, x4, x5}
c : x0 7! ([x1 7! 0.7, x2 7! 0.3], 0) x1 7! ([x3 7! 1], 0) x2 7! ([x3 7! 0.4, x4 7! 0.6], 0) . . .
Natsuki Urabe (U. Tokyo)
/ 29
Def:
12
A coalgebra-algebra homomorphism from to is s.t.
σ : F Ω → Ω
c : X → F X f : X → Ω
σ F f c = f
F X
= F f
/ F Ω
σ
✏ X
c
O
f
/ Ω
captures reachability
JµσKc : X → Ω
Natsuki Urabe (U. Tokyo)
/ 29
Def:
12
A coalgebra-algebra homomorphism from to is s.t.
σ : F Ω → Ω
c : X → F X f : X → Ω
σ F f c = f
F X
= F f
/ F Ω
σ
✏ X
c
O
f
/ Ω
captures reachability
JµσKc : X → Ω
Example:
JµσKc(x) = 1 ⇔ an accepting state is reachable from x
σ : F {0, 1} → {0, 1} ∃
∃ σ : F [0, 1] → [0, 1] JµσKc(x) = Prob(reach an accepting state from x)
Natsuki Urabe (U. Tokyo)
/ 29
Remark: Coalgebra-Algebra Homomorphism is Fixed Point
(see e.g. [Jacobs, LMCS 2015])
13
Def:
F X
F f
/ F Ω
σ
✏ X
c
O Ω
X
f
/ Ω 7!
(predicate lifting + precomposing c => weakest precondition)
Natsuki Urabe (U. Tokyo)
/ 29
Remark: Coalgebra-Algebra Homomorphism is Fixed Point
(see e.g. [Jacobs, LMCS 2015])
13
Def:
F X
F f
/ F Ω
σ
✏ X
c
O Ω
X
f
/ Ω 7!
Prop:
⇔ f is a fixed point of Φc,σ
F X
= F f
/ F Ω
σ
✏ X
c
O
f
/ Ω
(predicate lifting + precomposing c => weakest precondition)
Natsuki Urabe (U. Tokyo)
/ 29
Remark: Coalgebra-Algebra Homomorphism is Fixed Point
(see e.g. [Jacobs, LMCS 2015])
13
Def:
F X
F f
/ F Ω
σ
✏ X
c
O Ω
X
f
/ Ω 7!
Prop:
⇔ f is a fixed point of Φc,σ
F X
= F f
/ F Ω
σ
✏ X
c
O
f
/ Ω
reachability as the least coalgebra-algebra homomorphism
(predicate lifting + precomposing c => weakest precondition)
Natsuki Urabe (U. Tokyo)
/ 29
14
Natsuki Urabe (U. Tokyo)
/ 29
for each nonaccepting state x
A function is a ranking function if:
b : X → N∞ N ∪ {∞} N∞ =
( )
Def:
15
min
x!x0 b(x0)+1 ≤ b(x)
Natsuki Urabe (U. Tokyo)
/ 29
for each nonaccepting state x
A function is a ranking function if:
b : X → N∞ N ∪ {∞} N∞ =
( )
Def:
15
min
x!x0 b(x0)+1 ≤ b(x)
15
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c
Natsuki Urabe (U. Tokyo)
/ 29
16 16
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c
Natsuki Urabe (U. Tokyo)
/ 29
16
F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/ 7 R
q
/ Ω
16
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c
Natsuki Urabe (U. Tokyo)
/ 29
16
F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/ 7 R
q
/ Ω
16
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c
Natsuki Urabe (U. Tokyo)
/ 29
16
F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/ 7 R
q
/ Ω
16
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c
Natsuki Urabe (U. Tokyo)
/ 29
17
structured corecursion [Capretta et al., SBMF ‘09]
Def:
An algebra is corecursive if for all coalgebra , a coalgebra-algebra homomorphism from to uniquely exists.
r : F R → R c : X → F X
F X
= F LrMc / F R r
✏ X
c
O
LrMc
/ R
Natsuki Urabe (U. Tokyo)
/ 29
18 18
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/ R
q
/ Ω
Natsuki Urabe (U. Tokyo)
/ 29
18 18
Def:
An arrow is a ranking arrow wrt. if: b : X → R
(r, q, vR)
Def:
A ranking domain wrt. σ : F Ω → Ω is a triple ( r : F R ! R, q : R ! Ω, vR ) s.t.
b vR r F b c F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/ R
q
/ Ω
fix a ranking domain
notion of ranking function
Natsuki Urabe (U. Tokyo)
/ 29
19
Thm: (see e.g. [Floyd, PSAM ’67])
b(x) < ∞ b is a ranking function and an accepting state is reachable from x
Natsuki Urabe (U. Tokyo)
/ 29
19
Thm: (see e.g. [Floyd, PSAM ’67])
{x | b(x) < ∞} b is a ranking function ⊆ ( x
reachable )
Natsuki Urabe (U. Tokyo)
/ 29
19
Thm: (see e.g. [Floyd, PSAM ’67])
{x | b(x) < ∞} b is a ranking function ⊆ ( x
reachable )
Thm (soundness):
b is a ranking arrow
F X v
F b
/ F R
r
✏
v F q
/ F Ω
σ
✏ X
c
O
b
/
JµσKc
7 R
q
/ Ω
v
Natsuki Urabe (U. Tokyo)
/ 29
20
under-approximate the least fixed point
F X
=µ F JµσKc / F Ω σ
✏ X
c
O
JµσKc
/ Ω
Natsuki Urabe (U. Tokyo)
/ 29
20
under-approximate the least fixed point
F X
=µ F JµσKc / F Ω σ
✏ X
c
O
JµσKc
/ Ω
F X v
F b
/ F R
r
✏ X
c
O
b
/ R
Natsuki Urabe (U. Tokyo)
/ 29
20
under-approximate the least fixed point
F X
=µ F JµσKc / F Ω σ
✏ X
c
O
JµσKc
/ Ω
F X v
F b
/ F R
r
✏ X
c
O
b
/ R
It under-approximates the greatest fixed point
(the Knaster-Tarski theorem)
Natsuki Urabe (U. Tokyo)
/ 29
20
under-approximate the least fixed point
F X
=µ F JµσKc / F Ω σ
✏ X
c
O
JµσKc
/ Ω
we collapse the least and the greatest fixed points (i.e. unique coalgebra-algebra homomorphism)
F X v
F b
/ F R
r
✏ X
c
O
b
/ R
It under-approximates the greatest fixed point
(the Knaster-Tarski theorem)
Natsuki Urabe (U. Tokyo)
/ 29
21
Natsuki Urabe (U. Tokyo)
/ 29
22
nondeterministic system
ranking function & soundness theorem
probabilistic automaton
concretization
“probabilistic ranking function”?
generalization
categorically generalized system
“categorical ranking function” & soundness theorem
c : X → PX × {0, 1} c : X → DX × {0, 1}
Natsuki Urabe (U. Tokyo)
/ 29
23
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞]
probabilistic systems
Natsuki Urabe (U. Tokyo)
/ 29
23
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞]
probabilistic systems
accepting
○
nonaccepting
○ ○ ○
c a b
p q r
≥ pa + qb + rc+1
arbitrary
Natsuki Urabe (U. Tokyo)
/ 29
24
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞] u O
1 2
O
1 2
;
Natsuki Urabe (U. Tokyo)
/ 29
24
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞] u O
1 2
O
1 2
;
2
Natsuki Urabe (U. Tokyo)
/ 29
24
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞] u O
1 2
O
1 2
;
2
b(x) ≥ E number of steps to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29
24
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞] u O
1 2
O
1 2
;
2
Thm:
b is a ranking supermartingale and b(x) < ∞
an accepting state is reached ! = 1
b(x) ≥ E number of steps to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29
24
Def:
X
x02X
Prob(x → x0) · b(x0) +1 ≤ b(x)
A function is a ranking supermartingale if:
b : X → [0, ∞] u O
1 2
O
1 2
;
2
Thm:
b is a ranking supermartingale and b(x) < ∞
an accepting state is reached ! = 1
a ranking domain for ranking supermartingale exists? b(x) ≥ E number of steps to an accepting state from x !
Natsuki Urabe (U. Tokyo)
/ 29
25
(r, q, vR)
b is a ranking arrow
b is a ranking supermartingale
Natsuki Urabe (U. Tokyo)
/ 29
25
(r, q, vR)
b is a ranking arrow
b is a ranking supermartingale
We decided to give up describing ranking supermartingales
Natsuki Urabe (U. Tokyo)
/ 29
25
(r, q, vR)
b is a ranking arrow
b is a ranking supermartingale
We decided to give up describing ranking supermartingales They induces new definitions of ranking function (to the best of our knowledge)
Natsuki Urabe (U. Tokyo)
/ 29
For a probabilistic transition system, a function is a distribution-valued ranking function if:
b : X → DN∞
X
x02X
Pr(x → x0) · b(x0) !
26
∀a ∈ N∞. By soundness of (categorical) ranking arrows,
Thm:
Pr an accepting state is reached from x ! b(x)
Natsuki Urabe (U. Tokyo)
/ 29
For a probabilistic transition system, a function is a distribution-valued ranking function if:
b : X → DN∞
X
x02X
Pr(x → x0) · b(x0) !
26
∀a ∈ N∞. By soundness of (categorical) ranking arrows,
Thm:
Pr an accepting state is reached from x ! b(x)
Quantitative reasoning
Natsuki Urabe (U. Tokyo)
/ 29
Def:
27
Quantitative reasoning
For , a function is a -scaled noncounting ranking function if:
By soundness of (categorical) ranking arrows,
Thm:
Pr an accepting state is reached from x !
b(x) ≤
γ ∈ (0, 1) b : X → [0, 1]
γ
γ· X
x02X
Pr(x → x0) · b(x0) ≥ b(x)
Natsuki Urabe (U. Tokyo)
/ 29
28
Natsuki Urabe (U. Tokyo)
/ 29
29
Natsuki Urabe (U. Tokyo)
/ 29 30
Natsuki Urabe (U. Tokyo)
/ 29 31