@@ -28,7 +28,7 @@ open FStar.List.Tot
2828module RT = FStar.Reflection.Typing
2929module P = Pulse.Syntax.Printer
3030module PSB = Pulse.Syntax.Builder
31- module FV = Pulse.Typing.FV
31+
3232module T = FStar.Tactics.V2
3333module R = FStar.Reflection.V2
3434module 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,
397389preserving the st_typing derivation d *)
398390let 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
616590let 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
0 commit comments