Skip to content

Commit 3805094

Browse files
authored
Merge pull request #577 from FStarLang/gebner_rmsound
Remove soundness
2 parents 0c0d736 + 439c360 commit 3805094

100 files changed

Lines changed: 1025 additions & 8426 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/checker/Pulse.Checker.Abs.fst

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open FStar.List.Tot
2828
module RT = FStar.Reflection.Typing
2929
module P = Pulse.Syntax.Printer
3030
module PSB = Pulse.Syntax.Builder
31-
module FV = Pulse.Typing.FV
31+
3232
module T = FStar.Tactics.V2
3333
module R = FStar.Reflection.V2
3434
module RU = Pulse.RuntimeUtils
@@ -316,7 +316,7 @@ let preprocess_abs
316316
debug_abs g (fun _ -> Printf.sprintf "rebuild_abs = %s\n" (P.st_term_to_string abs));
317317
abs
318318

319-
let sub_effect_comp g r (asc:comp_ascription) (c_computed:comp) : T.Tac (option (c2:comp & lift_comp g c_computed c2)) =
319+
let sub_effect_comp g r (asc:comp_ascription) (c_computed:comp) : T.Tac (option comp) =
320320
let nop = None in
321321
match asc.elaborated with
322322
| None -> nop
@@ -326,19 +326,17 @@ let sub_effect_comp g r (asc:comp_ascription) (c_computed:comp) : T.Tac (option
326326
| C_ST _, C_ST _ -> nop
327327
| C_STGhost _ _, C_STGhost _ _ -> nop
328328
| C_STAtomic i Neutral c1, C_STGhost _ _ ->
329-
let lift = Lift_Neutral_Ghost g c_computed in
330-
Some (| C_STGhost i c1, lift |)
329+
Some (C_STGhost i c1)
331330
| C_STAtomic i o1 c1, C_STAtomic j o2 c2 ->
332331
if sub_observability o1 o2
333-
then let lift = Lift_Observability g c_computed o2 in
334-
Some (| C_STAtomic i o2 c1, lift |)
332+
then Some (C_STAtomic i o2 c1)
335333
else nop
336334

337335
(* FIXME: more lifts here *)
338336
| _ -> nop
339337

340-
let check_effect_annotation g r (asc:comp_ascription) (c_computed:comp) : T.Tac (c2:comp & st_sub g c_computed c2) =
341-
let nop = (| c_computed, STS_Refl _ _ |) in
338+
let check_effect_annotation g r (asc:comp_ascription) (c_computed:comp) : T.Tac comp =
339+
let nop = c_computed in
342340
match asc.elaborated with
343341
| None -> nop
344342
| Some c ->
@@ -360,10 +358,9 @@ let check_effect_annotation g r (asc:comp_ascription) (c_computed:comp) : T.Tac
360358

361359
let b = mk_binder "res" Range.range_0 c2.res in
362360
let phi = tm_inames_subset j i in
363-
let typing = tm_inames_subset_typing g j i in
364361
// Or:
365362
// let typing = core_check_tot_term g phi tm_prop in
366-
let tok = T.with_policy T.ForceSMT (fun () -> try_check_prop_validity g phi typing) in
363+
let tok = T.with_policy T.ForceSMT (fun () -> try_check_prop_validity g phi) in
367364
if None? tok then (
368365
let open Pulse.PP in
369366
fail_doc g (Some (RU.range_of_term i)) [
@@ -375,12 +372,7 @@ let check_effect_annotation g r (asc:comp_ascription) (c_computed:comp) : T.Tac
375372

376373
let Some tok = tok in
377374

378-
let d_sub : st_sub g c_computed c =
379-
match c_computed with
380-
| C_STAtomic _ obs _ -> STS_AtomicInvs g c2 j i obs obs tok
381-
| C_STGhost _ _ -> STS_GhostInvs g c2 j i tok
382-
in
383-
(| c, d_sub |)
375+
c
384376

385377
| _, _ ->
386378
let open Pulse.PP in
@@ -396,16 +388,15 @@ let check_effect_annotation g r (asc:comp_ascription) (c_computed:comp) : T.Tac
396388
(* Rewrite the comp c into the annotated one, if any,
397389
preserving the st_typing derivation d *)
398390
let maybe_rewrite_body_typing
399-
(#g:_) (#e:st_term) (#c:comp)
400-
(d:st_typing g e c)
391+
(g:_) (e:st_term) (c:comp)
401392
(asc:comp_ascription)
402-
: T.Tac (c':comp & st_typing g e c')
393+
: T.Tac comp
403394
= let open Pulse.PP in
404395
match asc.annotated, c with
405-
| None, _ -> (| c, d |)
396+
| None, _ -> c
406397
| Some (C_Tot t), C_Tot t' -> (
407398
let t, _ = Pulse.Checker.Pure.instantiate_term_implicits g t None false in
408-
let (| u, t_typing |) = Pulse.Checker.Pure.check_universe g t in
399+
let u = Pulse.Checker.Pure.check_universe g t in
409400
match T.t_check_equiv true true (elab_env g) t t' with
410401
| None, _ ->
411402
Env.fail_doc g (Some e.range) [
@@ -419,15 +410,7 @@ let maybe_rewrite_body_typing
419410
(show c)
420411
(show (C_Tot t)));
421412
let sq : squash (RT.equiv_token (elab_env g) t t') = () in
422-
let t'_typing : universe_of g t' u =
423-
(* t is equiv to t', and t has universe t. *)
424-
magic ()
425-
in
426-
let tok' : st_equiv g (C_Tot t') (C_Tot t) =
427-
ST_TotEquiv _ t' t u t'_typing
428-
(RT.Rel_sym _ _ _ (RT.Rel_eq_token _ _ _ sq))
429-
in
430-
(| C_Tot t, T_Equiv _ _ _ _ d tok' |)
413+
C_Tot t
431414
)
432415

433416
(* c is not a C_Tot *)
@@ -456,15 +439,15 @@ let rec check_abs_core
456439
(g:env)
457440
(t:st_term{Tm_Abs? t.term})
458441
(check:check_t)
459-
: T.Tac (t:st_term & c:comp & st_typing g t c) =
442+
: T.Tac (t:st_term & c:comp) =
460443
//warn g (Some t.range) (Printf.sprintf "check_abs_core, t = %s" (P.st_term_to_string t));
461444
let range = t.range in
462445
match t.term with
463446
| Tm_Abs { b = {binder_ty=t;binder_ppname=ppname;binder_attrs}; q=qual; ascription=asc; body } -> //pre=pre_hint; body; ret_ty; post=post_hint_body } ->
464447
let qual = T.map_opt (check_qual g) qual in
465448
(* (fun (x:t) -> {pre_hint} body : t { post_hint } *)
466-
let (| t, _, _ |) = compute_tot_term_type g t in //elaborate it first
467-
let (| u, t_typing |) = universe_of_well_typed_term g t in //then check that its universe ... We could collapse the two calls
449+
let (| t, _ |) = compute_tot_term_type g t in //elaborate it first
450+
let u = universe_of_well_typed_term g t in //then check that its universe ... We could collapse the two calls
468451
let x = fresh g in
469452
let px = ppname, x in
470453
let var = tm_var {nm_ppname=ppname;nm_index=x} in
@@ -474,27 +457,21 @@ let rec check_abs_core
474457
match body_opened.term with
475458
| Tm_Abs _ ->
476459
(* Check the opened body *)
477-
let (| body, c_body, body_typing |) = check_abs_core g' body_opened check in
460+
let (| body, c_body |) = check_abs_core g' body_opened check in
478461

479462
(* First lift into annotated effect *)
480-
let (| c_body, body_typing |) : ( c_body:comp & st_typing g' body c_body ) =
463+
let c_body : comp =
481464
match sub_effect_comp g' body.range asc c_body with
482-
| None -> (| c_body, body_typing |)
483-
| Some (| c_body, lift |) ->
484-
let body_typing = T_Lift _ _ _ _ body_typing lift in
485-
(| c_body, body_typing |)
465+
| None -> c_body
466+
| Some c_body -> c_body
486467
in
487468

488469
(* Check if it matches annotation (if any, likely not), and adjust derivation
489470
if needed. Currently this only subtypes the invariants. *)
490-
let (| c_body, d_sub |) = check_effect_annotation g' body.range asc c_body in
491-
let body_typing = T_Sub _ _ _ _ body_typing d_sub in
492-
(* Similar to above, fixes the type of the computation if we need to match
493-
its annotation. TODO: merge these two by adding a tot subtyping (or equiv)
494-
case to the st_sub judg. *)
495-
let (| c_body, body_typing |) = maybe_rewrite_body_typing body_typing asc in
496-
497-
FV.st_typing_freevars body_typing;
471+
let c_body = check_effect_annotation g' body.range asc c_body in
472+
473+
let c_body = maybe_rewrite_body_typing g' body c_body asc in
474+
498475
let body_closed = close_st_term body x in
499476
assume (open_st_term body_closed x == body);
500477

@@ -506,9 +483,9 @@ let rec check_abs_core
506483
|> FStar.Sealed.seal in
507484

508485
let b = {binder_ty=t;binder_ppname=ppname;binder_attrs} in
509-
let tt = T_Abs g x qual b u body_closed c_body t_typing body_typing in
510486
let tres = tm_arrow {binder_ty=t;binder_ppname=ppname;binder_attrs} qual (close_comp c_body x) in
511-
(| _, C_Tot tres, tt |)
487+
let abs_st = wtag None (Tm_Abs { b; q=qual; body=body_closed; ascription=empty_ascription}) in
488+
(| abs_st, C_Tot tres |)
512489
| _ ->
513490
let elab_c, pre_opened, inames_opened, ret_ty, post_hint_body =
514491
match asc.elaborated with
@@ -547,7 +524,7 @@ let rec check_abs_core
547524
Some (open_term_nv (comp_res c) px),
548525
Some (open_term' (comp_post c) var 1)
549526
in
550-
let (| pre_opened, pre_typing |) =
527+
let pre_opened =
551528
(* In some cases F* can mess up the range in error reporting and make it
552529
point outside of this term. Bound it here. See e.g. Bug59, if we remove
553530
this bound then the range points to the span between the 'x' and 'y' binders. *)
@@ -571,7 +548,7 @@ let rec check_abs_core
571548
in
572549

573550
let ppname_ret = mk_ppname_no_range "_fret" in
574-
let r = check g' pre_opened pre_typing post ppname_ret body_opened in
551+
let r = check g' pre_opened post ppname_ret body_opened in
575552
let (| post, r |) : (ph:post_hint_opt g' & checker_result_t g' pre_opened ph) =
576553
match post with
577554
| PostHint _ -> (| post, r |)
@@ -583,37 +560,34 @@ let rec check_abs_core
583560
let r = Pulse.Checker.Prover.prove_post_hint r (PostHint ph) (T.range_of_term t) in
584561
(| PostHint ph, r |)
585562
in
586-
let (| body, c_body, body_typing |) : st_typing_in_ctxt g' pre_opened post =
563+
let (| body, c_body |) : st_typing_in_ctxt g' pre_opened post =
587564
RU.record_stats "apply_checker_result_k" fun _ ->
588565
apply_checker_result_k #_ #_ #(PostHint?.v post) r ppname_ret in
589566

590567
let c_opened : comp_ascription = { annotated = None; elaborated = Some (open_comp_nv elab_c px) } in
591568

592569
(* First lift into annotated effect *)
593-
let (| c_body, body_typing |) : ( c_body:comp & st_typing g' body c_body ) =
570+
let c_body : comp =
594571
match sub_effect_comp g' body.range c_opened c_body with
595-
| None -> (| c_body, body_typing |)
596-
| Some (| c_body, lift |) ->
597-
let body_typing = T_Lift _ _ _ _ body_typing lift in
598-
(| c_body, body_typing |)
572+
| None -> c_body
573+
| Some c_body -> c_body
599574
in
600575

601-
let (| c_body, d_sub |) = check_effect_annotation g' body.range c_opened c_body in
602-
let body_typing = T_Sub _ _ _ _ body_typing d_sub in
576+
let c_body = check_effect_annotation g' body.range c_opened c_body in
577+
603578

604-
let (| c_body, body_typing |) = maybe_rewrite_body_typing body_typing asc in
579+
let c_body = maybe_rewrite_body_typing g' body c_body asc in
605580

606-
FV.st_typing_freevars body_typing;
607581
let body_closed = close_st_term body x in
608582
assume (open_st_term body_closed x == body);
609583
let b = {binder_ty=t;binder_ppname=ppname;binder_attrs} in
610-
let tt = T_Abs g x qual b u body_closed c_body t_typing body_typing in
611584
let tres = tm_arrow {binder_ty=t;binder_ppname=ppname;binder_attrs} qual (close_comp c_body x) in
585+
let abs_st = wtag None (Tm_Abs { b; q=qual; body=body_closed; ascription=empty_ascription}) in
612586

613-
(| _, C_Tot tres, tt |)
587+
(| abs_st, C_Tot tres |)
614588
#pop-options
615589

616590
let check_abs (g:env) (t:st_term{Tm_Abs? t.term}) (check:check_t)
617-
: T.Tac (t:st_term & c:comp & st_typing g t c) =
591+
: T.Tac (t:st_term & c:comp) =
618592
let t = preprocess_abs g t in
619593
check_abs_core g t check

src/checker/Pulse.Checker.Abs.fsti

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ val check_abs
3232
(g:env)
3333
(t:st_term{Tm_Abs? t.term})
3434
(check:check_t)
35-
: T.Tac (t:st_term & c:comp & st_typing g t c)
35+
: T.Tac (t:st_term & c:comp)

src/checker/Pulse.Checker.Admit.fst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ module P = Pulse.Syntax.Printer
2929
let check
3030
(g:env)
3131
(pre:term)
32-
(pre_typing:tot_typing g pre tm_slprop)
3332
(post_hint:post_hint_opt g)
3433
(res_ppname:ppname)
3534
(t:st_term { Tm_Admit? t.term })
@@ -44,8 +43,7 @@ let check
4443
let x = fresh g in
4544
let px = v_as_nv x in
4645
let res
47-
: (c:comp_st { comp_pre c == pre /\ comp_post_matches_hint c post_hint } &
48-
comp_typing g c (universe_of_comp c))
46+
: c:comp_st { comp_pre c == pre /\ comp_post_matches_hint c post_hint }
4947
= match post, post_hint with
5048
| None, NoHint
5149
| None, TypeHint _ ->
@@ -58,24 +56,29 @@ let check
5856
(P.term_to_string post2.post))
5957

6058
| Some post, _ ->
61-
let (| u, t_typing |) = check_universe g t in
59+
let u = check_universe g t in
6260
let post_opened = open_term_nv post px in
63-
let (| post_opened, post_typing |) =
61+
let post_opened =
6462
check_tot_term (push_binding g x (fst px) t) post_opened tm_slprop
6563
in
6664
let post = close_term post_opened x in
6765
let s : st_comp = {u;res=t;pre;post} in
6866
assume (open_term (close_term post_opened x) x == post_opened);
69-
let d_s : st_comp_typing _ s = STC _ s x t_typing pre_typing post_typing in
67+
7068
(match c with
71-
| STT -> (| _, CT_ST _ _ d_s |)
72-
| STT_Ghost -> (| _, CT_STGhost _ tm_emp_inames _ (RU.magic ()) d_s |)
73-
| STT_Atomic -> (| _, CT_STAtomic _ tm_emp_inames Neutral _ (RU.magic ()) d_s |))
69+
| STT -> C_ST s
70+
| STT_Ghost -> C_STGhost tm_emp_inames s
71+
| STT_Atomic -> C_STAtomic tm_emp_inames Neutral s)
7472

75-
| _, PostHint post -> Pulse.Typing.Combinators.comp_for_post_hint pre_typing post x
73+
| _, PostHint post -> Pulse.Typing.Combinators.comp_for_post_hint g pre post x
7674
in
77-
let (| c, d_c |) = res in
78-
let d = T_Admit _ _ d_c in
75+
let c = res in
76+
let admit_st = wtag (Some (ctag_of_comp_st c))
77+
(Tm_Admit { ctag=ctag_of_comp_st c;
78+
u=comp_u c;
79+
typ=comp_res c;
80+
post=None }) in
81+
7982
FStar.Tactics.BreakVC.break_vc ();
8083
// ^ This makes a big difference! Would be good to distill into
8184
// a smaller F*-only example and file an issue.
@@ -92,4 +95,4 @@ let check
9295
] in
9396
info_doc_env g (Some t0.range) msg
9497
end else ()) <: T.Tac unit;
95-
checker_result_for_st_typing (| _, _, d |) res_ppname
98+
checker_result_for_st_typing (| admit_st, c |) res_ppname

src/checker/Pulse.Checker.Admit.fsti

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ open Pulse.Checker.Base
2525
val check
2626
(g:env)
2727
(pre:term)
28-
(pre_typing:tot_typing g pre tm_slprop)
2928
(post_hint:post_hint_opt g)
3029
(res_ppname:ppname)
3130
(t:st_term { Tm_Admit? t.term })

0 commit comments

Comments
 (0)