-
WiSE.implem.bugfinder_proof
-
-
-
-
-
Correctness proof of the bugfinder
-
-
-
-
Soundness and Completness of expand w.r.t sym_step
-
-
-
-
-
-
Lemma map_in:
-
forall A B (
f :
A -> B) (
l :
list A)
b,
-
In b (
List.map f l)
-> exists a, In a l /\ b = f a.
-
Proof.
-
intros.
induction l;
try easy.
-
destruct H as [<- |
H].
- -
repeat econstructor.
- -
specialize (
IHl H)
as (
a' &
Ha' & ->).
-
exists a'.
split;
auto.
now right.
-
Qed.
-
-
-
-
-
-
-
Theorem expand_sound:
-
forall path env prog t,
-
In t (
expand path env prog)
-> sym_step ((path, env), prog) t.
-
Proof.
-
intros path env prog [[
path' env']
prog']
Hin.
-
induction prog in path',
env',
prog',
Hin |-*;
subst;
try easy.
- -
destruct Hin as [[=<-<-<-] | [ [=<-<-<-] | [] ]];
constructor.
- -
destruct prog1;
try easy.
- +
destruct Hin as [[=<-<-<-] | []].
now econstructor.
- +
pose proof (
map_in _ _ _ _ _ Hin)
as ([[
path2 env2]
prog3] & [
H1 [=->->->]]).
-
specialize (
IHprog1 _ _ _ H1).
-
now constructor.
- +
pose proof (
map_in _ _ _ _ _ Hin)
as ([[
path2 env2]
prog3] & [
H1 [=->->->]]).
-
specialize (
IHprog1 _ _ _ H1).
-
now constructor.
- +
pose proof (
map_in _ _ _ _ _ Hin)
as ([[
path2 env2]
prog3] & [
H1 [=->->->]]).
-
specialize (
IHprog1 _ _ _ H1).
-
now constructor.
- +
pose proof (
map_in _ _ _ _ _ Hin)
as ([[
path2 env2]
prog3] & [
H1 [=->->->]]).
-
specialize (
IHprog1 _ _ _ H1).
-
now constructor.
- -
destruct Hin as [[=<-<-<-] | []].
now constructor.
- -
destruct Hin as [[=<-<-<-] | [[=<-<-<-]| []]];
now constructor.
-
Qed.
-
-
-
-
-
-
-
-
-
expand spawns 0, 1 or 2 tasks
-
-
-
Theorem expand_inv:
-
forall path env prog,
-
(expand path env prog = []) \/
-
(exists s, expand path env prog = [s]) \/
-
(exists s1 s2, expand path env prog = [s1; s2]).
-
Proof.
-
intros.
induction prog.
- -
now left.
- -
now right;
right;
repeat econstructor.
- -
destruct IHprog1 as [
IH | [(
s &
Hs) | (
s1 &
s2 &
Hs)]].
- +
destruct prog1;
simpl in *;
try easy.
-
now right;
left;
repeat econstructor.
rewrite IH.
-
now left.
-
now left.
- +
destruct prog1;
simpl in *;
try easy.
-
right.
repeat econstructor.
now rewrite Hs.
-
right.
repeat econstructor.
- +
destruct prog1;
simpl in *;
try easy.
-
now right;
right;
repeat econstructor.
-
now right;
right;
repeat econstructor;
rewrite Hs.
-
right;
right;
repeat econstructor;
rewrite Hs.
- -
now right;
left;
repeat econstructor.
- -
now left.
- -
now right;
right;
repeat econstructor.
-
Qed.
-
-
-
-
-
-
Eager model of run
- The
run function that executes the main loop of the bugfinder
- generates a lazy stream. Lazy streams are defined co-inductively
- which make them somwhat hard to reason about. To ease the proofs, we
- provide an eager implementation
run_n of
run that simulates the behavior of
-
run for
n steps of computation. We then relate the 2 functions by a theorem
run_run_n.
-
-
-
-
run_eq can be used to destruct applications of the cofixpoint
run
-
-
-
-
-the
run [] is a fixpoint for
shift i.e.
- once the task list is empty,
run loops indefinitely
- in a state where the task list remains empty
-
-
-
-
-
-Relation between
run and its eager model
run_n.
-
run_n n l computes the task list after
n iterations
run l
-
-
-
-
-
-After
List.length l1 iterations, the task list of
run (l1 ++ l2)
- starts with
l2
-
-
-
-
-
-After
1 + List.length l1 iterations, the task list of
run (t::l1 ++ l2)
- starts with
l2 followed with the task spawed by executing
t
-
-
-
-
-
-
LTL Specification Predicates
-
-
-
-
- In the remainder of this file, we will use a shallow embedding of the
LTL
- logic to write specifications over lazy streams.
- We start by defining some usefull
LTL predicates.
-
-
-
- The current state in the stream is
sym_steps reachable from a state in
l
-
-
-
-
-The current state in the stream is s
-
-
-
-
-
Soundess of run
-
-
-
-
run is sound with respect to
sym_exec:
- all states generate by the stream
run l,
- are reachable from
l
-
-
-
-
Theorem run_sound:
-
forall l,
-
run l ⊨ □ reachable_from l.
-
Proof.
-
intros l n.
rewrite run_run_n.
-
induction n in l |-*.
- -
simpl in *.
destruct l as [| [[
path env]
prog]];
try easy.
-
repeat econstructor.
- -
destruct l as [| [[
path env]
prog]
l];
try easy.
-
specialize (
IHn (
l ++ expand path env prog)).
-
simpl.
destruct run_n as [| [[
path1 env1]
prog1]]
eqn:
Heq;
try easy.
-
destruct IHn as [[[
path2 env2]
prog2] [[
H |
H]%
in_app_iff Hsteps]].
- +
eexists.
split;
eauto.
now right.
- +
pose proof (
expand_sound _ _ _ _ H).
-
eexists.
split.
now left.
-
econstructor;
eauto.
-
Qed.
-
-
-
-
-
-
Completeness of run
-
-
-
-
run is complete for
sym_step:
- if
s is the next value generated by
run l, then
- all the direct sucessors of
s are eventually generated
-
-
-
-
-
-
run [s] immediately generates
s
-
-
-
-
-
run is complete for
sym_steps:
- At any point in time, if
s is generated by
run l, then
- all the
sym_steps sucessors of
s are eventually generated
-
-
-
-
-
-
run is a complete wau to compute the
sym_steps sucessors
- of any state
s:
- starting with the task
[s],
run [s] eventually generates
- all
sym_steps sucessors of
s
-
-
-
-
-
-
fin_bugs is sound:
- For any program
p,
find_bugs p
- emits warnings ONLY if it found a bug in
p
-
-
-
-
-
-
fin_bugs is complete:
- For any program
p, if it has a bug,
-
find_bugs p will eventually find it
-
-
-
-
-
-A symbolic state denotes a valid bug in
- p if all states in its concretization are bugs
-
-
-
-
-
-A status message is valid wrt prog
p
- if it is a
BugFound message reporting a
ValidBug
- or any other kind of status message
-
-
-
-
-
-
Main Correctness Theorem !!!!
-
-
-
- THE MAIN RESULT:
-
find_bugs p is correct !
- This statement means 2 things:
- (1) For any bug in the program
p, the bug is eventually going
- to be discovered
- (2) If a 'bugy path' is discovered, then any concrete
- instance of this path is a bug
-
-
-
-
-
-
-
-
-
-"termination" of the bugfinding loop:
- If at any point in time
find_bugs p emits
- a
Finished token, then the exploration of
p
- terminated. We encode this property by
- asserting that after the first
Finished token,
- the only message that the loop will ever send is
Finished
- (i.e. it cannot find new bugs afterward)
-
-
-
-