Skip to content

Commit a8582c7

Browse files
authored
Merge pull request #4257 from FStarLang/gebner_fix4255
Check equality of slprops in prover.
2 parents 3aee342 + d7e3a46 commit a8582c7

2 files changed

Lines changed: 61 additions & 7 deletions

File tree

pulse/src/checker/Pulse.Checker.Prover.fst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ let try_apply_elim_lemma (pg: penv) (lid: R.name) (i: nat) (ctxt: slprop_view) :
10911091
let typing = core_check_term g t T.E_Ghost ty in
10921092
let t' = wtag (Some STT_Ghost) (Tm_ST { t; args=[] }) in
10931093

1094-
1094+
check_slprop_equiv_ext (RU.range_of_term pre) g (elab_slprop ctxt) pre;
10951095

10961096
assume (elab_slprop ctxt == pre);
10971097
let k_t = cont_elab_with_bind_nondep_unit c t' in
@@ -1133,9 +1133,7 @@ let try_apply_eager_intro_lemma (pg: penv) (lid: R.name) (i: nat) ctxt (goal: sl
11331133
let typing = core_check_term g'' t T.E_Ghost ty in
11341134
let t' = wtag (Some STT_Ghost) (Tm_ST { t; args=[] }) in
11351135

1136-
1137-
1138-
1136+
check_slprop_equiv_ext (RU.range_of_term (elab_slprop goal)) g post' (elab_slprop goal);
11391137

11401138
let k_typing = cont_elab_with_bind_nondep_unit c t' in
11411139
cont_elab_refl g ctxt ([] @ ctxt),
@@ -1238,9 +1236,7 @@ let try_apply_intro_lemma (pg: penv) (lid: R.name) (i: nat) ctxt (goal: slprop_v
12381236
let typing = core_check_term g' t T.E_Ghost ty in
12391237
let t' = wtag (Some STT_Ghost) (Tm_ST { t; args=[] }) in
12401238

1241-
1242-
1243-
1239+
check_slprop_equiv_ext (RU.range_of_term (elab_slprop goal)) g (elab_slprop post''_i) (elab_slprop goal);
12441240

12451241
let k_typing = cont_elab_with_bind_nondep_unit c t' in
12461242
let k_typing = cont_elab_frame k_typing ctxt' in

pulse/test/Bug4256.fst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module Bug4256
2+
#lang-pulse
3+
open Pulse
4+
5+
let foo ([@@@mkey] m: nat) (n: nat) : slprop =
6+
pure (m = n)
7+
8+
[@@pulse_intro]
9+
ghost fn foo_refl (m: nat)
10+
ensures foo m m
11+
{
12+
fold foo m m
13+
}
14+
15+
[@@expect_failure [19]]
16+
ghost fn uhoh_intro ()
17+
ensures pure False
18+
{
19+
assert foo 2 3;
20+
unfold foo
21+
}
22+
23+
let bar ([@@@mkey] m: nat) (n: nat) : slprop =
24+
pure (m = n)
25+
26+
[@@pulse_eager_intro]
27+
ghost fn bar_refl (m: nat)
28+
ensures bar m m
29+
{
30+
fold bar m m
31+
}
32+
33+
[@@expect_failure [19]]
34+
ghost fn uhoh_eager_intro ()
35+
ensures pure False
36+
{
37+
assert bar 2 3;
38+
unfold bar
39+
}
40+
41+
let baz ([@@@mkey] m: nat) (n: nat) : slprop =
42+
pure (m <> n)
43+
44+
[@@pulse_eager_elim]
45+
ghost fn baz_refl (m: nat)
46+
requires baz m m
47+
ensures is_unreachable
48+
{
49+
unfold baz m m;
50+
unreachable ()
51+
}
52+
53+
[@@expect_failure [19]]
54+
ghost fn uhoh_eager_elim ()
55+
ensures pure False
56+
{
57+
fold baz 2 3;
58+
}

0 commit comments

Comments
 (0)