implicitly-typed deadlock-free process calculuskoba/ss2013/ss2013-2.pdf決定性 < 非決定性 =...
TRANSCRIPT
PPLサマースクール 「高階モデル検査とその応用」
東京大学 小林 直樹
講義の計画
第一部 – 高階モデル検査とその意義
第二部 – 高階モデル検査アルゴリズム
第三部 – 高階モデル検査のプログラム検証への応用
第二部の目次 高階モデル検査問題
– 高階再帰スキーム – 木オートマトン
• 自明オートマトン • 交代性パリティ木オートマトン
高階モデル検査の型判定問題への帰着 高階モデル検査アルゴリズム
済
高階モデル検査問題
検証できる性質の例 - Does every finite path end with “c”? - Does “a” occur below “b”?
入力: G: 高階再帰スキーム(HORS) A: (無限木を受理する)木オートマトン (交代性パリティ木オートマトン、 または様相μ計算の論理式), 出力: A が Gの生成する木Tree(G)を受理するか否か
定理 (Ong 2006) order-k HORSに対する 高階モデル検査問題はk重指数完全
p(x) 2 .. 2 2
(有限語を受理する)オートマトン(復習)
A = (Σ, Q, ∆, q0, F) Σ: 入力記号の有限集合 Q: 状態の有限集合 q0: 初期状態 ∆: 遷移規則(q →a q’)の集合 F: 受理状態の集合
A がw=a1...anを受理 ∃q1...qn. (q0 →a1 q1→a2 ...→an qn∈ F) 例:偶数個のaを持つ語を受理するオートマトン (a,b, even,odd, ∆, even, even) even →a odd, odd →a even, even →b even, odd →b odd
∆ =
even →a odd →b odd →b odd →a evenなのでabbaは受理
(トップダウン)非決定性木オートマトン A = (Σ, Q, ∆, q0)
Σ: 入力記号の有限集合(arityつき) Q: 状態の有限集合 q0: 初期状態 ∆: 遷移規則(q →a q1 ... qarity(a) )の集合
A が木Tを受理 Tの各ノードに遷移規則に従った状態割り当てが可能
例:aを偶数個含む木を受理するオートマトン
(a/2,b/1,e/0, even,odd, ∆, even) even →aodd even,
odd →aeven even, even →beven, odd →bodd, even →e
∆ =
a
T1 T2
... Tn
q
q1 q2 qn
even →aeven odd, odd →aodd odd,
a
a b
e
e
e b
even
even odd
even even
even
even
(トップダウン)交代性木オートマトン A = (Σ, Q, δ, q0)
Σ: 入力記号の有限集合(arityつき) Q: 状態の有限集合 q0: 初期状態 δ: 遷移関数 (状態、入力記号の組を(i,qi),∧,∨,true,falseからなる論理式に写像)
A が木Tを受理 遷移規則に従ったオートマトンの状態遷移、分岐が可能
例:aを偶数個含む木を受理する交代性木オートマトン
(a/2,b/1,e/0, even,odd, δ, even) δ(even, a) = ((1,even)∧(2,odd))∨((1,odd) ∧(2,even)) δ(odd, a) = ((1,even)∧(2,even))∨((1,odd) ∧(2,odd)) δ(even, b) = (1,even) δ(odd, b) = (1, odd) δ(even, e) = true δ(odd, e) = true
無限語を受理する非決定性木オートマトン 非決定性木オートマトン+受理条件 A が木Tを受理 遷移規則に従うTの各ノードに対する状態割り当てのうち、 すべての無限パス上の状態列が受理条件を満たすものあり
オートマトン(*) 受理条件
自明木オートマトン なし(自明)
Bϋchi 木オートマトン 受理状態の少なくとも一つが無限回出現
パリティ木オートマトン 無限回現れる状態の優先度の最大値が偶数
(*) 他に代表的なものとして Muller , Streett, Rabinオートマトンがある
自明木オートマトンの例
c a a
b c
a b b c
a b b b c
...
q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
q0
q0 q0 q0 q0
q1 q0 q0
q1
q1
q0 q1
q1
q1 “a” does not occur below “b”
(非決定性)パリティ木オートマトンの例
c a a
b c
a b b c
a b b b c
...
q0
q0 q0 q0 q0
q1 q0 q0
q1
q1
q0 q1
q1
q1
優先度関数: Ω(q0) = 1 Ω(q1) = 2
受理条件: すべてのパスにおいて、無限回出現する状態の優先度の 最大値が偶数 = すべての無限パスはbを含む
q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
無限木に対するオートマトンの表現力
遷移関数による分類 決定性 < 非決定性 = 交代性 (ただし交代性の方が同じ性質を小さく表現可能)
受理条件による分類 自明 < Bϋchi < パリティ (=Muller=Streett= Rabin)
safety property の表現には自明木オートマトンで十分
交代性パリティ木オートマトンと様相µ計算の論理式との間では線形サイズの相互変換が可能 [Kupferman+,2000]
練習問題
アルファベットa/2,b/1,c/1から構成される
無限木で、次の条件を満たすもののみを受理するパリティ木オートマトンを作れ。
「すべてのパスにおいて、 (bが無限回出現するならば cも無限回出現する)」
練習問題解答例
(a/2,b/1,c/1, qa,qb,qc, D, qa, Ω) q →a qa qa q →b qb q →c qc
(for every q)
Ω(qa)=0, Ω(qb)=1, Ω(qc)=2
第二部の目次 高階モデル検査問題
– 高階再帰スキーム – 木オートマトン
高階モデル検査の型判定問題への帰着 – 自明木オートマトンの場合 – パリティ木オートマトンの場合
高階モデル検査アルゴリズム
高階モデル検査問題
入力: G: 高階再帰スキーム(HORS) A: (無限木を受理する)木オートマトン (交代性パリティ木オートマトン、 または様相μ計算の論理式), 出力: A が Gの生成する木Tree(G)を受理するか否か
定理 (Ong 2006) order-k HORSに対する 高階モデル検査問題はk重指数完全
p(x) 2 .. 2 2
目標 高階モデル検査と等価な型システムを構成
Tree(G) is accepted by A
if and only if
|−A G (GがAによってパラメタ化された 型システム|−Aで型づけ可能)
高階モデル検査の決定可能性の平易な証明
効率的な高階モデル検査アルゴリズム
既存の高階モデル検査アルゴリズム 第0世代(決定可能性の証明のための理論的なもの。
常にn重指数時間がかかる) – ゲーム意味論に基づくもの[Ong, LICS06] – CPDS経由 [Hague+,LICS08] – 型理論に基づくもの[K, POPL09][K&Ong, POPL09]
第1世代: – TRecS アルゴリズム[K, PPDP09] – GTRecS [K, FoSSaCS11] – TravMC [Neatherway+, 12]
第2世代: – HorSat [Broadbent&K, CSL13] – PREFACE [Ramsay+, HOPA13] – CSHORe [Hague+, ICFP13]
型判定問題への 帰着[K, POPL09] を利用
第二部の目次 高階モデル検査問題
– 高階再帰スキーム – 木オートマトン
高階モデル検査の型判定問題への帰着 – 自明木オートマトンの場合 – パリティ木オートマトンの場合
高階モデル検査アルゴリズム
高階モデル検査問題(一般の場合)
入力: G: 高階再帰スキーム(HORS) A: (交代性)パリティ木オートマトン 出力: A が Gの生成する木Tree(G)を受理するか否か
定理 (Ong 2006) order-k HORSに対する 高階モデル検査問題はk重指数完全
制限つき高階モデル検査問題
入力: G: 高階再帰スキーム(HORS) A: 自明木オートマトン 出力: A が Gの生成する木Tree(G)を受理するか否か
定理 (K&Ong 2009) - order-k HORSに対する制限つき 高階モデル検査問題はk重指数完全 - 自明木オートマトンをさらに決定性に制限すると (k-1)重指数完全
自明木オートマトンの例(再掲)
c a a
b c
a b b c
a b b b c
...
q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
q0
q0 q0 q0 q0
q1 q0 q0
q1
q1
q0 q1
q1
q1 “a” does not occur below “b”
型システムのアイデア オートマトンの状態を木の型とみなす
– q: 状態qから受理される木の型
– q1∧q2: 状態q1とq2の両方から受理できる木の型
q
Is Tree(G) accepted by A?
Does Tree(G) have type q0?
木に関する関数(文脈)の型 q1→ q2: functions that take a tree of type q1 and return a tree of q2
q2
q1 + = q1
q2
q1
木に関する関数(文脈)の型 q1∧q2 → q3: functions that take a tree of type q1∧q2 and return a tree of type q3
+ =
q1, q2 q3
q1 q2 q2
q3
q1 q2 q2
木に関する高階関数(文脈)の型 (q1 → q2) → q3: functions that take a function of type q1 → q2 and return a tree of type q3
+ =
q3
q1
q2
q1
q2
q3
q1
q2
Example
a: q0 →q0→q0
a q0
q0 q0
b q0
q1
Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
λx.a c (b x): q1→q0 b: q1→q0
a q0
q0 q0 c b q1
x
Γ, x:τ x :τ
型付け規則
Γ t1: τ1∧…∧τn → τ Γ t2:τi (i=1,..n) −−−−−−−−−−−−−−−−−−−−
Γ t1 t2:τ
Γ, x:τ1,..., x:τn t:τ −−−−−−−−−−−−−−−−−− Γ λx.t: τ1∧…∧τn → τ
Γ tk : τ (for every Fk:τ∈Γ)
−−−−−−−−−−−−−−−−−−−−−−−−− F1→t1,..., Fn → tn : Γ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−− a :q1 → … → qn → q
Γ, x:τ x :τ
型付け規則
Γ t1: τ1∧…∧τn → τ Γ t2:τi (i=1,..n) −−−−−−−−−−−−−−−−−−−−
Γ t1 t2:τ
Γ, x:τ1,..., x:τn t:τ −−−−−−−−−−−−−−−−−− Γ λx.t: τ1∧…∧τn → τ
Γ tk : τ (for every Fk:τ∈Γ)
−−−−−−−−−−−−−−−−−−−−−−−−− F1→t1,..., Fn → tn : Γ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−− a :q1 → … → qn → q
Γ, x:τ x :τ
a
…
q
q1 qn
型の導出例 Automaton:
q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
x:q0 |− a x:q0→q0 x:q1 |− (b x): q0 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
x:q0, x:q1 |− a x (b x): q0 −−−−−−−−−−−−−−−−−−−−−−− |− λx.a x (b x): q0∧q1→q0
|− a: q0→q0 →q0 x:q0 |− x: q0 −−−−−−−−−−−−−−−−−−−−−−−
|− b:q1→q0 x:q1|− x:q1 −−−−−−−−−−−−−−−−−−−−−−−
Γ, x:τ x :τ
型付け規則
Γ t1: τ1∧…∧τn → τ Γ t2:τi (i=1,..n) −−−−−−−−−−−−−−−−−−−−
Γ t1 t2:τ
Γ, x:τ1,..., x:τn t:τ −−−−−−−−−−−−−−−−−− Γ λx.t: τ1∧…∧τn → τ
Γ tk : τ (for every Fk:τ∈Γ)
−−−−−−−−−−−−−−−−−−−−−−−−− F1→t1,..., Fn → tn : Γ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−− a :q1 → … → qn → q
書き換え規則の型導出例 HORS: S → F c F → λx.a x (F (b x)) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
S:q0, F: q0∧q1→q0 |− λx.a x (F (b x)): q0∧q1→ q0
S:q0, F: q0∧q1→q0 |− F c : q0
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
|− S→ F c, F → λx.a x (F (b x)): S:q0, F: q0∧q1→q0
型システムの健全性と完全性 [K., POPL2009]
G = F1 →t1, ..., Fm →tm (with S=F1) A: Trivial automaton with initial state q0 TS(A): Intersection type system for A
A⊥: Extension of A with rule q →⊥ ε for each q
Tree(G) is accepted by A⊥ if and only if S has type q0 in TS(A), i.e. ∃Γ.(S:q0∈ Γ ∧ |− F1→t1,..., Fn → tn : Γ)
Γ, x:τ x :τ
再帰に関する別の定式化
Γ t1: τ1∧…∧τn → τ Γ t2:τi (i=1,..n) −−−−−−−−−−−−−−−−−−−−
Γ t1 t2:τ
Γ, x:τ1,..., x:τn t:τ −−−−−−−−−−−−−−−−−− Γ λx.t: τ1∧…∧τn → τ
t : τ (if t is the body of F)
−−−−−−−−−−−−−−−−−−−−−−−−− Γ F: τ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−− a :q1 → … → qn → q
型システムの健全性と完全性 G: HORS, A:自明オートマトンの場合: Tree(G) is accepted by A if and only if there is a possibly infinite derivation for |− S:q0 G: HORS, A:余自明オートマトン(*)の場合: Tree(G) is accepted by A if and only if there is a finite derivation for |− S:q0
(*)自明オートマトンの受理言語の補集合を受理するオートマトン
第二部の目次 高階モデル検査問題
– 高階再帰スキーム – 木オートマトン
高階モデル検査の型判定問題への帰着 – 自明木オートマトンの場合 – パリティ木オートマトンの場合
高階モデル検査アルゴリズム
高階モデル検査問題(一般の場合)
入力: G: 高階再帰スキーム(HORS) A: パリティ木オートマトン 出力: A が Gの生成する木Tree(G)を受理するか否か
(非決定性)パリティ木オートマトンの例
c a a
b c
a b b c
a b b b c
...
q0
q0 q0 q0 q0
q1 q0 q0
q1
q1
q0 q1
q1
q1
優先度関数: Ω(q0) = 1 Ω(q1) = 2
受理条件: すべてのパスにおいて、無限回出現する状態の優先度の 最大値が偶数 = すべての無限パスはbを含む
q0 →a q0 q0 q0 →b q1 q1 →b q1 q0 →c ε q1 →c ε
優先度を考慮した型 (q1, m) → q2: functions that take a tree of type q1 and return a tree of q2
q2
q1 + = q1
q2
q1
priority
Largest priority is m
優先度を考慮した型 ((q1, 3) → q2, 2) → (q1, 3) → q3 :
priority
+ =
q3
q1
q2
q1
q2 3
2 q3
q1
q2 3
優先度を考慮した型判断
x1: (θ1,m1),..., xn: (θn,mn) |− M: θ where θ ::= q | (θ1,m1)∧...∧(θn,mn)→ θ
x1:θ1
x2:θ2 xn:θn
m1
m2 mn the tree generated by M
型付け規則
Γ0 t1: (θ1,m1)∧…∧ (θn,mn) → θ Γi t2:θi (i=1,..n) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Γ0 ∪ Γ1↑m1 ∪ ...∪ Γn↑mn t1 t2:θ
Γ, x:τ1,..., x:τk t:θ k≤n −−−−−−−−−−−−−−−−−−−−−−−−−
Γ λx.t: τ1∧…∧τn → θ
x:(θ,Ω(θ)) x:θ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a : (q1, max(Ω(q1),Ω(q))) → … → (qn, max(Ω(qn),Ω(q))) → q
t : τ (if t is the body of F)
−−−−−−−−−−−−−−−−−−−−−−−−− Γ F: τ
型付け規則
Γ0 t1: (θ1,m1)∧…∧ (θn,mn) → θ Γi t2:θi (i=1,..n) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Γ0 ∪ Γ1↑m1 ∪ ...∪ Γn↑mn t1 t2:θ
Γ, x:τ1,..., x:τk t:θ k≤n −−−−−−−−−−−−−−−−−−−−−−−−−
Γ λx.t: τ1∧…∧τn → θ
x:(θ,Ω(θ)) x:θ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a : (q1, max(Ω(q1),Ω(q))) → … → (qn, max(Ω(qn),Ω(q))) → q
q a
… qn q1
t : τ (if t is the body of F)
−−−−−−−−−−−−−−−−−−−−−−−−− Γ F: τ
型付け規則
Γ0 t1: (θ1,m1)∧…∧ (θn,mn) → θ Γi t2:θi (i=1,..n) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Γ0 ∪ Γ1↑m1 ∪ ...∪ Γn↑mn t1 t2:θ
Γ, x:τ1,..., x:τk t:θ k≤n −−−−−−−−−−−−−−−−−−−−−−−−−
Γ λx.t: τ1∧…∧τn → θ
x:(θ,Ω(θ)) x:θ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a : (q1, max(Ω(q1),Ω(q))) → … → (qn, max(Ω(qn),Ω(q))) → q
t : τ (if t is the body of F)
−−−−−−−−−−−−−−−−−−−−−−−−− Γ F: τ
θ1 θ2 θn
m1 m2 mn
型付け規則
Γ0 t1: (θ1,m1)∧…∧ (θn,mn) → θ Γi t2:θi (i=1,..n) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Γ0 ∪ Γ1↑m1 ∪ ...∪ Γn↑mn t1 t2:θ
Γ, x:τ1,..., x:τk t:θ k≤n −−−−−−−−−−−−−−−−−−−−−−−−−
Γ λx.t: τ1∧…∧τn → θ
x:(θ,Ω(θ)) x:θ
q →a q1…qn ∈ ∆ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a : (q1, max(Ω(q1),Ω(q))) → … → (qn, max(Ω(qn),Ω(q))) → q
t : τ (if t is the body of F)
−−−−−−−−−−−−−−−−−−−−−−−−− Γ F: τ
t2 t2 t2
m1 m2 mn
t1
Γ1 Γ2 Γn Γ0
健全性と完全性
G: HORS, A:パリティ木オートマトン Tree(G) is accepted by A if and only if there is a possibly infinite derivation for |− S:q0 that satisfies a certain parity condition.
高階モデル検査の計算量 [K&Ong, LICS09]
O(|G|1+m/2 expn (aQm)1+ε)
|G| : HORS Gのサイズ n: Gのオーダー a: G中のシンボルのarityの最大値 Q: 交代性パリティオートマトンAの状態数 m: Aの優先度の数
他のパラメタを固定すれば、 Gのサイズに対して多項式時間
第二部の目次 高階モデル検査問題 高階モデル検査の型判定問題への帰着 高階モデル検査アルゴリズム
– ナイーブな不動点計算アルゴリズム – 実践的アルゴリズム(TRecSアルゴリズム) – 最新の動向
型システムの健全性と完全性 (自明オートマトンの場合)
G = F1 →t1, ..., Fm →tm (with S=F1) A: Trivial automaton with initial state q0 TS(A): Intersection type system for A
Tree(G) is accepted by A if and only if S has type q0 in TS(A), i.e. ∃Γ.(S:q0∈ Γ ∧ |− F1→t1,..., Fn → tn : Γ)
型システムの健全性と完全性
Tree(G) is accepted by A if and only if S has type q0 in TS(A), i.e. ∃Γ.(S:q0∈ Γ ∧ |− F1→t1,..., Fn → tn : Γ) if and only if ∃Γ.(S: q0 ∈ Γ ∧ ∀(Fk:τ)∈Γ. Γ|− tk : τ ) if and only if ∃Γ.(S: q0 ∈ Γ ∧ Γ = H( Γ) ) for H(Γ) = Fk:τ ∈ Γ | Γ |− tk:τ
Function to filter out invalid type bindings
モデル検査問題=型検査問題=不動点問題
Is there a fixedpoint of H greater than S:q0? (where H(Γ) = Fj:τ ∈ Γ | Γ |− tj:τ )
Γmax (the set of all type bindings)
S:q0
⊆ F:q0→q0,S:q0
⊆
⊆
⊆
...
... ...
∅
⊆
x fixedpoint of H
Naive Algorithm [K. POPL09] 1.Compute the greatest fixedpoint Γgfp of H (H(Γ) = Fj:τ ∈ Γ | Γ |− tj:τ ) 2.Check whether S:q0∈ Γgfp
Γmax (the set of all possible type bindings)
S:q0
⊆
F:q0→q0,S:q0
⊆
... ...
x fixedpoint
H(Γmax) x
H2(Γmax) x
H3(Γmax) x ...
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
Γmax= S:q0, S:q1, F:T→q0, F: T→q1, F:q0 →q0, F:q1 →q0, F: q0 ∧q1 →q0, F: q0 →q1, F: q1 →q1, F: q0 ∧q1 →q1
H(Γmax) = S:τ ∈ Γmax | Γmax |− F c:τ ∪ F:τ ∈ Γmax | Γmax |− λx.a x (F(b x)) :τ = S:q0, S:q1, F: q0 →q0, F: q0∧q1 →q0 H2(Γmax) = S:q0, F: q0∧q1 →q0
H3(Γmax) = S:q0, F: q0∧q1 →q0 = H2(Γmax)
Naive Algorithm [K. POPL09] 1.Compute the greatest fixedpoint Γgfp of H (H(Γ) = Fj:τ ∈ Γ | Γ |− tj:τ ) 2.Check whether S:q0∈ Γgfp
Γmax (the set of all possible type bindings)
S:q0
⊆
F:q0→q0,S:q0
⊆
... ...
x fixedpoint
H(Γmax) x
H2(Γmax) x
H3(Γmax) x ...
Drawbacks: - Huge cost for computing H - Huge number of iterations (both as huge as |Γmax| = O(|G|× ) )
(AQ)1+ε 2 .. 2 2 A: largest arity
Q: automaton size
How large is Γmax?
sort # of types for each sort (Q=q0,q1,q2,q3)
o (trees) 4 (q0,q1,q2,q3)
o → o 24 ×4 = 64 (∧S→ q, with S∈2Q, q∈Q)
(o→o) → o 264 ×4 = 266
((o→o) → o) → o 266 10000000000000000000 2 ×4 > 10
Γmax: the set of all possible type bindings for non-terminals
(A|Q|)1+ε 2 .. 2 2
|Γmax| = O(|G|× )
第二部の目次 高階モデル検査問題 高階モデル検査の型判定問題への帰着 高階モデル検査アルゴリズム
– ナイーブな不動点計算アルゴリズム – 実践的アルゴリズム(TRecSアルゴリズム) – 最新の動向
Practical Algorithms [K. PPDP09] [K.FoSSaCS11]
1.Guess a type environment Γ0 2.Compute greatest fixedpoint Γ smaller than Γ0 3.Check whether S:q0∈ Γ 4. Repeat 1-3 until the property is proved or refuted.
Γmax (the set of all possible type bindings)
S:q0
... ...
H(Γ0) x H2(Γ0) x
...
Γ0 x
Practical Algorithms [K. PPDP09] [K.FoSSaCS11]
Γmax (the set of all possible type bindings)
S:q0
... ...
H(Γ0) x H2(Γ0) x
...
Γ0 x
1.Guess a type environment Γ0 2.Compute greatest fixedpoint Γ smaller than Γ0 3.Check whether S:q0∈ Γ 4. Repeat 1-3 until the property is proved or refuted.
How to guess Γ0? PPDP09 algorithm
– Reduce a recursion scheme a finite number of steps
– Observe how each function is used and express it as types
FoSSaCS11 algorithm – Like PPDP09, but avoid
reductions by using game semantic interpretation of types
Γmax
S:q0
... ...
H(Γ0) x H2(Γ0) x
...
Γ0 x
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Γ0 : S: q0
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Γ0 : S: q0
F: ? → q0
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Γ0 : S: q0
F: q0 ∧ q1
→ q0
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Γ0 : S: q0
F: q0 ∧ q1
→ q0 F: q0 → q0
Example HORS: S → F c F → λx.a x (F (b x))
(S:o, F: o→o) Automaton: q0 →a q0 q0 q0 →b q1 q1 →b q1
q0 →c ε q1 →c ε
→ F c
c F(b c)
→ a
c a
→ a
b F(b(b c)) c
S q0 q0 q0
q0 q0
q0
q0 q0
q0
q1
q0
Γ0 : S: q0
F: q0 ∧ q1
→ q0 F: q0 → q0
F: T → q0
Practical Algorithms [K. PPDP09] [K.FoSSaCS11]
1.Guess a type environment Γ0 2.Compute greatest fixedpoint Γ smaller than Γ0 3.Check whether S:q0∈ Γ 4. Repeat 1-3 until the property is proved or refuted.
S:q0 ...
H(Γ0) x H2(Γ0) x
...
Γ0 x
Γ0 = S: q0, F: q0 ∧ q1→ q0, F: q0 → q0 , F: T → q0 H(Γ0) = Fj:τ ∈ Γ0 | Γ0 |− tj:τ
= S: q0, F: q0 ∧ q1→ q0, F: q0 → q0 H2(Γ0) = S: q0, F: q0 ∧ q1→ q0
H3(Γ0) = S: q0, F: q0 ∧ q1→ q0
TRecS [K. PPDP09] http://www-kb.is.s.u-tokyo.ac.jp/~koba/trecs/
The first model checker for recursion schemes
Based on the PPDP09 algorithm, with certain additional optimizations
第二部の目次 高階モデル検査問題 高階モデル検査の型判定問題への帰着 高階モデル検査アルゴリズム
– ナイーブな不動点計算アルゴリズム – 実践的アルゴリズム(TRecSアルゴリズム) – 最新の動向
最新のモデル検査器/アルゴリズム
HorSat [Broadbent&K, CSL13]
– エラーに到達しうる項の集合(の型表現)を後ろ向きに推論 – フロー解析により無駄な後ろ向き伝搬を回避
(cf. CSHORe [Broadbent+, ICFP13])
Preface [Ramsay+, HOPA13]
– 抽象簡約列から(自明および余自明オートマトンに対する) 型を推論 (cf. TRecSのconcrete簡約列からの型の推論)
– 推論された型を用いて抽象化を徐々に改良
APTRecS(仮名) [Fujima+, APLAS13] – TRecSアルゴリズムを交代性パリティオートマトンに拡張
多くの例でTRecSを 上回る性能
第二部まとめ 高階モデル検査問題は共通型システムにおける 型検査問題に帰着可能
高階モデル検査の計算量は、他のパラメタを固定すればHORSのサイズに対して多項式時間 – モデルが有限状態システムであっても、高階関数を用いたコンパクトな表現により超指数的高速化が可能
Order-n HORS Rm,n
S → F0 Gn-1 ... G2 G1 G0
F0 f → F1 (F1 f) ... Fm-1 f → Fm (Fm f) Fm f → Gn f Gn f z → f (f z) ... G2 f z → f (f z) G1 z → a z G0 → c
m 2 .. 2 2
S →* a (G0)
n
n-EXPTIME algorithm for order-n HORS ≈ Polynomial time algorithm for finite state model checking
Order-n HORS Rm,n
S → F0 Gn-1 ... G2 G1 G0
F0 f → F1 (F1 f) ... Fm-1 f → Fm (Fm f) Fm f → Gn f Gn f z → f (f z) ... G2 f z → f (f z) G1 z → a z G0 → c
m 2 .. 2 2
S →* a (G0)
n
fixed-parameter polynomial time algorithm for order-n HORS > Polynomial time algorithm for finite state model checking
第二部まとめ 高階モデル検査問題は共通型システムにおける 型検査問題に帰着可能
高階モデル検査の計算量は、他のパラメタを固定すればHORSのサイズに対して多項式時間 – モデルが有限状態システムであっても、高階関数を用いたコンパクトな表現により超指数的高速化が可能
型判定問題への帰着を通して実践的に効率のよい 高階モデル検査器を構築可能
最新の高階モデル検査器は、共通型に加え、 オートマトン、フロー解析、抽象解釈などの技術を 融合してさらなる高速化を実現
第二部に関連する今後の課題 高階モデル検査器のさらなる高速化
– 共通型の爆発の回避 • BDD表現、union型を併用、...
– 最新の(自明オートマトン用)アルゴリズム(HorSat, Preface)のパリティオートマトンへの拡張
– 有限状態モデル検査やプッシュダウンオートマトンを 効率上もsubsumeできるか?
「高階モデル検査が実践的に効率よく解ける」ことの理論的保証の強化
Why HO model checking works despite k-EXPTIME completeness? Non-answer: average-case complexity (for uniform input distribution)
<average time comlexity>
= −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 2m
= k-EXP(m) (for order-k HORS, k>1)
Σ <time for solving x> x∈0,1m
Why HO model checking works despite k-EXPTIME completeness? Fact:
Given intersection types as certificates, it is easy to validate them
Hypothesis: Many HO model checking problems tend to have small certificates (although certificates are k-fold exponential in the worst case)
⇒ Similar to NP problems
Empirical Evidence for “Small Certificate” Hypothesis?
order rules states #cert. |Γmax| Twofiles 4 11 5 37 >1010^10^49
TwofilesE 4 12 5 42 >1010^10^49
FileOcamlC 4 23 4 41 >1010^10^20
Lock 4 11 4 41 >1010^10^20
Order5 5 9 5 43 >1010^10^10^48
mc91 4 49 1 115 >1010^80
xhtml 2 64 50 101 >10753
exp4-5-3 4 12 3 137 >1010^10^7
#cert: the number of type bindings in the certificate found by a model checker
Open Question about “Small Certificate” Hypothesis
Complexity-Theoretic Support? “q(n)% of HO model checking problems of size n have certificates of size p(n)” (If p(n) is polynomial, q(n) % of the problems can be solved in polynomial time)
第2部に関する参考文献 無限木用のオートマトン、時相論理
– Erich Grädel, Wolfgang Thomas, Thomas Wilke (Eds.): Automata, Logics, and Infinite Games: A Guide to Current Research [outcome of a Dagstuhl seminar, February 2001]. Springer 2002 ISBN 3-540-00388-6
高階モデル検査の型検査への帰着 – Naoki Kobayashi: Model Checking Higher-Order Programs. J. ACM
60(3): 20 (2013) – Naoki Kobayashi, C.-H. Luke Ong: A Type System Equivalent to
the Modal Mu-Calculus Model Checking of Higher-Order Recursion Schemes. LICS 2009: 179-188
最新の高階モデル検査アルゴリズム – Christopher Broadbent and Naoki Kobayashi, Saturation-Based
Model Checking of Higher-Order Recursion Schemes, CSL 13. – Steven J. Ramsay, Robin P. Neatherway, C.-H. Luke Ong,
An Abstraction Refinement Approach to Higher-Order Model Checking, HOPA 2013.