Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A separation logic prover for pulse #38

Merged
merged 138 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
b7c0b68
hacky integration of the prover in the typechecker
aseemr Jul 13, 2023
437bbec
snap and cp
aseemr Jul 13, 2023
a244c9c
adding check_bindv2 to the interface
aseemr Jul 13, 2023
880a2b6
checker calling v2
aseemr Jul 13, 2023
20c5ce4
debug messages + matched exact same vprops
aseemr Jul 13, 2023
bb18da1
wip, implementing st_typing weakening
aseemr Jul 13, 2023
9b255af
st typing weakening
aseemr Jul 14, 2023
cd30ab8
st typing subst
aseemr Jul 14, 2023
d36b9b1
snap
aseemr Jul 14, 2023
ddaa33a
implementing some more admits
aseemr Jul 14, 2023
740fcfe
snap
aseemr Jul 14, 2023
8ec0051
snap
aseemr Jul 14, 2023
b27ac6c
debugging an intro exists with the prover
aseemr Jul 14, 2023
ebc4e53
fixing a bug, push the new uvar in intro exists to pst.uvs
aseemr Jul 14, 2023
c064728
fixing some bugs
aseemr Jul 16, 2023
936fc7c
wip, new checker interface
aseemr Jul 18, 2023
e6443b4
stapp in the new checker interface
aseemr Jul 18, 2023
3b47e29
bind implementation with the new checker interface
aseemr Jul 18, 2023
d532bbe
trying to get to a compiling stage
aseemr Jul 18, 2023
23221f5
tweaks to bind
aseemr Jul 18, 2023
6d134d0
a return_in_ctxt combinator
aseemr Jul 18, 2023
7389aa7
checking for abs
aseemr Jul 18, 2023
259189a
fixing compilation errors
aseemr Jul 18, 2023
3ec2cd3
snap
aseemr Jul 18, 2023
3adb54f
an end-to-end example with bind and stapp
aseemr Jul 18, 2023
04a626a
fixing a bug in bind checker
aseemr Jul 18, 2023
76d9b0e
implicit inference in the prover framework
aseemr Jul 19, 2023
c919e52
bind fix, port return to the new checker
aseemr Jul 19, 2023
b94609c
snap
aseemr Jul 19, 2023
bb296e2
tweaks to return
aseemr Jul 19, 2023
f892d5e
snap
aseemr Jul 19, 2023
491c40c
wip, an intro pure step
aseemr Jul 19, 2023
90e5728
intro pure and adding it to the prover
aseemr Jul 19, 2023
7b8c24e
snap
aseemr Jul 19, 2023
b4f366f
new ml file
aseemr Jul 19, 2023
88d3b52
nit
aseemr Jul 19, 2023
7780ca2
cp
aseemr Jul 19, 2023
6e65f01
nit
aseemr Jul 19, 2023
6f571b9
if checker in the new interface
aseemr Jul 20, 2023
b27f551
example with if works
aseemr Jul 20, 2023
6aeb3b1
a combinator for applying checker result continuation
aseemr Jul 20, 2023
d609519
snap
aseemr Jul 20, 2023
52bd4cb
combinator for st typing to checker result
aseemr Jul 20, 2023
00c9ce1
snap
aseemr Jul 20, 2023
113d715
while checker in the new interface
aseemr Jul 20, 2023
eb43e70
snap
aseemr Jul 20, 2023
f0b05bb
while example works and is simpler than before
aseemr Jul 20, 2023
846dd04
cp
aseemr Jul 20, 2023
6c06975
exists checker (no witness inference yet)
aseemr Jul 20, 2023
63c0edd
snap
aseemr Jul 20, 2023
6ce19cd
cp
aseemr Jul 20, 2023
b60b098
prover based implementation of assert with binders, ExistsWitness goe…
aseemr Jul 20, 2023
de9c768
snap
aseemr Jul 20, 2023
f71bf14
wip, exists witness inference
aseemr Jul 20, 2023
7af77ce
nits
aseemr Jul 20, 2023
98c6757
witness inference for intro exists
aseemr Jul 21, 2023
90840c6
snap
aseemr Jul 21, 2023
5f23d91
Working through CustomSynax, cp
aseemr Jul 21, 2023
77483cb
tot bind
aseemr Jul 21, 2023
0535560
snap
aseemr Jul 21, 2023
c7e3d19
enable tot bind in checker
aseemr Jul 21, 2023
937e9af
withlocal checker
aseemr Jul 21, 2023
73a8762
snap
aseemr Jul 21, 2023
eef6d1d
Enable withlocal checker
aseemr Jul 21, 2023
7e1b1c5
intro pure checker
aseemr Jul 21, 2023
f417116
snap
aseemr Jul 21, 2023
1a3ecbf
enable intro pure checker
aseemr Jul 21, 2023
e41902e
admit checker
aseemr Jul 21, 2023
e6d0743
snap
aseemr Jul 21, 2023
23d03cc
rewrite checker
aseemr Jul 21, 2023
9f4fc5b
snap
aseemr Jul 21, 2023
f781607
par checker
aseemr Jul 21, 2023
69d97ee
snap
aseemr Jul 21, 2023
9e21576
snap
aseemr Jul 21, 2023
0310f5b
enable par checker
aseemr Jul 21, 2023
342bb66
solving pure (?u = e)
aseemr Jul 21, 2023
100fbb9
snap
aseemr Jul 21, 2023
b756d7d
snap
aseemr Jul 21, 2023
f532ce6
notes in CustomSyntax
aseemr Jul 21, 2023
49538cd
nit
aseemr Jul 21, 2023
d21d656
refining the pure uvar equalities handling
aseemr Jul 21, 2023
a314ee1
Snap
aseemr Jul 21, 2023
4026db0
fixing another example
aseemr Jul 21, 2023
5221e2d
Snap
aseemr Jul 21, 2023
a2186f8
ExistsWitness
aseemr Jul 21, 2023
45140f5
Cp
aseemr Jul 21, 2023
d709ccc
use intro exists erased (we should fix it properly)
aseemr Jul 22, 2023
a74103d
one example in customsyntax remains, need ghost support for it
aseemr Jul 22, 2023
84451bd
merge with main
aseemr Jul 22, 2023
e719ce8
temporary state, comment match
aseemr Jul 22, 2023
396b901
cp, parity
aseemr Jul 22, 2023
a247409
enable match checking
aseemr Jul 22, 2023
6577048
snap
aseemr Jul 22, 2023
fdc7cd1
bootstrap with smt
aseemr Jul 22, 2023
1cf2fa9
removing Tm_Protect from syntax
aseemr Jul 22, 2023
2b9433d
removing should_check flag
aseemr Jul 22, 2023
4207ba2
Revert "removing should_check flag"
aseemr Jul 22, 2023
2fd6176
removing should_check
aseemr Jul 22, 2023
d4b5700
snap
aseemr Jul 22, 2023
c3b923c
suppoprt for fold/unfold without binders
aseemr Jul 23, 2023
ccad432
snap
aseemr Jul 23, 2023
6dcf885
support for ghost functions, dice goes through
aseemr Jul 23, 2023
fa3c59d
snap
aseemr Jul 23, 2023
09b0299
better implementation for fold/unfold with binders
aseemr Jul 23, 2023
7de4f0e
snap
aseemr Jul 23, 2023
f4fc0ed
some cleanup
aseemr Jul 23, 2023
c54f882
optimization to check goals eq_tm
aseemr Jul 23, 2023
59bf014
nit
aseemr Jul 24, 2023
c30a965
renaming Pulse.Prover
aseemr Jul 24, 2023
ed5f9b1
tweaks
aseemr Jul 24, 2023
9e28d57
some API changes
aseemr Jul 24, 2023
59436b9
Snap
aseemr Jul 24, 2023
0af563e
snap
aseemr Jul 24, 2023
711a684
switching off the eq_tm optimization
aseemr Jul 25, 2023
714707f
Merge branch 'main' into _aseem_prover_integration
aseemr Jul 25, 2023
b691cd6
wip, pass over checker errors
aseemr Jul 25, 2023
d4cd00e
wip, error messages in the checker
aseemr Jul 25, 2023
9d0bde1
cp
aseemr Jul 25, 2023
264d10d
snap
aseemr Jul 25, 2023
9921cf1
refining st typing in ctxt, removes some runtime checks
aseemr Jul 25, 2023
8b42079
snap
aseemr Jul 25, 2023
0d78d1a
strengthening the type checker_result
aseemr Jul 25, 2023
5f17285
snap
aseemr Jul 25, 2023
4e827aa
splitting metatheory into base and metatheory
aseemr Jul 25, 2023
ade170b
snap
aseemr Jul 25, 2023
00ab198
fixing a range in stapp checker
aseemr Jul 25, 2023
bac6313
Merge branch 'main' into _aseem_prover_integration
aseemr Jul 26, 2023
b55484d
propagating ppnames in the checker
aseemr Jul 26, 2023
41a2f68
snap
aseemr Jul 26, 2023
e3d276b
Merge branch '_aseem_prover_integration' of github.com:FStarLang/stee…
aseemr Jul 26, 2023
c852909
more names
aseemr Jul 26, 2023
11b2e7d
implement tot_typing_weakening_single
aseemr Jul 27, 2023
f9f763c
a standard form of tot_typing_weakening
aseemr Jul 27, 2023
206f927
removing some weakening admits
aseemr Jul 27, 2023
8263be5
snap
aseemr Jul 27, 2023
5cd6bff
some error messages
aseemr Jul 27, 2023
9fe4f26
snap
aseemr Jul 27, 2023
aa07516
ifuel
aseemr Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 55 additions & 42 deletions lib/steel/pulse/Pulse.Checker.Abs.fst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module Pulse.Checker.Abs

module T = FStar.Tactics.V2
module RT = FStar.Reflection.Typing

open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Common
open Pulse.Checker.Base

module P = Pulse.Syntax.Printer
module FV = Pulse.Typing.FV
Expand All @@ -31,58 +31,71 @@ let check_effect_annotation g r (c_annot c_computed:comp) =


#push-options "--z3rlimit_factor 2 --fuel 0 --ifuel 1"
let check_abs
let rec check_abs
(g:env)
(t:st_term{Tm_Abs? t.term})
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) =
if Some? post_hint then fail g None "Unexpected post-condition annotation from context for an abstraction" else
: T.Tac (t:st_term & c:comp & st_typing g t c)=

let range = t.range in
match t.term with
| Tm_Abs { b = {binder_ty=t;binder_ppname=ppname}; q=qual; ascription=c; body } -> //pre=pre_hint; body; ret_ty; post=post_hint_body } ->

(* (fun (x:t) -> {pre_hint} body : t { post_hint } *)
let (| t, _, _ |) = check_term g t in //elaborate it first
let (| u, t_typing |) = check_universe g t in //then check that its universe ... We could collapse the two calls
let x = fresh g in
let px = ppname, x in
let var = tm_var {nm_ppname=ppname;nm_index=x} in
let g' = push_binding g x ppname t in
let pre_opened, ret_ty, post_hint_body =
match c with
| C_Tot { t = Tm_Unknown } ->
tm_emp, None, None
let body_opened = open_st_term_nv body px in
match body_opened.term with
| Tm_Abs _ ->
let (| body, c_body, body_typing |) = check_abs g' body_opened check in
check_effect_annotation g' body.range c c_body;
FV.st_typing_freevars body_typing;
let body_closed = close_st_term body x in
assume (open_st_term body_closed x == body);
let b = {binder_ty=t;binder_ppname=ppname} in
let tt = T_Abs g x qual b u body_closed c_body t_typing body_typing in
let tres = tm_arrow {binder_ty=t;binder_ppname=ppname} qual (close_comp c_body x) in
(| _, C_Tot tres, tt |)
| _ ->
let pre_opened, ret_ty, post_hint_body =
match c with
| C_Tot _ ->
fail g (Some body.range)
"Unexpected error: found a total computation annotation on a top-level function"

| _ ->
open_term_nv (comp_pre c) px,
Some (open_term_nv (comp_res c) px),
Some (open_term' (comp_post c) var 1)
in
let (| pre_opened, pre_typing |) = check_vprop g' pre_opened in
let pre = close_term pre_opened x in
let post : post_hint_opt g' =
match post_hint_body with
| None -> fail g (Some body.range) "Top-level functions must be annotated with pre and post conditions"
| Some post ->
let post_hint_typing
: post_hint_t
= Pulse.Checker.Base.intro_post_hint (push_context "post_hint_typing" range g') (Some (ctag_of_comp_st c)) ret_ty post
in
Some post_hint_typing
in

let ppname = mk_ppname_no_range "_fret" in
let r = check g' pre_opened pre_typing post ppname body_opened in
let (| body, c_body, body_typing |) : st_typing_in_ctxt g' pre_opened post =
apply_checker_result_k #_ #_ #(Some?.v post) r ppname in

| C_Tot ty ->
tm_emp,
Some (open_term_nv ty px),
None
check_effect_annotation g' body.range c c_body;

| _ ->
open_term_nv (comp_pre c) px,
Some (open_term_nv (comp_res c) px),
Some (open_term' (comp_post c) var 1)
in
let (| pre_opened, pre_typing |) = check_vprop g' pre_opened in
let pre = close_term pre_opened x in
let post =
match post_hint_body with
| None -> None
| Some post ->
let post_hint_typing
: post_hint_t
= Pulse.Checker.Common.intro_post_hint (push_context "post_hint_typing" range g') ret_ty post
in
Some post_hint_typing
in
let (| body', c_body, body_typing |) = check g' (open_st_term_nv body px) pre_opened pre_typing post in
check_effect_annotation g' body'.range c c_body;
FV.st_typing_freevars body_typing;
let body_closed = close_st_term body' x in
assume (open_st_term body_closed x == body');
let b = {binder_ty=t;binder_ppname=ppname} in
let tt = T_Abs g x qual b u body_closed c_body t_typing body_typing in
let tres = tm_arrow {binder_ty=t;binder_ppname=ppname} qual (close_comp c_body x) in
(| _, C_Tot tres, tt |)
FV.st_typing_freevars body_typing;
let body_closed = close_st_term body x in
assume (open_st_term body_closed x == body);
let b = {binder_ty=t;binder_ppname=ppname} in
let tt = T_Abs g x qual b u body_closed c_body t_typing body_typing in
let tres = tm_arrow {binder_ty=t;binder_ppname=ppname} qual (close_comp c_body x) in
(| _, C_Tot tres, tt |)
52 changes: 25 additions & 27 deletions lib/steel/pulse/Pulse.Checker.Abs.fst.hints
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
"ÌŽ—]Æê$žRm€ˆ\n™4",
"j›R\u0005¼–håÿ\u0004¶*Û“z",
[
[
"Pulse.Checker.Abs.check_effect_annotation",
Expand All @@ -13,7 +13,7 @@
"string_typing"
],
0,
"99ab22c732cabb968a68fa9bb11ca57a"
"e3ed564cdb21aa89d1f311e001c5aa9a"
],
[
"Pulse.Checker.Abs.check_abs",
Expand All @@ -25,31 +25,30 @@
"@fuel_correspondence_Pulse.Syntax.Naming.freevars_st.fuel_instrumented",
"@query", "Prims_pretyping_ce036b6b736ef4e0bc3a9ff132a12aed",
"Pulse.Syntax.Base_pretyping_fe09dc1e796799f4bac0760e63f30d40",
"Pulse.Typing_pretyping_85b09ae4ef91823fbf549acd09fde244",
"bool_inversion",
"constructor_distinct_FStar.Pervasives.Native.None",
"constructor_distinct_FStar.Pervasives.Native.Some",
"constructor_distinct_FStar.Tactics.Result.Failed",
"constructor_distinct_FStar.Tactics.Result.Success",
"constructor_distinct_Pulse.Syntax.Base.C_Tot",
"constructor_distinct_Pulse.Syntax.Base.Tm_Abs",
"constructor_distinct_Pulse.Syntax.Base.Tm_Unknown",
"data_elim_FStar.Tactics.Result.Success",
"data_elim_Pulse.Syntax.Base.Mkppname",
"data_elim_Pulse.Syntax.Base.Mkst_term",
"disc_equation_FStar.Pervasives.Native.None",
"disc_equation_FStar.Pervasives.Native.Some",
"disc_equation_Pulse.Syntax.Base.C_ST",
"disc_equation_Pulse.Syntax.Base.C_STAtomic",
"disc_equation_Pulse.Syntax.Base.C_STGhost",
"disc_equation_Pulse.Syntax.Base.C_Tot",
"disc_equation_Pulse.Syntax.Base.Tm_Abs",
"disc_equation_Pulse.Syntax.Base.Tm_Unknown",
"equality_tok_Pulse.Syntax.Base.Tm_Unknown@tok",
"equation_FStar.Pervasives.Native.fst",
"equation_FStar.Pervasives.Native.snd", "equation_FStar.Range.range",
"equation_FStar.Reflection.Typing.fstar_top_env",
"equation_FStar.Reflection.Typing.pp_name_t",
"equation_FStar.Reflection.V2.Data.var", "equation_Prims.eqtype",
"equation_FStar.Reflection.V2.Data.var",
"equation_FStar.Sealed.Inhabited.sealed",
"equation_FStar.Sealed.Inhabited.sealed_", "equation_Prims.eqtype",
"equation_Prims.nat", "equation_Pulse.Checker.Pure.push_context",
"equation_Pulse.Syntax.Base.comp_st",
"equation_Pulse.Syntax.Base.index",
"equation_Pulse.Syntax.Base.nvar",
"equation_Pulse.Syntax.Base.ppname_default",
Expand All @@ -64,16 +63,14 @@
"equation_Pulse.Typing.FV.set_minus",
"equation_Pulse.Typing.post_hint_for_env",
"equation_Pulse.Typing.post_hint_opt",
"fuel_guarded_inversion_FStar.Pervasives.Native.option",
"fuel_guarded_inversion_FStar.Tactics.Result.__result",
"fuel_guarded_inversion_Pulse.Syntax.Base.comp",
"fuel_guarded_inversion_Pulse.Syntax.Base.ppname",
"fuel_guarded_inversion_Pulse.Syntax.Base.st_term",
"function_token_typing_Prims.__cache_version_number__",
"function_token_typing_Prims.int",
"function_token_typing_Prims.string",
"haseqTm_refine_542f9d4f129664613f2483a6c88bc7c2", "int_inversion",
"int_typing", "kinding_Pulse.Syntax.Base.ppname@tok",
"haseqTm_refine_542f9d4f129664613f2483a6c88bc7c2", "int_typing",
"kinding_Pulse.Syntax.Base.ppname@tok",
"kinding_Pulse.Syntax.Base.term@tok",
"kinding_Pulse.Typing.post_hint_t@tok",
"lemma_FStar.Map.lemma_ContainsDom",
Expand All @@ -88,12 +85,13 @@
"proj_equation_FStar.Pervasives.Native.Mktuple2__1",
"proj_equation_FStar.Pervasives.Native.Mktuple2__2",
"proj_equation_FStar.Pervasives.Native.Some_v",
"proj_equation_Pulse.Syntax.Base.C_Tot__0",
"proj_equation_Pulse.Syntax.Base.Mkbinder_binder_ppname",
"proj_equation_Pulse.Syntax.Base.Mkbinder_binder_ty",
"proj_equation_Pulse.Syntax.Base.Mknm_nm_ppname",
"proj_equation_Pulse.Syntax.Base.Mkppname_name",
"proj_equation_Pulse.Syntax.Base.Mkterm_t",
"proj_equation_Pulse.Syntax.Base.Mkppname_range",
"proj_equation_Pulse.Syntax.Base.Mkst_term_range",
"proj_equation_Pulse.Syntax.Base.Mkst_term_term",
"projection_inverse_BoxBool_proj_0",
"projection_inverse_FStar.Pervasives.Native.Mktuple2__1",
"projection_inverse_FStar.Pervasives.Native.Mktuple2__2",
Expand All @@ -106,41 +104,41 @@
"projection_inverse_FStar.Tactics.Result.Success_a",
"projection_inverse_FStar.Tactics.Result.Success_ps",
"projection_inverse_FStar.Tactics.Result.Success_v",
"projection_inverse_Pulse.Syntax.Base.C_Tot__0",
"projection_inverse_Pulse.Syntax.Base.Mkbinder_binder_ppname",
"projection_inverse_Pulse.Syntax.Base.Mkbinder_binder_ty",
"projection_inverse_Pulse.Syntax.Base.Mknm_nm_ppname",
"projection_inverse_Pulse.Syntax.Base.Mkppname_name",
"projection_inverse_Pulse.Syntax.Base.Mkterm_t",
"projection_inverse_Pulse.Syntax.Base.Tm_Abs__0",
"refinement_interpretation_Tm_refine_0e05a441736ee1a990510e8440d3b4d7",
"refinement_interpretation_Tm_refine_262f039a938fc14ac016e995f8cd074e",
"refinement_interpretation_Tm_refine_25fe9861b42cf97d961ff4c8f44eb399",
"refinement_interpretation_Tm_refine_414d0a9f578ab0048252f8c8f552b99f",
"refinement_interpretation_Tm_refine_484fe0819d1383a2c20d94ae027baa5f",
"refinement_interpretation_Tm_refine_542f9d4f129664613f2483a6c88bc7c2",
"refinement_interpretation_Tm_refine_6c182d6f9819de8b46a7a4d39f909d33",
"refinement_interpretation_Tm_refine_6e8e5238aadfc712ef5fa6bc6310c384",
"refinement_interpretation_Tm_refine_78cf9fabb706bab7e54de904b7db9d2a",
"refinement_interpretation_Tm_refine_7f3ad0958305f2921bfac06f466396ae",
"refinement_interpretation_Tm_refine_8c22aa61a47c16d0229ef090894097c8",
"refinement_interpretation_Tm_refine_ba488b4f12660f6fd23fa65ec4b4a4ff",
"refinement_kinding_Tm_refine_542f9d4f129664613f2483a6c88bc7c2",
"string_typing", "typing_FStar.Map.contains",
"typing_FStar.Pervasives.Native.fst",
"typing_FStar.Pervasives.Native.uu___is_None",
"typing_FStar.Reflection.V2.Data.var", "typing_FStar.Set.complement",
"typing_FStar.Set.mem", "typing_FStar.Set.singleton",
"string_typing", "typing_FStar.Pervasives.Native.fst",
"typing_FStar.Reflection.V2.Data.var", "typing_FStar.Sealed.seal",
"typing_FStar.Set.complement", "typing_FStar.Set.mem",
"typing_FStar.Set.singleton",
"typing_Pulse.Checker.Pure.push_context",
"typing_Pulse.Syntax.Base.__proj__Mkppname__item__name",
"typing_Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"typing_Pulse.Syntax.Base.__proj__Mkppname__item__range",
"typing_Pulse.Syntax.Base.ppname_default",
"typing_Pulse.Syntax.Base.v_as_nv",
"typing_Pulse.Syntax.Naming.close_st_term",
"typing_Pulse.Syntax.Naming.close_st_term_",
"typing_Pulse.Syntax.Naming.freevars_st",
"typing_Pulse.Typing.Env.as_map", "typing_Pulse.Typing.Env.fresh",
"typing_Pulse.Typing.Env.fstar_env",
"typing_Pulse.Typing.Env.as_map", "typing_Pulse.Typing.Env.dom",
"typing_Pulse.Typing.Env.fresh",
"typing_Pulse.Typing.Env.push_binding"
],
0,
"25d95b794f02aa77026e3575b7127935"
"b392d6b9fe11f6e3b5eb6649a0773099"
]
]
]
7 changes: 2 additions & 5 deletions lib/steel/pulse/Pulse.Checker.Abs.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ module T = FStar.Tactics.V2

open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Common
open Pulse.Checker.Base

val check_abs
(g:env)
(t:st_term{Tm_Abs? t.term})
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(check:check_t)
: T.Tac (checker_result_t g pre post_hint)
: T.Tac (t:st_term & c:comp & st_typing g t c)
2 changes: 1 addition & 1 deletion lib/steel/pulse/Pulse.Checker.Abs.fsti.hints
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ "ò¥µgÎJ½qŽ>`É fb-", [] ]
[ "\u0004hë\u001c\f\u0011ÇmµuÇT\u000ev.®", [] ]
38 changes: 22 additions & 16 deletions lib/steel/pulse/Pulse.Checker.Admit.fst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Pulse.Checker.Admit

module T = FStar.Tactics.V2
module RT = FStar.Reflection.Typing

open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Common
open Pulse.Checker.Base
open Pulse.Checker.Prover

module FV = Pulse.Typing.FV
module P = Pulse.Syntax.Printer

let post_hint_compatible (p:option post_hint_t) (x:var) (t:term) (u:universe) (post:vprop) =
match p with
Expand All @@ -18,15 +18,20 @@ let post_hint_compatible (p:option post_hint_t) (x:var) (t:term) (u:universe) (p
p.u == u /\
p.ret_ty == t

#push-options "--z3rlimit_factor 4"
let check_admit
let check
(g:env)
(t:st_term{Tm_Admit? t.term})
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })

: T.Tac (checker_result_t g pre post_hint) =

let g = Pulse.Typing.Env.push_context g "check_admit" t.range in

let Tm_Admit { ctag = c; typ=t; post } = t.term in

let x = fresh g in
let px = v_as_nv x in
let res
Expand All @@ -36,9 +41,14 @@ let check_admit
post:vprop { post_hint_compatible post_hint x t u post } &
tot_typing (push_binding g x (fst px) t) post tm_vprop)
= match post, post_hint with
| None, None
| Some _, Some _ ->
fail g None "T_Admit: either no post or two posts"
| None, None ->
fail g None "could not find a post annotation on admit, please add one"

| Some post1, Some post2 ->
fail g None
(Printf.sprintf "found two post annotations on admit: %s and %s, please remove one"
(P.term_to_string post1)
(P.term_to_string post2.post))

| Some post, _ ->
let (| u, t_typing |) = check_universe g t in
Expand All @@ -51,7 +61,7 @@ let check_admit
| _, Some post ->
let post : post_hint_t = post in
if x `Set.mem` freevars post.post
then fail g None "Unexpected freevar clash in Tm_Admit"
then fail g None "Impossible: unexpected freevar clash in Tm_Admit, please file a bug-report"
else (
let post_typing_rec = post_hint_typing g post x in
let post_opened = open_term_nv post.post px in
Expand All @@ -64,9 +74,5 @@ let check_admit
let s : st_comp = {u;res=t;pre;post} in

assume (open_term (close_term post_opened x) x == post_opened);
(|
_, //Tm_Admit c u t None,
comp_admit c s,
T_Admit _ _ c (STC _ s x t_typing pre_typing post_typing)
|)
#pop-options
let d = T_Admit _ _ c (STC _ s x t_typing pre_typing post_typing) in
prove_post_hint (try_frame_pre pre_typing d res_ppname) post_hint t.range
Loading
Loading