Skip to content

Commit b7442f1

Browse files
committed
Update rule
1 parent cd5f851 commit b7442f1

File tree

12 files changed

+997
-986
lines changed

12 files changed

+997
-986
lines changed

examples/exception.ec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ exception tata.
55

66
module M ={
77
proc truc (x:int) : int = {
8-
raise toto;
8+
if (x = 3) {raise toto;} else{ x <- 5; }
99
return x;
1010
}
1111
}.
1212

1313
lemma truc :
14-
hoare [M.truc : true ==> (res = 1) | toto:(res = 1) |tata:(res=2) ].
14+
hoare [M.truc : true ==> (4 < res) | toto:(res = 3) |tata:(res=2) ].
1515
proof.
16-
proc.
17-
wp.
16+
proc.
17+
conseq (: _ ==> x = 5).
18+
+ smt.
19+
+ auto.
20+
qed.

src/ecPrinting.ml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,15 +2978,17 @@ let pp_hoareF (ppe : PPEnv.t) ?prpo fmt hf =
29782978
let pp_hoareS (ppe : PPEnv.t) ?prpo fmt hs =
29792979
let ppef = PPEnv.push_mem ppe ~active:true hs.hs_m in
29802980
let ppnode = collect2_s ppef hs.hs_s.s_node [] in
2981-
let ppnode = c_ppnode ~width:ppe.PPEnv.ppe_width ppef ppnode
2982-
in
2983-
Format.fprintf fmt "Context : %a@\n%!" (pp_memtype ppe) (snd hs.hs_m);
2984-
Format.fprintf fmt "@\n%!";
2985-
Format.fprintf fmt "%a%!" (pp_pre ppef ?prpo) hs.hs_pr;
2986-
Format.fprintf fmt "@\n%!";
2987-
Format.fprintf fmt "%a" (pp_node `Left) ppnode;
2988-
Format.fprintf fmt "@\n%!";
2989-
Format.fprintf fmt "%a%!" (pp_post ppef ?prpo) hs.hs_po
2981+
let ppnode = c_ppnode ~width:ppe.PPEnv.ppe_width ppef ppnode in
2982+
2983+
Format.fprintf fmt "Context : %a@\n%!" (pp_memtype ppe) (snd hs.hs_m);
2984+
Format.fprintf fmt "@\n%!";
2985+
Format.fprintf fmt "%a%!" (pp_pre ppef ?prpo) hs.hs_pr;
2986+
Format.fprintf fmt "@\n%!";
2987+
Format.fprintf fmt "%a" (pp_node `Left) ppnode;
2988+
Format.fprintf fmt "@\n%!";
2989+
Format.fprintf fmt "%a%!" (pp_post ppef ?prpo) hs.hs_po;
2990+
Format.fprintf fmt "@\n%!";
2991+
Format.fprintf fmt "%a%!" (pp_poe ppef ?prpo) hs.hs_poe
29902992

29912993
(* -------------------------------------------------------------------- *)
29922994
let pp_eHoareF (ppe : PPEnv.t) ?prpo fmt hf =

src/phl/ecPhlApp.ml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,52 +35,52 @@ let t_ehoare_app_r i f tc =
3535
let t_ehoare_app = FApi.t_low2 "hoare-app" t_ehoare_app_r
3636

3737
(* -------------------------------------------------------------------- *)
38-
let t_bdhoare_app_r_low _i (_phi, _pR, _f1, _f2, _g1, _g2) _tc = assert false
39-
(* let env = FApi.tc1_env tc in *)
40-
(* let bhs = tc1_as_bdhoareS tc in *)
41-
(* let s1, s2 = s_split env i bhs.bhs_s in *)
42-
(* let s1, s2 = stmt s1, stmt s2 in *)
43-
(* let nR = f_not pR in *)
44-
(* let cond_phi = f_hoareS bhs.bhs_m bhs.bhs_pr s1 phi in *)
45-
(* let condf1 = f_bdHoareS_r { bhs with bhs_s = s1; bhs_po = pR; bhs_bd = f1; } in *)
46-
(* let condg1 = f_bdHoareS_r { bhs with bhs_s = s1; bhs_po = nR; bhs_bd = g1; } in *)
47-
(* let condf2 = f_bdHoareS_r *)
48-
(* { bhs with bhs_s = s2; bhs_pr = f_and_simpl phi pR; bhs_bd = f2; } in *)
49-
(* let condg2 = f_bdHoareS_r *)
50-
(* { bhs with bhs_s = s2; bhs_pr = f_and_simpl phi nR; bhs_bd = g2; } in *)
51-
(* let bd = *)
52-
(* (f_real_add_simpl (f_real_mul_simpl f1 f2) (f_real_mul_simpl g1 g2)) in *)
53-
(* let condbd = *)
54-
(* match bhs.bhs_cmp with *)
55-
(* | FHle -> f_real_le bd bhs.bhs_bd *)
56-
(* | FHeq -> f_eq bd bhs.bhs_bd *)
57-
(* | FHge -> f_real_le bhs.bhs_bd bd in *)
58-
(* let condbd = f_imp bhs.bhs_pr condbd in *)
59-
(* let (ir1, ir2) = EcIdent.create "r", EcIdent.create "r" in *)
60-
(* let (r1 , r2 ) = f_local ir1 treal, f_local ir2 treal in *)
61-
(* let condnm = *)
62-
(* let eqs = f_and (f_eq f2 r1) (f_eq g2 r2) in *)
63-
(* f_forall *)
64-
(* [(ir1, GTty treal); (ir2, GTty treal)] *)
65-
(* (f_hoareS bhs.bhs_m (f_and bhs.bhs_pr eqs) s1 eqs) in *)
66-
(* let conds = [f_forall_mems [bhs.bhs_m] condbd; condnm] in *)
67-
(* let conds = *)
68-
(* if f_equal g1 f_r0 *)
69-
(* then condg1 :: conds *)
70-
(* else if f_equal g2 f_r0 *)
71-
(* then condg2 :: conds *)
72-
(* else condg1 :: condg2 :: conds in *)
73-
74-
(* let conds = *)
75-
(* if f_equal f1 f_r0 *)
76-
(* then condf1 :: conds *)
77-
(* else if f_equal f2 f_r0 *)
78-
(* then condf2 :: conds *)
79-
(* else condf1 :: condf2 :: conds in *)
80-
81-
(* let conds = cond_phi :: conds in *)
82-
83-
(* FApi.xmutate1 tc `HlApp conds *)
38+
let t_bdhoare_app_r_low i (phi, pR, f1, f2, g1, g2) tc =
39+
let env = FApi.tc1_env tc in
40+
let bhs = tc1_as_bdhoareS tc in
41+
let s1, s2 = s_split env i bhs.bhs_s in
42+
let s1, s2 = stmt s1, stmt s2 in
43+
let nR = f_not pR in
44+
let cond_phi = f_hoareS bhs.bhs_m bhs.bhs_pr s1 phi [] in
45+
let condf1 = f_bdHoareS_r { bhs with bhs_s = s1; bhs_po = pR; bhs_bd = f1; } in
46+
let condg1 = f_bdHoareS_r { bhs with bhs_s = s1; bhs_po = nR; bhs_bd = g1; } in
47+
let condf2 = f_bdHoareS_r
48+
{ bhs with bhs_s = s2; bhs_pr = f_and_simpl phi pR; bhs_bd = f2; } in
49+
let condg2 = f_bdHoareS_r
50+
{ bhs with bhs_s = s2; bhs_pr = f_and_simpl phi nR; bhs_bd = g2; } in
51+
let bd =
52+
(f_real_add_simpl (f_real_mul_simpl f1 f2) (f_real_mul_simpl g1 g2)) in
53+
let condbd =
54+
match bhs.bhs_cmp with
55+
| FHle -> f_real_le bd bhs.bhs_bd
56+
| FHeq -> f_eq bd bhs.bhs_bd
57+
| FHge -> f_real_le bhs.bhs_bd bd in
58+
let condbd = f_imp bhs.bhs_pr condbd in
59+
let (ir1, ir2) = EcIdent.create "r", EcIdent.create "r" in
60+
let (r1 , r2 ) = f_local ir1 treal, f_local ir2 treal in
61+
let condnm =
62+
let eqs = f_and (f_eq f2 r1) (f_eq g2 r2) in
63+
f_forall
64+
[(ir1, GTty treal); (ir2, GTty treal)]
65+
(f_hoareS bhs.bhs_m (f_and bhs.bhs_pr eqs) s1 eqs []) in
66+
let conds = [f_forall_mems [bhs.bhs_m] condbd; condnm] in
67+
let conds =
68+
if f_equal g1 f_r0
69+
then condg1 :: conds
70+
else if f_equal g2 f_r0
71+
then condg2 :: conds
72+
else condg1 :: condg2 :: conds in
73+
74+
let conds =
75+
if f_equal f1 f_r0
76+
then condf1 :: conds
77+
else if f_equal f2 f_r0
78+
then condf2 :: conds
79+
else condf1 :: condf2 :: conds in
80+
81+
let conds = cond_phi :: conds in
82+
83+
FApi.xmutate1 tc `HlApp conds
8484

8585
(* -------------------------------------------------------------------- *)
8686
let t_bdhoare_app_r i info tc =

0 commit comments

Comments
 (0)