Automatically Disproving Fair Termination of Higher-Order Functional Programs
Keiichi Watanabe, Ryosuke Sato Takeshi Tsukada, Naoki Kobayashi The University of Tokyo
September 20th, 2016
ICFP 2016 at Nara
1
Fair Termination of Higher-Order Functional Programs Keiichi - - PowerPoint PPT Presentation
Automatically Disproving Fair Termination of Higher-Order Functional Programs Keiichi Watanabe , Ryosuke Sato Takeshi Tsukada, Naoki Kobayashi The University of Tokyo September 20 th , 2016 ICFP 2016 at Nara 1 2 Our Goal Automated method for
1
2
3
4
5
6
7
8 let rand_int () = *int let rec rand_pos () = let x = rand_int () in if 0 < x then x else rand_pos () let main = rand_pos ()
9
let rand_int () = *int let rec rand_pos () = let x = rand_int () in if 0 < x then x else rand_pos () let main = rand_pos ()
10 let rand_int () = let r = *int in if 0 < r then (event B; r) else (event A; r) let rec rand_pos () = let x = rand_int () in if 0 < x then x else rand_pos () let main = rand_pos ()
11 let rand_int () = let r = *int in if 0 < r then (event B; r) else (event A; r) let rec rand_pos () = let x = rand_int () in if 0 < x then x else rand_pos () let main = rand_pos ()
12
13
14
15
An extension of a method for disproving plain termination [Kuwahara+ CAV15]
16
Computation Tree
17
Computation Tree
18
Computation Tree
19
20
21
22
Computation Tree
23
Tree(πΈ)
let f x = let y = x+1 in if 0 < y then event B; g y else event A; g y in f *int
let f bx=0 = if bx=0 then β(B(g true)) else β(B(g true), A(g false)) in β(f true, f false)
Computation tree of π
Abstract by π = π, π < π 24
if A if A if B if B γ»γ»γ» γ»γ»γ» 0<y x=0 β β β B A B Β¬(x=0) 0<y Β¬(0<y)
Tree(πΈ)
let f x = let y = x+1 in if 0 < y then event B; g y else event A; g y in f *int
let f bx=0 = if bx=0 then β(B(g true)) else β(B(g true), A(g false)) in β(f true, f false)
Computation tree of π
Abstract by π = π, π < π 25
if A if A if B if B γ»γ»γ» γ»γ»γ»
0<y
β β B A B 0<y Β¬(0<y)
Tree(πΈ)
let f x = let y = x+1 in if 0 < y then event B; g y else event A; g y in f *int
let f bx=0 = if bx=0 then β(B(g true)) else β(B(g true), A(g false)) in β(f true, f false)
Computation tree of π
Abstract by π = π, π < π 26
if A if A if B if B γ»γ»γ» γ»γ»γ»
0<y
β β B A B 0<y Β¬(0<y)
Tree(πΈ)
let f x = let y = x+1 in if 0 < y then event B; g y else event A; g y in f *int
let f bx=0 = if bx=0 then β(B(g true)) else β(B(g true), A(g false)) in β(f true, f false)
Computation tree of π
Abstract by π = π, π < π 27
if
if A if B
if
γ»γ»γ» Β¬(x=0) 0<y Β¬(0<y) 0<y x=0 β β B
γ»γ»γ»
Tree(πΈ)
let f x = let y = x+1 in if 0 < y then event B; g y else event A; g y in f *int
let f bx=0 = if bx=0 then β(B(g true)) else β(B(g true), A(g false)) in β(f true, f false)
Computation tree of π
Abstract by π = π, π < π 28
if
if A if B
if
γ»γ»γ» Β¬(x=0) 0<y Β¬(0<y) 0<y x=0 β β B
γ»γ»γ»
Β¬(x=0) 0<y Β¬(0<y) 0<y x=0 β β β B A B
29
Β¬(x=0) 0<y Β¬(0<y) 0<y x=0 β β β B A B
30
31
Output of Step 1 32
Output of Step 1 33
34
35
[Carayol&Serre LICS12] [Tsukada&Ong LICS14]
36
generates
37
38
( )
39
( )
End
40
( )
End
41
( )
End
42
Aπ
43
Aπ
44
45 [Murase+ POPL16]
46
47
48
49
(predicates given by hand)
50
51
52
53
54