Revision ebafbc92ad9b52ae775ab3bd4f9ddbb32bd51e73 authored by Pierre-Yves Strub on 05 July 2014, 22:13:30 UTC, committed by Pierre-Yves Strub on 05 July 2014, 22:13:30 UTC
1 parent 7c527a4
AdvAbsVal.ec
(* --------------------------------------------------------------------
* Copyright IMDEA Software Institute / INRIA - 2013, 2014
* -------------------------------------------------------------------- *)
require import Real.
module type Adv = {
proc main () : bool
}.
module Neg_main (A:Adv) = {
proc main () : bool = {
var b : bool;
b = A.main ();
return !b;
}
}.
equiv Neg_A (A<:Adv) :
Neg_main(A).main ~ A.main : ={glob A} ==> res{1} = !res{2}.
proof -strict.
proc *;inline{1} Neg_main(A).main.
by wp;call (_:true).
qed.
lemma Neg_A_Pr (A<:Adv) &m:
Pr[Neg_main(A).main() @ &m : res] = Pr[A.main() @ &m : !res].
proof -strict.
byequiv (Neg_A A) => //.
qed.
lemma Neg_A_Pr_minus (A<:Adv) &m:
islossless A.main =>
Pr[Neg_main(A).main() @ &m : res] = 1%r - Pr[A.main() @ &m : res].
proof -strict.
intros Hl; rewrite (Neg_A_Pr A &m); rewrite Pr[mu_not]; congr => //.
by byphoare Hl.
qed.
lemma abs_val :
forall (P:real -> bool),
(forall &m (A<:Adv), P (Pr[A.main() @ &m : res] - 1%r/2%r)) =>
forall &m (A<:Adv), islossless A.main =>
P (`|Pr[A.main() @ &m : res] - 1%r/2%r| ).
proof -strict.
intros P HP &m A Hl.
case (Pr[A.main() @ &m : res] <= 1%r / 2%r) => Hle.
cut H := HP &m (Neg_main(A)).
cut H1 := Neg_A_Pr_minus A &m _; [trivial | smt].
cut H := HP &m A;smt.
qed.
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...