Skip to content

Commit 07155c0

Browse files
committed
Fix Conseq rule
1 parent b7442f1 commit 07155c0

File tree

9 files changed

+186
-43
lines changed

9 files changed

+186
-43
lines changed

examples/exception.ec

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

66
module M ={
77
proc truc (x:int) : int = {
8-
if (x = 3) {raise toto;} else{ x <- 5; }
8+
if (x = 3) {
9+
raise toto;
10+
} else { x <- 5; }
911
return x;
1012
}
1113
}.
1214

13-
lemma truc :
14-
hoare [M.truc : true ==> (4 < res) | toto:(res = 3) |tata:(res=2) ].
15+
lemma truc (_x: int):
16+
hoare [M.truc : _x = x ==> (4 < res) | toto:(_x = 3) | tata:(false) ].
1517
proof.
1618
proc.
17-
conseq (: _ ==> x = 5).
18-
+ smt.
19+
conseq (: _ ==> x = 5).
1920
+ auto.
21+
+ auto.
22+
qed.
23+
24+
exception assume.
25+
exception assert.
26+
27+
module M' ={
28+
proc truc (x:int) : int = {
29+
if (x = 3) {
30+
raise assume;
31+
}
32+
if (x=3) {
33+
raise assert;
34+
}
35+
return x;
36+
}
37+
}.
38+
39+
(* lemma assume_assert : *)
40+
(* hoare [M'.truc : true ==> true | assume:true |assert: false ]. *)
41+
(* proof. *)
42+
(* proc. *)
43+
(* wp. *)
44+
(* auto. *)
45+
(* qed. *)
46+
47+
(* lemma assert_assume : *)
48+
(* hoare [M'.truc : x <> 3 ==> true | assume:false |assert: true ]. *)
49+
(* proof. *)
50+
(* proc. *)
51+
(* wp. *)
52+
(* auto. *)
53+
(* qed. *)
54+
55+
op p1: bool.
56+
op p2: bool.
57+
op p3: bool.
58+
op p4: bool.
59+
op p5: bool.
60+
op p6: bool.
61+
op p7: bool.
62+
op p8: bool.
63+
op p9: bool.
64+
65+
lemma assume_assert :
66+
hoare [M'.truc : p7 ==> p3 | assume:p1 |assert: p2 ].
67+
proof.
68+
admitted.
69+
70+
op q1: bool.
71+
op q2: bool.
72+
op q3: bool.
73+
74+
75+
lemma assert_assume :
76+
hoare [M'.truc : p8 ==> q3 | assume:q1 |assert: q2 ].
77+
proof.
78+
admitted.
79+
80+
81+
(*Conseq is brocken, should take into account the post of exception*)
82+
lemma assert_assume' :
83+
hoare [M'.truc : p9 ==> p4 | assume:p6 |assert: p5 ].
84+
proof.
85+
conseq (assume_assert) (assert_assume).
86+
+ admit.
87+
+ admit.
88+
+ admit.
89+
+ admit.
2090
qed.

src/ecAst.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ and equivS = {
230230
es_sr : stmt;
231231
es_po : form; }
232232

233-
and post = (memory * form) list
233+
and post = ((* EcPath.path *) memory * form) list
234234

235235
and sHoareF = {
236236
hf_pr : form;

src/ecLowPhlGoal.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ let tc1_get_post tc =
251251
| None -> tc_error_noXhl ~kinds:hlkinds_Xhl !!tc
252252
| Some f -> f
253253

254+
(* -------------------------------------------------------------------- *)
255+
let get_poste f =
256+
match f.f_node with
257+
| FhoareF hf -> Some (hf.hf_poe )
258+
| FhoareS hs -> Some (hs.hs_poe )
259+
| _ -> None
260+
261+
let tc1_get_poste tc =
262+
match get_poste (FApi.tc1_goal tc) with
263+
| None -> tc_error_noXhl ~kinds:hlkinds_Xhl !!tc
264+
| Some f -> f
265+
254266
(* -------------------------------------------------------------------- *)
255267
let set_pre ~pre f =
256268
match f.f_node with

src/ecTyping.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3501,7 +3501,7 @@ and trans_form_or_pattern env mode ?mv ?ps ue pf tt =
35013501
let epost' =
35023502
List.map (fun (e,f) ->
35033503
let symb,_ = except_genpath env e in
3504-
EcIdent.create symb,transf qenv f
3504+
EcIdent.create symb,transf penv f
35053505
) eposts
35063506
in
35073507

src/phl/ecPhlApp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let t_bdhoare_app_r_low i (phi, pR, f1, f2, g1, g2) tc =
8686
let t_bdhoare_app_r i info tc =
8787
let tactic tc =
8888
let hs = tc1_as_hoareS tc in
89-
let tt1 = EcPhlConseq.t_hoareS_conseq_nm hs.hs_pr f_true in
89+
let tt1 = EcPhlConseq.t_hoareS_conseq_nm hs.hs_pr f_true hs.hs_poe in
9090
let tt2 = EcPhlAuto.t_pl_trivial in
9191
FApi.t_seqs [tt1; tt2; t_fail] tc
9292
in

0 commit comments

Comments
 (0)