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 disproving fair-termination of higher-order functional programs cf. Prove Fair-termination [Murase+ POPL16] includes LTL properties Verification of π -regular properties can be reduced to that of fair-termination [Vardi APAL91]
3 Outline β’ Termination & Fair-Termination β’ Importance of Fair-Termination β’ Our Method β’ Implementation and Experiments β’ Related Work β’ Conclusion
4 Outline β’ Termination & Fair-Termination β’ Importance of Fair-Termination β’ Our Method β’ Implementation and Experiments β’ Related Work β’ Conclusion
5 Plain Termination Program π is terminating β Every execution eventually terminates main main Terminating Not Terminating
6 Fair-Termination Program π is fair-terminating β Every fair execution eventually terminates An example of fairness in this talk: If A occurs infinitely often, so does B Fair-Terminating Not Fair-Terminating
7 Outline β’ Termination & Fair-Termination β’ Importance of Fair-Termination β’ Our Method β’ Implementation and Experiments β’ Related Work β’ Conclusion
8 Termination assuming Randomness let rand_int () = * int Terminating, assuming let rec rand_pos () = randomness of * int let x = rand_int () in if 0 < x then x else rand_pos () let main = rand_pos ()
9 Termination assuming Randomness let rand_int () = * int Terminating, assuming let rec rand_pos () = randomness of * int let x = rand_int () in if 0 < x then x Q. else rand_pos () How to incorporate randomness with let main = rand_pos () termination verification?
10 Termination assuming Randomness let rand_int () = let r = * int in if 0 < r then ( event B; r) Insert event expressions 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 Termination assuming Randomness let rand_int () = If * int never returns a positive integer, let r = * int in execution is unfair if 0 < r then A β A β A β A ββ¦ ( event B; r) else ( event A; r) let rec rand_pos () = let x = rand_int () in if 0 < x then Termination assuming x else randomness rand_pos () β Fair-termination let main = rand_pos ()
12 Our Goal (Again) Automated method for disproving fair-termination of higher-order functional programs cf. Prove Fair-termination [Murase+ POPL16] includes LTL properties Verification of π -regular properties can be reduced to that of fair-termination [Vardi APAL91]
13 Our Goal (Again) Automated method for disproving fair-termination of higher-order functional programs Proving the existence of fair infinite executions includes LTL properties Verification of π -regular properties can be reduced to that of fair-termination [Vardi APAL91]
14 Outline β’ Termination & Fair-Termination β’ Importance of Fair-Termination β’ Our Method β’ Overview of Method β’ Step 1, Step 2, Step 3 β’ Properties of Our Method β’ Implementation and Experiments β’ Related Work β’ Conclusion
15 Overview of Method Fairness Functional Constraint Program Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Model Checking Discovery Tree Tree Generating Automaton Program Counterexample Step 2 οΌ Higher-Order reject Model Checking An extension of a method for accept disproving plain termination Fair infinite executions exist! [Kuwahara+ CAV15]
16 Overview of Method Computation Tree Fairness Functional Fair infinite Constraint Program paths exist Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Model Checking Discovery Tree Tree Generating Automaton Program Counterexample Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
17 Overview of Method Computation Tree Fairness Functional Fair infinite Constraint Program paths exist Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Model Checking Discovery Abstracted Tree Tree Tree Generating Automaton Program Counterexample Accepted by the automaton Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
18 Overview of Method Computation Tree Fairness Functional Fair infinite Constraint Program paths exist Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Sufficient condition Model Checking Discovery Abstracted Tree Tree Tree Generating Automaton Program Counterexample Accepted by the automaton Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
19 Overview of Method Abstracted Tree Fairness Functional Constraint Program Decide whether the automaton Step 1: Reduction to Step 3: accepts the Predicates Predicate Higher-Order abstracted tree Model Checking Discovery Tree Tree Generating Automaton Program Counterexample Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
20 Overview of Method Refine abstraction by Fairness Functional Constraint using counterexamples Program Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Model Checking Discovery Tree Tree Generating Automaton Program Counterexample Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
21 Overview of Method Fairness Functional Constraint Program Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Model Checking Discovery Tree Tree Generating Automaton Program Counterexample Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
22 Overview of Method Computation Tree Fairness Functional Fair infinite Constraint Program paths exist Step 1: Reduction to Step 3: Predicates Predicate Higher-Order Sufficient condition Model Checking Discovery Abstracted Tree Tree Tree Generating Automaton Program Counterexample Accepted by the automaton Step 2 οΌ Higher-Order reject Model Checking accept Fair infinite executions exist!
23 Two Branching Nodes in Abstracted Trees [Kuwahara+ CAV15] β -node β’ Represents inherent non-determinism in programs β’ e.g. random integer, inputs β’ We should check if there exists a fair infinite branch β -node β’ Represents non-determinism introduced by abstraction β’ We should check if every branch is fair and infinite
24 Two Branching Nodes in Abstracted Trees [Kuwahara+ CAV15] π Abstract by π = π, π < π πΈ let f x = let y = x+1 in let f b x=0 = if 0 < y then if b x=0 then β (B(g true)) event B; g y else else β (B(g true), A(g false)) event A; g y in β (f true, f false) in f * int Tree ( πΈ ) Computation tree of π * β x=0 Β¬ (x=0) γ»γ»γ» γ»γ»γ» β β if if if if Β¬ (0<y) 0<y 0<y B A B A A B B
25 β - node: Inherent Non-Determinism π Abstract by π = π, π < π πΈ let f x = let y = x+1 in let f b x=0 = if 0 < y then if b x=0 then β (B(g true)) event B; g y else else β (B(g true), A(g false)) event A; g y in β (f true, f false) in f * int merged Tree ( πΈ ) Computation tree of π β x=-1 * x=0 Β¬ (x=0) x=0 γ»γ»γ» γ»γ»γ» x=-2 x=1 β β if if if if Β¬ (0<y) 0<y 0<y B A B A A B B
26 β - node: Inherent Non-Determinism π Abstract by π = π, π < π πΈ let f x = let y = x+1 in let f b x=0 = if 0 < y then if b x=0 then β (B(g true)) event B; g y else else Check if either branch is β (B(g true), A(g false)) event A; g y in β (f true, f false) in f * int fair and infinite Tree ( πΈ ) Computation tree of π β x=-1 * x=0 Β¬ (x=0) x=0 γ»γ»γ» γ»γ»γ» x=-2 x=1 β β if if if if Β¬ (0<y) 0<y 0<y B A B A A B B
27 Non-Determinism β - node: introduced by Abstraction π Abstract by π = π, π < π πΈ let f x = let y = x+1 in let f b x=0 = if 0 < y then if b x=0 then β (B(g true)) event B; g y else else β (B(g true), A(g false)) event A; g y in β (f true, f false) in f * int Tree ( πΈ ) Computation tree of π * β x=0 Β¬ (x=0) γ»γ»γ» γ»γ»γ» else β then β if if if if Β¬ (0<y) else 0<y then 0<y B A A B A B B
28 Non-Determinism β - node: introduced by Abstraction π Abstract by π = π, π < π πΈ let f x = let y = x+1 in let f b x=0 = if 0 < y then if b x=0 then β (B(g true)) event B; g y else else β (B(g true), A(g false)) event A; g y in β (f true, f false) in f * int Check if both branches are Tree ( πΈ ) Computation tree of π fair and infinite * β x=0 Β¬ (x=0) γ»γ»γ» γ»γ»γ» else β then β if if if if Β¬ (0<y) else 0<y then 0<y B A A B A B B
29 Parity Tree Automaton π΅ π· If Tree ( πΈ ) is accepted by π΅ π· , π is NOT fair-terminating Tree ( πΈ ) is accepted by π΅ π· if β β’ β -node Β¬ (x=0) x=0 Some branches have fair infinite paths β β Β¬ (0<y) 0<y 0<y β’ β -node A B B All branches have fair infinite paths
Recommend
More recommend