Skip to content

Commit 028df92

Browse files
authored
Merge pull request #516 from FStarLang/gebner_impure_spec_prover
Use default prover for impure specs too.
2 parents cbcb12e + c00952b commit 028df92

File tree

5 files changed

+34
-81
lines changed

5 files changed

+34
-81
lines changed

src/checker/Pulse.Checker.ImpureSpec.fst

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -60,63 +60,10 @@ let rec get_rewrites_to_from_post (g: env) xres (post: slprop) : T.Tac (option R
6060
| _ -> None)
6161
| _ -> None
6262

63-
let prove_this (g: env) (goal: slprop) (ctxt: list slprop) : T.Tac (option (list slprop)) =
64-
match inspect_term goal with
65-
| Tm_Pure p ->
66-
// TODO: pure (x == ?u)
67-
Some []
68-
| Tm_ExistsSL u b body ->
69-
let uv = RU.new_implicit_var "witness for exists*" (RU.range_of_term goal) (elab_env g) b.binder_ty false in
70-
Some (slprop_as_list (open_term' body uv 0))
71-
| Tm_WithPure p _ body ->
72-
Some (tm_pure p :: slprop_as_list (open_term' body unit_const 0))
73-
| Tm_Star a b ->
74-
Some [a; b]
75-
| _ ->
76-
let rec try_match (ctxt: list slprop) : Dv bool =
77-
match ctxt with
78-
| [] -> false
79-
| c::ctxt ->
80-
if RU.teq_nosmt_force_phase1 (elab_env g) goal c then
81-
true
82-
else
83-
try_match ctxt
84-
in
85-
if try_match ctxt then
86-
Some []
87-
else
88-
None
89-
90-
let rec prove_step (g: env) (goals: list slprop) (ctxt: list slprop) : T.Tac (option (list slprop)) =
91-
match goals with
92-
| [] -> None
93-
| goal::goals ->
94-
match prove_this g goal ctxt with
95-
| Some new_goals -> Some (new_goals @ goals)
96-
| None ->
97-
match prove_step g goals ctxt with
98-
| Some stepped -> Some (goal :: stepped)
99-
| None -> None
100-
101-
let rec prove_loop (g: env) (goals: list slprop) (ctxt: list slprop) : T.Tac (list slprop) =
102-
match prove_step g goals ctxt with
103-
| Some new_goals -> prove_loop g new_goals ctxt
104-
| None -> goals
105-
10663
let prove (g: env) (goal: slprop) (ctxt: slprop) (r: range) : T.Tac unit =
107-
let (| goal, _ |) = normalize_slprop g goal true in
108-
let goal = slprop_as_list goal in
109-
let (| ctxt, _ |) = normalize_slprop g ctxt true in
110-
let ctxt = slprop_as_list ctxt in
111-
match prove_loop g goal ctxt with
112-
| [] -> ()
113-
| unsolved_goals ->
114-
T.fail_doc_at [
115-
text "Cannot prove remaining precondition:";
116-
separate hardline (T.map pp unsolved_goals);
117-
text "from context:";
118-
separate hardline (T.map pp ctxt);
119-
] (Some r)
64+
let allow_amb = true in
65+
let (| g', ctxt', _ |) = Pulse.Checker.Prover.prove r g ctxt goal allow_amb in
66+
()
12067

12168
let symb_eval_stateful_app (g: env) (ctxt: slprop) (t: term) : T.Tac R.term =
12269
let t, ty, _ = tc_term_phase1 g t in

src/checker/Pulse.Checker.Prover.fst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ let check_slprop_equiv_ext r (g:env) (p q:slprop)
535535
match res with
536536
| None ->
537537
fail_doc_with_subissues g (Some r) issues [
538-
text "rewrite: could not prove equality of";
538+
text "Could not prove equality of:";
539539
pp p;
540540
pp q;
541541
]
@@ -1097,11 +1097,12 @@ let prove rng (g: env) (ctxt goals: slprop) allow_amb :
10971097
] else []))
10981098
(Some rng)
10991099
else
1100-
let before, after = k g' in
1101-
let h: slprop_equiv g' (elab_slprops (solved' @ ctxt')) (elab_slprops (ctxt' @ solved' @ goals')) = RU.magic () in
1102-
let k = cont_elab_trans before (cont_elab_frame after ctxt') h [] in
1103-
let h: slprop_equiv g' (elab_slprops (ctxt' @ [Unknown goals])) (tm_star goals (elab_slprops ctxt')) = RU.magic () in
1104-
(| g', RU.deep_compress_safe (elab_slprops ctxt'), k_elab_equiv k (VE_Refl _ _) h |)
1100+
(| g', RU.deep_compress_safe (elab_slprops ctxt'), fun post_hint post_hint_typ ->
1101+
let before, after = k g' in
1102+
let h: slprop_equiv g' (elab_slprops (solved' @ ctxt')) (elab_slprops (ctxt' @ solved' @ goals')) = RU.magic () in
1103+
let k = cont_elab_trans before (cont_elab_frame after ctxt') h [] in
1104+
let h: slprop_equiv g' (elab_slprops (ctxt' @ [Unknown goals])) (tm_star goals (elab_slprops ctxt')) = RU.magic () in
1105+
k_elab_equiv k (VE_Refl _ _) h post_hint post_hint_typ |)
11051106

11061107
#restart-solver
11071108
#push-options "--z3rlimit_factor 2"
@@ -1195,10 +1196,10 @@ let elim_exists_and_pure (#g:env) (#ctxt:slprop)
11951196
let ctxt' = Pulse.Checker.Prover.Substs.ss_term ctxt ss in
11961197
let (| g', ctxt'', goals'', solved, k |) = try_elim_core g [Unknown ctxt'] in
11971198
let h: tot_typing g' (elab_slprops ctxt'') tm_slprop = RU.magic () in // TODO thread through prover
1198-
let h1: slprop_equiv g (elab_slprops ([] @ [Unknown ctxt'])) ctxt = (RU.magic() <: slprop_equiv g ctxt' ctxt) in
1199-
let h2: slprop_equiv g' (elab_slprops (ctxt'' @ solved @ goals'')) (elab_slprops ([] @ solved @ ctxt'')) = RU.magic () in
1200-
let h3: slprop_equiv g' (elab_slprops (ctxt'' @ [])) (elab_slprops ctxt'') = RU.magic () in
1201-
let before, after = k g' in
1202-
(| g', elab_slprops ctxt'', h,
1199+
(| g', elab_slprops ctxt'', h, fun post_hint post_hint_typ ->
1200+
let h1: slprop_equiv g (elab_slprops ([] @ [Unknown ctxt'])) ctxt = (RU.magic() <: slprop_equiv g ctxt' ctxt) in
1201+
let h2: slprop_equiv g' (elab_slprops (ctxt'' @ solved @ goals'')) (elab_slprops ([] @ solved @ ctxt'')) = RU.magic () in
1202+
let h3: slprop_equiv g' (elab_slprops (ctxt'' @ [])) (elab_slprops ctxt'') = RU.magic () in
1203+
let before, after = k g' in
12031204
k_elab_trans (k_elab_equiv (before []) h1 (VE_Refl _ _))
1204-
(k_elab_equiv (after ctxt'') h2 h3) |)
1205+
(k_elab_equiv (after ctxt'') h2 h3) post_hint post_hint_typ |)

test/LoopInvariants.fst.output.expected

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
- Expected failure:
33
- When using multiple invariants, they must all be in the "new" style without a binder.
44

5-
* Info at LoopInvariants.fst(77,4-77,8):
5+
* Info at LoopInvariants.fst(76,20-77,8):
66
- Expected failure:
7-
- rewrite: could not prove equality of
7+
- Could not prove equality of:
88
- Pulse.Lib.Reference.pts_to s 3
99
- Pulse.Lib.Reference.pts_to s 2
1010
- Assertion failed
1111
- The SMT solver could not prove the query. Use --query_stats for more
1212
details.
13-
- See also LoopInvariants.fst(77,4-77,10)
13+
- See also LoopInvariants.fst(76,20-77,10)
1414

15-
* Info at LoopInvariants.fst(88,4-88,8):
15+
* Info at LoopInvariants.fst(86,2-88,8):
1616
- Expected failure:
17-
- rewrite: could not prove equality of
17+
- Could not prove equality of:
1818
- Pulse.Lib.Reference.pts_to s 3
1919
- Pulse.Lib.Reference.pts_to s 2
2020
- Assertion failed
2121
- The SMT solver could not prove the query. Use --query_stats for more
2222
details.
23-
- See also LoopInvariants.fst(88,4-88,10)
23+
- See also LoopInvariants.fst(86,2-88,10)
2424

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
* Info at Bug174.fst(15,1-16,42):
1+
* Info at Bug174.fst(16,30-16,42):
22
- Expected failure:
3-
- rewrite: could not prove equality of
4-
- Pulse.Lib.Reference.pts_to r v
5-
- Pulse.Lib.Reference.pts_to r v
3+
- Ill-typed term: !r
4+
- Expected a term of type
5+
Pulse.Lib.Core.stt FStar.SizeT.t
6+
(r |-> Pulse.Class.PtsTo.Frac 1.0R v)
7+
(fun x ->
8+
r |-> Pulse.Class.PtsTo.Frac 1.0R v **
9+
Pulse.Lib.Core.rewrites_to x v)
610
- Assertion failed
711
- The SMT solver could not prove the query. Use --query_stats for more
812
details.
13+
- See also Bug174.fst(15,1-16,40)
914

test/bug-reports/ExistsErasedAndPureEqualities.fst.output.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
v#269 : FStar.Ghost.erased Prims.int,
1010
x#263 : Pulse.Lib.Reference.ref Prims.int
1111

12-
* Info at ExistsErasedAndPureEqualities.fst(70,4-71,21):
12+
* Info at ExistsErasedAndPureEqualities.fst(70,32-72,5):
1313
- Expected failure:
14-
- Failed to prove pure property: v == (*?u102*)_
14+
- Ill-typed term: pure (v == (*?u102*)_)
15+
- Expected a term of type slprop
1516
- Cannot check relation with uvars.
16-
- See also ExistsErasedAndPureEqualities.fst(70,23-71,15)
1717

0 commit comments

Comments
 (0)