Skip to content

Commit 083f2c2

Browse files
committed
Use default prover for impure specs too.
1 parent dac3a56 commit 083f2c2

File tree

2 files changed

+16
-68
lines changed

2 files changed

+16
-68
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 |)

0 commit comments

Comments
 (0)