effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Steel.ST.Effect.Ghost.STGhost | val ununion_field_and_drop
(#opened: _)
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields))
opened
((has_union_field r field r') `star` (pts_to r' v'))
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\ td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v'))) | [
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ununion_field_and_drop
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields)) opened
(has_union_field r field r' `star` pts_to r' v')
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\
td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v'))
)
= let res = ununion_field r field r' in
drop (has_union_field _ _ _);
res | val ununion_field_and_drop
(#opened: _)
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields))
opened
((has_union_field r field r') `star` (pts_to r' v'))
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\ td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v')))
let ununion_field_and_drop
(#opened: _)
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields))
opened
((has_union_field r field r') `star` (pts_to r' v'))
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\ td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v'))) = | true | null | false | let res = ununion_field r field r' in
drop (has_union_field _ _ _);
res | {
"checked_file": "Steel.ST.C.Types.Union.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.C.Types.Fields.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.C.Typestring.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.Union.fsti"
} | [] | [
"Steel.Memory.inames",
"Prims.string",
"Steel.ST.C.Types.Fields.field_description_t",
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.Union.union_t0",
"Steel.ST.C.Types.Union.union0",
"Steel.ST.C.Types.Fields.field_t",
"Steel.ST.C.Types.Base.typedef",
"FStar.Ghost.erased",
"Prims.unit",
"Steel.ST.Util.drop",
"Steel.ST.C.Types.Union.has_union_field",
"Steel.ST.C.Types.Union.ununion_field",
"Steel.Effect.Common.star",
"Steel.ST.C.Types.Base.pts_to",
"Steel.Effect.Common.vprop",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Steel.ST.C.Types.Fields.__proj__Mkfield_description_t__item__fd_type",
"Steel.ST.C.Types.Fields.__proj__Mkfield_description_t__item__fd_typedef",
"FStar.Ghost.reveal",
"Steel.ST.C.Types.Union.union_set_field",
"FStar.Pervasives.coerce_eq"
] | [] | module Steel.ST.C.Types.Union
open Steel.ST.Util
include Steel.ST.C.Types.Fields
open Steel.C.Typestring
module P = Steel.FractionalPermission
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields
val union_set_field (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) (f: field_t fields) (v: fields.fd_type f) : GTot (union_t0 tn n fields)
val union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
: GTot (option (field_t fields))
val union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
(field: field_t fields)
: Ghost (fields.fd_type field)
(requires (union_get_case u == Some field))
(ensures (fun _ -> True))
val union_get_field_same
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (~ (v == unknown (fields.fd_typedef field))))
(ensures (
let u = union_set_field tn n fields field v in
union_get_case u == Some field /\
union_get_field u field == v
))
[SMTPatOr [
[SMTPat (union_get_case (union_set_field tn n fields field v))];
[SMTPat (union_get_field (union_set_field tn n fields field v) field)];
]]
val union_set_field_same
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
union_set_field tn n fields field (union_get_field s field) == s
))
[SMTPat (union_set_field tn n fields (union_get_field s field))]
[@@noextract_to "krml"] // proof-only
val union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
inline_for_extraction
[@@noextract_to "krml"; norm_field_attr] // proof-only
let union (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
= union0 tn #tf n fields
val union_get_case_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (unknown (union0 tn n fields)) == None)
[SMTPat (unknown (union0 tn n fields))]
val union_set_field_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
: Lemma
(union_set_field tn n fields field (unknown (fields.fd_typedef field)) == unknown (union0 tn n fields))
[SMTPat (union_set_field tn n fields field (unknown (fields.fd_typedef field)))]
val union_get_case_uninitialized
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (uninitialized (union0 tn n fields)) == None)
[SMTPat (uninitialized (union0 tn n fields))]
val mk_fraction_union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: P.perm)
: Lemma
(requires (fractionable (union0 tn n fields) s))
(ensures (
union_get_case (mk_fraction (union0 tn n fields) s p) == union_get_case s
))
[SMTPat (union_get_case (mk_fraction (union0 tn n fields) s p))]
val fractionable_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
fractionable (union0 tn n fields) s <==> fractionable (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (fractionable (union0 tn n fields) s); SMTPat (union_get_field s field)]
val mk_fraction_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: P.perm)
(field: field_t fields)
: Lemma
(requires (fractionable (union0 tn n fields) s /\ union_get_case s == Some field))
(ensures (union_get_field (mk_fraction (union0 tn n fields) s p) field == mk_fraction (fields.fd_typedef field) (union_get_field s field) p))
[SMTPat (union_get_field (mk_fraction (union0 tn n fields) s p) field)]
val mk_fraction_union_set_field
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
(p: P.perm)
: Lemma
(requires (fractionable (fields.fd_typedef field) v))
(ensures (
fractionable (union0 tn n fields) (union_set_field tn n fields field v) /\
mk_fraction (union0 tn n fields) (union_set_field tn n fields field v) p == union_set_field tn n fields field (mk_fraction (fields.fd_typedef field) v p)
))
val full_union
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
full (union0 tn n fields) s <==> full (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (full (union0 tn n fields) s); SMTPat (union_get_field s field)]
let full_union_set_field_intro
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (full (fields.fd_typedef field) v))
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
= full_union (union_set_field tn n fields field v) field
let full_union_set_field_elim
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
(ensures (
full (fields.fd_typedef field) v
))
= full_union (union_set_field tn n fields field v) field
let full_union_set_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires True)
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v) <==> full (fields.fd_typedef field) v
))
[SMTPat (full (union0 tn n fields) (union_set_field tn n fields field v))]
= Classical.move_requires (full_union_set_field_intro #tn #tf #n #fields field) v;
Classical.move_requires (full_union_set_field_elim #tn #tf #n #fields field) v
val has_union_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(r': ref td')
: Tot vprop
val has_union_field_prop
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(r': ref td')
: STGhost unit opened
(has_union_field r field r')
(fun _ -> has_union_field r field r')
True
(fun _ ->
t' == fields.fd_type field /\
td' == fields.fd_typedef field
)
val has_union_field_dup
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: nonempty_field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(r': ref td')
: STGhostT unit opened
(has_union_field r field r')
(fun _ -> has_union_field r field r' `star` has_union_field r field r')
val has_union_field_inj
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: nonempty_field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t1: Type0)
(#td1: typedef t1)
(r1: ref td1)
(#t2: Type0)
(#td2: typedef t2)
(r2: ref td2)
: STGhostT (squash (t1 == t2 /\ td1 == td2)) opened
(has_union_field r field r1 `star` has_union_field r field r2)
(fun _ -> has_union_field r field r1 `star` has_union_field r field r2 `star` ref_equiv r1 (coerce_eq () r2))
val has_union_field_equiv_from
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: nonempty_field_description_t tf)
(r1 r2: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(r': ref td')
: STGhostT unit opened
(has_union_field r1 field r' `star` ref_equiv r1 r2)
(fun _ -> has_union_field r2 field r' `star` ref_equiv r1 r2)
val has_union_field_equiv_to
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: nonempty_field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(r1 r2: ref td')
: STGhostT unit opened
(has_union_field r field r1 `star` ref_equiv r1 r2)
(fun _ -> has_union_field r field r2 `star` ref_equiv r1 r2)
val ghost_union_field_focus
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(#v: Ghost.erased (union_t0 tn n fields))
(r: ref (union0 tn n fields))
(field: field_t fields {union_get_case v == Some field})
(#t': Type0)
(#td': typedef t')
(r': ref td')
: STGhostT (squash (
t' == fields.fd_type field /\
td' == fields.fd_typedef field
)) opened
(has_union_field r field r' `star` pts_to r v)
(fun _ -> has_union_field r field r' `star` pts_to r' (Ghost.hide (coerce_eq () (union_get_field v field))))
val ghost_union_field
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(#v: Ghost.erased (union_t0 tn n fields))
(r: ref (union0 tn n fields))
(field: field_t fields {union_get_case v == Some field})
: STGhostT (Ghost.erased (ref (fields.fd_typedef field))) opened
(pts_to r v)
(fun r' -> has_union_field r field r' `star` pts_to r' (union_get_field v field))
[@@noextract_to "krml"] // primitive
val union_field0
(#tn: Type0)
(#tf: Type0)
(t': Type0)
(#n: string)
(#fields: field_description_t tf)
(#v: Ghost.erased (union_t0 tn n fields))
(r: ref (union0 tn n fields))
(field: field_t fields {union_get_case v == Some field})
(td': typedef t' {
t' == fields.fd_type field /\
td' == fields.fd_typedef field
})
: STT (ref td')
(pts_to r v)
(fun r' -> has_union_field r field r' `star` pts_to r' (Ghost.hide (coerce_eq () (union_get_field v field))))
inline_for_extraction [@@noextract_to "krml"]
let union_field1
(#tn: Type0)
(#tf: Type0)
(t': Type0)
(#n: string)
(#fields: field_description_t tf)
(#v: Ghost.erased (union_t0 tn n fields))
(r: ref (union0 tn n fields))
(field: field_t fields {union_get_case v == Some field})
(td': typedef t')
(sq_t': squash (t' == fields.fd_type field))
(sq_td': squash (td' == fields.fd_typedef field))
: STT (ref td')
(pts_to r v)
(fun r' -> has_union_field r field r' `star` pts_to r' (union_get_field v field))
= union_field0 t' r field td'
inline_for_extraction [@@noextract_to "krml"] // primitive
let union_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(#v: Ghost.erased (union_t0 tn n fields))
(r: ref (union0 tn n fields))
(field: field_t fields {union_get_case v == Some field})
(#t': Type0)
(#td': typedef t')
(# [ norm_fields () ] sq_t': squash (t' == fields.fd_type field))
(# [ norm_fields () ] sq_td': squash (td' == fields.fd_typedef field))
()
: STT (ref td')
(pts_to r v)
(fun r' -> has_union_field r field r' `star` pts_to r' (union_get_field v field))
= union_field0
t'
r
field
td'
val ununion_field
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields)) opened
(has_union_field r field r' `star` pts_to r' v')
(fun res -> has_union_field r field r' `star` pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\
td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v'))
)
let ununion_field_and_drop
(#opened: _)
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields)) opened
(has_union_field r field r' `star` pts_to r' v')
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\
td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v')) | false | false | Steel.ST.C.Types.Union.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ununion_field_and_drop
(#opened: _)
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(r: ref (union0 tn n fields))
(field: field_t fields)
(#t': Type0)
(#td': typedef t')
(#v': Ghost.erased t')
(r': ref td')
: STGhost (Ghost.erased (union_t0 tn n fields))
opened
((has_union_field r field r') `star` (pts_to r' v'))
(fun res -> pts_to r res)
True
(fun res ->
t' == fields.fd_type field /\ td' == fields.fd_typedef field /\
Ghost.reveal res == union_set_field tn n fields field (coerce_eq () (Ghost.reveal v'))) | [] | Steel.ST.C.Types.Union.ununion_field_and_drop | {
"file_name": "lib/steel/c/Steel.ST.C.Types.Union.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Union.union0 tn n fields) ->
field: Steel.ST.C.Types.Fields.field_t fields ->
r': Steel.ST.C.Types.Base.ref td'
-> Steel.ST.Effect.Ghost.STGhost
(FStar.Ghost.erased (Steel.ST.C.Types.Union.union_t0 tn n fields)) | {
"end_col": 5,
"end_line": 458,
"start_col": 1,
"start_line": 456
} |
Prims.Tot | val no_repeats (l: list var) : Type0 | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl | val no_repeats (l: list var) : Type0
let rec no_repeats (l: list var) : Type0 = | false | null | false | match l with
| [] -> True
| x :: tl -> (~(L.memP x tl)) /\ no_repeats tl | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Prims.list",
"Pulse.Syntax.Base.var",
"Prims.l_True",
"Prims.l_and",
"Prims.l_not",
"FStar.List.Tot.Base.memP",
"Pulse.Checker.Prover.Substs.no_repeats"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val no_repeats (l: list var) : Type0 | [
"recursion"
] | Pulse.Checker.Prover.Substs.no_repeats | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | l: Prims.list Pulse.Syntax.Base.var -> Type0 | {
"end_col": 47,
"end_line": 18,
"start_col": 2,
"start_line": 16
} |
Prims.Tot | val as_map (ss:ss_t) : Map.t var term | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_map (ss:ss_t) = ss.m | val as_map (ss:ss_t) : Map.t var term
let as_map (ss: ss_t) = | false | null | false | ss.m | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"FStar.Map.t",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.term"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
} | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_map (ss:ss_t) : Map.t var term | [] | Pulse.Checker.Prover.Substs.as_map | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ss: Pulse.Checker.Prover.Substs.ss_t -> FStar.Map.t Pulse.Syntax.Base.var Pulse.Syntax.Base.term | {
"end_col": 27,
"end_line": 51,
"start_col": 23,
"start_line": 51
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown) | let remove_map (m: ss_map) (x: var) = | false | null | false | Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_map",
"Pulse.Syntax.Base.var",
"FStar.Map.restrict",
"Pulse.Syntax.Base.term",
"FStar.Set.complement",
"FStar.Set.singleton",
"FStar.Map.upd",
"Pulse.Syntax.Base.tm_unknown",
"FStar.Map.t"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
} | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val remove_map : m: Pulse.Checker.Prover.Substs.ss_map -> x: Pulse.Syntax.Base.var
-> FStar.Map.t Pulse.Syntax.Base.var Pulse.Syntax.Base.term | [] | Pulse.Checker.Prover.Substs.remove_map | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | m: Pulse.Checker.Prover.Substs.ss_map -> x: Pulse.Syntax.Base.var
-> FStar.Map.t Pulse.Syntax.Base.var Pulse.Syntax.Base.term | {
"end_col": 74,
"end_line": 27,
"start_col": 2,
"start_line": 27
} |
|
Prims.Tot | val push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t } | val push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t
let push (ss: ss_t) (x: var{~(contains ss x)}) (t: term) : ss_t = | false | null | false | is_dom_push ss.l ss.m x t;
{ l = x :: ss.l; m = Map.upd ss.m x t } | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Syntax.Base.var",
"Prims.l_not",
"Prims.b2t",
"Pulse.Checker.Prover.Substs.contains",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.Mkss_t",
"Prims.Cons",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"FStar.Map.upd",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.unit",
"Pulse.Checker.Prover.Substs.is_dom_push"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t = | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t | [] | Pulse.Checker.Prover.Substs.push | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ss: Pulse.Checker.Prover.Substs.ss_t ->
x: Pulse.Syntax.Base.var{~(Pulse.Checker.Prover.Substs.contains ss x)} ->
t: Pulse.Syntax.Base.term
-> Pulse.Checker.Prover.Substs.ss_t | {
"end_col": 26,
"end_line": 68,
"start_col": 2,
"start_line": 66
} |
Prims.Tot | val is_dom (l: ss_dom) (m: ss_map) : Type0 | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x) | val is_dom (l: ss_dom) (m: ss_map) : Type0
let rec is_dom (l: ss_dom) (m: ss_map) : Type0 = | false | null | false | match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x :: tl -> Map.contains m x /\ is_dom tl (remove_map m x) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_dom",
"Pulse.Checker.Prover.Substs.ss_map",
"FStar.Set.equal",
"Pulse.Syntax.Base.var",
"FStar.Map.domain",
"Pulse.Syntax.Base.term",
"FStar.Set.empty",
"Prims.list",
"Prims.l_and",
"Prims.b2t",
"FStar.Map.contains",
"Pulse.Checker.Prover.Substs.is_dom",
"Pulse.Checker.Prover.Substs.remove_map"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_dom (l: ss_dom) (m: ss_map) : Type0 | [
"recursion"
] | Pulse.Checker.Prover.Substs.is_dom | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | l: Pulse.Checker.Prover.Substs.ss_dom -> m: Pulse.Checker.Prover.Substs.ss_map -> Type0 | {
"end_col": 50,
"end_line": 33,
"start_col": 2,
"start_line": 30
} |
Prims.Tot | val empty : ss_t | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let empty = { l = []; m = Map.const_on Set.empty tm_unknown } | val empty : ss_t
let empty = | false | null | false | { l = []; m = Map.const_on Set.empty tm_unknown } | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.Mkss_t",
"Prims.Nil",
"Pulse.Syntax.Base.var",
"FStar.Map.const_on",
"Pulse.Syntax.Base.term",
"FStar.Set.empty",
"Pulse.Syntax.Base.tm_unknown"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty : ss_t | [] | Pulse.Checker.Prover.Substs.empty | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Checker.Prover.Substs.ss_t | {
"end_col": 59,
"end_line": 53,
"start_col": 14,
"start_line": 53
} |
Prims.Tot | val ss_st_term (t:st_term) (ss:ss_t) : st_term | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss) | val ss_st_term (t:st_term) (ss:ss_t) : st_term
let rec ss_st_term (t: st_term) (ss: ss_t) : Tot st_term (decreases L.length ss.l) = | false | null | false | match ss.l with
| [] -> t
| y :: tl ->
let t = subst_st_term t [NT y (Map.sel ss.m y)] in
ss_st_term t (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Syntax.Base.st_term",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_st_term",
"Pulse.Checker.Prover.Substs.tail",
"Pulse.Syntax.Naming.subst_st_term",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_st_term (t:st_term) (ss:ss_t) : st_term | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_st_term | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Pulse.Syntax.Base.st_term -> ss: Pulse.Checker.Prover.Substs.ss_t
-> Prims.Tot Pulse.Syntax.Base.st_term | {
"end_col": 26,
"end_line": 146,
"start_col": 2,
"start_line": 142
} |
Prims.Tot | val ss_term (t:term) (ss:ss_t) : term | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss) | val ss_term (t:term) (ss:ss_t) : term
let rec ss_term (t: term) (ss: ss_t) : Tot term (decreases L.length ss.l) = | false | null | false | match ss.l with
| [] -> t
| y :: tl ->
let t = subst_term t [NT y (Map.sel ss.m y)] in
ss_term t (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_term",
"Pulse.Checker.Prover.Substs.tail",
"Pulse.Syntax.Naming.subst_term",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x)) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_term (t:term) (ss:ss_t) : term | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_term | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Pulse.Syntax.Base.term -> ss: Pulse.Checker.Prover.Substs.ss_t
-> Prims.Tot Pulse.Syntax.Base.term | {
"end_col": 23,
"end_line": 139,
"start_col": 2,
"start_line": 135
} |
Prims.Tot | val ss_st_comp (s:st_comp) (ss:ss_t) : st_comp | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss) | val ss_st_comp (s:st_comp) (ss:ss_t) : st_comp
let rec ss_st_comp (s: st_comp) (ss: ss_t) : Tot st_comp (decreases L.length ss.l) = | false | null | false | match ss.l with
| [] -> s
| y :: tl ->
let s = subst_st_comp s [NT y (Map.sel ss.m y)] in
ss_st_comp s (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Syntax.Base.st_comp",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_st_comp",
"Pulse.Checker.Prover.Substs.tail",
"Pulse.Syntax.Naming.subst_st_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_st_comp (s:st_comp) (ss:ss_t) : st_comp | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_st_comp | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | s: Pulse.Syntax.Base.st_comp -> ss: Pulse.Checker.Prover.Substs.ss_t
-> Prims.Tot Pulse.Syntax.Base.st_comp | {
"end_col": 26,
"end_line": 154,
"start_col": 2,
"start_line": 150
} |
Prims.Tot | val tail (ss: ss_t{Cons? ss.l}) : ss_t | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) } | val tail (ss: ss_t{Cons? ss.l}) : ss_t
let tail (ss: ss_t{Cons? ss.l}) : ss_t = | false | null | false | { l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) } | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Prims.b2t",
"Prims.uu___is_Cons",
"Pulse.Syntax.Base.var",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Checker.Prover.Substs.Mkss_t",
"FStar.List.Tot.Base.tl",
"Pulse.Checker.Prover.Substs.remove_map",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"FStar.List.Tot.Base.hd"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t } | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tail (ss: ss_t{Cons? ss.l}) : ss_t | [] | Pulse.Checker.Prover.Substs.tail | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ss: Pulse.Checker.Prover.Substs.ss_t{Cons? (Mkss_t?.l ss)} -> Pulse.Checker.Prover.Substs.ss_t | {
"end_col": 51,
"end_line": 71,
"start_col": 5,
"start_line": 71
} |
Prims.Tot | val ss_binder (b:binder) (ss:ss_t) : binder | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss) | val ss_binder (b:binder) (ss:ss_t) : binder
let rec ss_binder (b: binder) (ss: ss_t) : Tot binder (decreases L.length ss.l) = | false | null | false | match ss.l with
| [] -> b
| y :: tl ->
let b = subst_binder b [NT y (Map.sel ss.m y)] in
ss_binder b (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Syntax.Base.binder",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_binder",
"Pulse.Checker.Prover.Substs.tail",
"Pulse.Syntax.Naming.subst_binder",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_binder (b:binder) (ss:ss_t) : binder | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_binder | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | b: Pulse.Syntax.Base.binder -> ss: Pulse.Checker.Prover.Substs.ss_t
-> Prims.Tot Pulse.Syntax.Base.binder | {
"end_col": 25,
"end_line": 170,
"start_col": 2,
"start_line": 166
} |
Prims.Tot | val ss_comp (c:comp) (ss:ss_t) : comp | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss) | val ss_comp (c:comp) (ss:ss_t) : comp
let rec ss_comp (c: comp) (ss: ss_t) : Tot comp (decreases L.length ss.l) = | false | null | false | match ss.l with
| [] -> c
| y :: tl ->
let c = subst_comp c [NT y (Map.sel ss.m y)] in
ss_comp c (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Syntax.Base.comp",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_comp",
"Pulse.Checker.Prover.Substs.tail",
"Pulse.Syntax.Naming.subst_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t) | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_comp (c:comp) (ss:ss_t) : comp | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_comp | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | c: Pulse.Syntax.Base.comp -> ss: Pulse.Checker.Prover.Substs.ss_t
-> Prims.Tot Pulse.Syntax.Base.comp | {
"end_col": 23,
"end_line": 162,
"start_col": 2,
"start_line": 158
} |
Prims.Pure | val remove_l (l: ss_dom) (x: var{L.memP x l})
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y: var). L.memP y r <==> (L.memP y l /\ y =!= x)) | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x) | val remove_l (l: ss_dom) (x: var{L.memP x l})
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y: var). L.memP y r <==> (L.memP y l /\ y =!= x))
let rec remove_l (l: ss_dom) (x: var{L.memP x l})
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y: var). L.memP y r <==> (L.memP y l /\ y =!= x)) = | false | null | false | match l with
| [] ->
assert False;
[]
| y :: tl -> if y = x then tl else y :: (remove_l tl x) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [] | [
"Pulse.Checker.Prover.Substs.ss_dom",
"Pulse.Syntax.Base.var",
"FStar.List.Tot.Base.memP",
"Prims.Nil",
"Prims.unit",
"Prims._assert",
"Prims.l_False",
"Prims.list",
"Prims.op_Equality",
"Prims.bool",
"Prims.Cons",
"Pulse.Checker.Prover.Substs.remove_l",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_iff",
"Prims.l_and",
"Prims.l_not",
"Prims.eq2"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val remove_l (l: ss_dom) (x: var{L.memP x l})
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y: var). L.memP y r <==> (L.memP y l /\ y =!= x)) | [
"recursion"
] | Pulse.Checker.Prover.Substs.remove_l | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | l: Pulse.Checker.Prover.Substs.ss_dom -> x: Pulse.Syntax.Base.var{FStar.List.Tot.Base.memP x l}
-> Prims.Pure Pulse.Checker.Prover.Substs.ss_dom | {
"end_col": 27,
"end_line": 113,
"start_col": 2,
"start_line": 109
} |
Prims.Tot | val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x} | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x | val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x}
let coerce_eq (#a: Type) (#b: Type) (x: a) (_: squash (a == b)) : y: b{y == x} = | false | null | false | x | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Prims.squash",
"Prims.eq2"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x} | [] | Pulse.Checker.Prover.Substs.coerce_eq | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: a -> _: Prims.squash (a == b) -> y: b{y == x} | {
"end_col": 71,
"end_line": 13,
"start_col": 70,
"start_line": 13
} |
Prims.Tot | val is_permutation (nts:nt_substs) (ss:ss_t) : Type0 | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec is_permutation (nts:nt_substs) (ss:ss_t) : Type0 =
match nts, ss.l with
| [], [] -> True
| (NT x e)::nts_rest, _::_ ->
Map.contains ss.m x /\
Map.sel ss.m x == e /\
is_permutation nts_rest ({l=remove_l ss.l x; m=remove_map ss.m x})
| _ -> False | val is_permutation (nts:nt_substs) (ss:ss_t) : Type0
let rec is_permutation (nts: nt_substs) (ss: ss_t) : Type0 = | false | null | false | match nts, ss.l with
| [], [] -> True
| NT x e :: nts_rest, _ :: _ ->
Map.contains ss.m x /\ Map.sel ss.m x == e /\
is_permutation nts_rest ({ l = remove_l ss.l x; m = remove_map ss.m x })
| _ -> False | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"total"
] | [
"Pulse.Checker.Prover.Substs.nt_substs",
"Pulse.Checker.Prover.Substs.ss_t",
"FStar.Pervasives.Native.Mktuple2",
"Prims.list",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Base.var",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Prims.l_True",
"Pulse.Syntax.Base.term",
"Prims.l_and",
"Prims.b2t",
"FStar.Map.contains",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.eq2",
"FStar.Map.sel",
"Pulse.Checker.Prover.Substs.is_permutation",
"Pulse.Checker.Prover.Substs.Mkss_t",
"Pulse.Checker.Prover.Substs.remove_l",
"Pulse.Checker.Prover.Substs.remove_map",
"FStar.Pervasives.Native.tuple2",
"Prims.l_False"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss)
let rec ss_env (g:env) (ss:ss_t)
: Tot (g':env { fstar_env g' == fstar_env g /\
Env.dom g' == Env.dom g })
(decreases L.length ss.l) =
admit ();
match ss.l with
| [] -> g
| y::tl -> ss_env (subst_env g [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_st_comp_commutes (subst_st_comp s [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l)
[SMTPat (ss_comp c ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_comp_commutes (subst_comp c [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
(decreases nts)
[SMTPat (nt_subst_st_comp s nts)] =
match nts with
| [] -> ()
| (NT x e)::nts_tl -> nt_substs_st_comp_commutes (nt_subst_st_comp s [ NT x e ]) nts_tl
let rec nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
(decreases nts)
[SMTPat (nt_subst_comp c nts)] =
match nts with
| [] -> ()
| (NT x e)::nts_tl -> nt_subst_comp_commutes (nt_subst_comp c [ NT x e ]) nts_tl | false | true | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_permutation (nts:nt_substs) (ss:ss_t) : Type0 | [
"recursion"
] | Pulse.Checker.Prover.Substs.is_permutation | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | nts: Pulse.Checker.Prover.Substs.nt_substs -> ss: Pulse.Checker.Prover.Substs.ss_t -> Type0 | {
"end_col": 14,
"end_line": 242,
"start_col": 2,
"start_line": 236
} |
FStar.Pervasives.Lemma | val ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
[SMTPat (ss_st_comp s ss)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_st_comp_commutes (subst_st_comp s [ NT y (Map.sel ss.m y) ]) (tail ss) | val ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
[SMTPat (ss_st_comp s ss)]
let rec ss_st_comp_commutes (s: st_comp) (ss: ss_t)
: Lemma
(ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss; pre = ss_term s.pre ss; post = ss_term s.post ss })
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] = | false | null | true | match ss.l with
| [] -> ()
| y :: tl -> ss_st_comp_commutes (subst_st_comp s [NT y (Map.sel ss.m y)]) (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"lemma"
] | [
"Pulse.Syntax.Base.st_comp",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_st_comp_commutes",
"Pulse.Syntax.Naming.subst_st_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil",
"Pulse.Checker.Prover.Substs.tail",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Pulse.Checker.Prover.Substs.ss_st_comp",
"Pulse.Syntax.Base.Mkst_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Checker.Prover.Substs.ss_term",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss)
let rec ss_env (g:env) (ss:ss_t)
: Tot (g':env { fstar_env g' == fstar_env g /\
Env.dom g' == Env.dom g })
(decreases L.length ss.l) =
admit ();
match ss.l with
| [] -> g
| y::tl -> ss_env (subst_env g [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
[SMTPat (ss_st_comp s ss)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_st_comp_commutes | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | s: Pulse.Syntax.Base.st_comp -> ss: Pulse.Checker.Prover.Substs.ss_t
-> FStar.Pervasives.Lemma
(ensures
Pulse.Checker.Prover.Substs.ss_st_comp s ss ==
Pulse.Syntax.Base.Mkst_comp (Mkst_comp?.u s)
(Pulse.Checker.Prover.Substs.ss_term (Mkst_comp?.res s) ss)
(Pulse.Checker.Prover.Substs.ss_term (Mkst_comp?.pre s) ss)
(Pulse.Checker.Prover.Substs.ss_term (Mkst_comp?.post s) ss))
(decreases FStar.List.Tot.Base.length (Mkss_t?.l ss))
[SMTPat (Pulse.Checker.Prover.Substs.ss_st_comp s ss)] | {
"end_col": 86,
"end_line": 191,
"start_col": 2,
"start_line": 189
} |
FStar.Pervasives.Lemma | val nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
[SMTPat (nt_subst_st_comp s nts)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
(decreases nts)
[SMTPat (nt_subst_st_comp s nts)] =
match nts with
| [] -> ()
| (NT x e)::nts_tl -> nt_substs_st_comp_commutes (nt_subst_st_comp s [ NT x e ]) nts_tl | val nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
[SMTPat (nt_subst_st_comp s nts)]
let rec nt_substs_st_comp_commutes (s: st_comp) (nts: nt_substs)
: Lemma
(ensures
nt_subst_st_comp s nts ==
{
s with
res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts
}) (decreases nts) [SMTPat (nt_subst_st_comp s nts)] = | false | null | true | match nts with
| [] -> ()
| NT x e :: nts_tl -> nt_substs_st_comp_commutes (nt_subst_st_comp s [NT x e]) nts_tl | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"lemma"
] | [
"Pulse.Syntax.Base.st_comp",
"Pulse.Checker.Prover.Substs.nt_substs",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.term",
"Prims.list",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Checker.Prover.Substs.nt_substs_st_comp_commutes",
"Pulse.Checker.Prover.Substs.nt_subst_st_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.NT",
"Prims.Nil",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Pulse.Syntax.Base.Mkst_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Checker.Prover.Substs.nt_subst_term",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss)
let rec ss_env (g:env) (ss:ss_t)
: Tot (g':env { fstar_env g' == fstar_env g /\
Env.dom g' == Env.dom g })
(decreases L.length ss.l) =
admit ();
match ss.l with
| [] -> g
| y::tl -> ss_env (subst_env g [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_st_comp_commutes (subst_st_comp s [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l)
[SMTPat (ss_comp c ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_comp_commutes (subst_comp c [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
(decreases nts) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
[SMTPat (nt_subst_st_comp s nts)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.nt_substs_st_comp_commutes | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | s: Pulse.Syntax.Base.st_comp -> nts: Pulse.Checker.Prover.Substs.nt_substs
-> FStar.Pervasives.Lemma
(ensures
Pulse.Checker.Prover.Substs.nt_subst_st_comp s nts ==
Pulse.Syntax.Base.Mkst_comp (Mkst_comp?.u s)
(Pulse.Checker.Prover.Substs.nt_subst_term (Mkst_comp?.res s) nts)
(Pulse.Checker.Prover.Substs.nt_subst_term (Mkst_comp?.pre s) nts)
(Pulse.Checker.Prover.Substs.nt_subst_term (Mkst_comp?.post s) nts))
(decreases nts)
[SMTPat (Pulse.Checker.Prover.Substs.nt_subst_st_comp s nts)] | {
"end_col": 89,
"end_line": 218,
"start_col": 2,
"start_line": 216
} |
FStar.Pervasives.Lemma | val is_dom_mem (l: ss_dom) (m: ss_map)
: Lemma (requires is_dom l m)
(ensures
forall (x: var). {:pattern L.memP x l\/Map.contains m x} L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y) | val is_dom_mem (l: ss_dom) (m: ss_map)
: Lemma (requires is_dom l m)
(ensures
forall (x: var). {:pattern L.memP x l\/Map.contains m x} L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)]
let rec is_dom_mem (l: ss_dom) (m: ss_map)
: Lemma (requires is_dom l m)
(ensures
forall (x: var). {:pattern L.memP x l\/Map.contains m x} L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] = | false | null | true | match l with
| [] -> ()
| y :: tl -> is_dom_mem tl (remove_map m y) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"lemma"
] | [
"Pulse.Checker.Prover.Substs.ss_dom",
"Pulse.Checker.Prover.Substs.ss_map",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.is_dom_mem",
"Pulse.Checker.Prover.Substs.remove_map",
"Prims.unit",
"Pulse.Checker.Prover.Substs.is_dom",
"Prims.squash",
"Prims.l_Forall",
"Prims.l_iff",
"FStar.List.Tot.Base.memP",
"Prims.b2t",
"FStar.Map.contains",
"Pulse.Syntax.Base.term",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_dom_mem (l: ss_dom) (m: ss_map)
: Lemma (requires is_dom l m)
(ensures
forall (x: var). {:pattern L.memP x l\/Map.contains m x} L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.is_dom_mem | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | l: Pulse.Checker.Prover.Substs.ss_dom -> m: Pulse.Checker.Prover.Substs.ss_map
-> FStar.Pervasives.Lemma (requires Pulse.Checker.Prover.Substs.is_dom l m)
(ensures
forall (x: Pulse.Syntax.Base.var).
{:pattern FStar.List.Tot.Base.memP x l\/FStar.Map.contains m x}
FStar.List.Tot.Base.memP x l <==> FStar.Map.contains m x)
[SMTPat (Pulse.Checker.Prover.Substs.is_dom l m)] | {
"end_col": 43,
"end_line": 43,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) }) : ss_t | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2) | val push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) }) : ss_t
let rec push_ss (ss1: ss_t) (ss2: ss_t{Set.disjoint (dom ss1) (dom ss2)})
: Tot ss_t (decreases L.length ss2.l) = | false | null | false | match ss2.l with
| [] -> ss1
| x :: tl -> push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"total"
] | [
"Pulse.Checker.Prover.Substs.ss_t",
"FStar.Set.disjoint",
"Pulse.Syntax.Base.var",
"Pulse.Checker.Prover.Substs.dom",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Prims.list",
"Pulse.Checker.Prover.Substs.push_ss",
"Pulse.Checker.Prover.Substs.push",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Pulse.Checker.Prover.Substs.tail"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) }) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) }) : ss_t | [
"recursion"
] | Pulse.Checker.Prover.Substs.push_ss | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ss1: Pulse.Checker.Prover.Substs.ss_t ->
ss2:
Pulse.Checker.Prover.Substs.ss_t
{ FStar.Set.disjoint (Pulse.Checker.Prover.Substs.dom ss1)
(Pulse.Checker.Prover.Substs.dom ss2) }
-> Prims.Tot Pulse.Checker.Prover.Substs.ss_t | {
"end_col": 53,
"end_line": 78,
"start_col": 2,
"start_line": 75
} |
FStar.Pervasives.Lemma | val push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures as_map (push_ss ss1 ss2) == Map.concat (as_map ss1) (as_map ss2))
[SMTPat (as_map (push_ss ss1 ss2))] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
() | val push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures as_map (push_ss ss1 ss2) == Map.concat (as_map ss1) (as_map ss2))
[SMTPat (as_map (push_ss ss1 ss2))]
let push_as_map (ss1 ss2: ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2)) (Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] = | false | null | true | let rec aux (ss1 ss2: ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2)) (Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x :: tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
() | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"lemma"
] | [
"Pulse.Checker.Prover.Substs.ss_t",
"Prims.unit",
"FStar.List.Tot.Base.length",
"Pulse.Syntax.Base.var",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"FStar.Set.disjoint",
"Pulse.Checker.Prover.Substs.dom",
"Prims.squash",
"FStar.Map.equal",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.as_map",
"Pulse.Checker.Prover.Substs.push_ss",
"FStar.Map.concat",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Prims.list",
"Pulse.Checker.Prover.Substs.push",
"FStar.Map.sel",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Pulse.Checker.Prover.Substs.tail",
"FStar.Map.t"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2))) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures as_map (push_ss ss1 ss2) == Map.concat (as_map ss1) (as_map ss2))
[SMTPat (as_map (push_ss ss1 ss2))] | [] | Pulse.Checker.Prover.Substs.push_as_map | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ss1: Pulse.Checker.Prover.Substs.ss_t -> ss2: Pulse.Checker.Prover.Substs.ss_t
-> FStar.Pervasives.Lemma
(requires
FStar.Set.disjoint (Pulse.Checker.Prover.Substs.dom ss1)
(Pulse.Checker.Prover.Substs.dom ss2))
(ensures
Pulse.Checker.Prover.Substs.as_map (Pulse.Checker.Prover.Substs.push_ss ss1 ss2) ==
FStar.Map.concat (Pulse.Checker.Prover.Substs.as_map ss1)
(Pulse.Checker.Prover.Substs.as_map ss2))
[SMTPat (Pulse.Checker.Prover.Substs.as_map (Pulse.Checker.Prover.Substs.push_ss ss1 ss2))] | {
"end_col": 4,
"end_line": 102,
"start_col": 47,
"start_line": 90
} |
FStar.Pervasives.Lemma | val is_dom_push (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{~(Map.contains m x)}) (t: term)
: Lemma (is_dom (x :: l) (Map.upd m x t)) | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m) | val is_dom_push (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{~(Map.contains m x)}) (t: term)
: Lemma (is_dom (x :: l) (Map.upd m x t))
let is_dom_push (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{~(Map.contains m x)}) (t: term)
: Lemma (is_dom (x :: l) (Map.upd m x t)) = | false | null | true | assert (Map.equal (remove_map (Map.upd m x t) x) m) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"lemma"
] | [
"Pulse.Checker.Prover.Substs.ss_dom",
"Pulse.Checker.Prover.Substs.ss_map",
"Pulse.Checker.Prover.Substs.is_dom",
"Pulse.Syntax.Base.var",
"Prims.l_not",
"Prims.b2t",
"FStar.Map.contains",
"Pulse.Syntax.Base.term",
"Prims._assert",
"FStar.Map.equal",
"Pulse.Checker.Prover.Substs.remove_map",
"FStar.Map.upd",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) = | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_dom_push (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{~(Map.contains m x)}) (t: term)
: Lemma (is_dom (x :: l) (Map.upd m x t)) | [] | Pulse.Checker.Prover.Substs.is_dom_push | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
l: Pulse.Checker.Prover.Substs.ss_dom ->
m: Pulse.Checker.Prover.Substs.ss_map{Pulse.Checker.Prover.Substs.is_dom l m} ->
x: Pulse.Syntax.Base.var{~(FStar.Map.contains m x)} ->
t: Pulse.Syntax.Base.term
-> FStar.Pervasives.Lemma
(ensures Pulse.Checker.Prover.Substs.is_dom (x :: l) (FStar.Map.upd m x t)) | {
"end_col": 53,
"end_line": 62,
"start_col": 2,
"start_line": 62
} |
FStar.Pervasives.Lemma | val ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
[SMTPat (ss_comp c ss)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l)
[SMTPat (ss_comp c ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_comp_commutes (subst_comp c [ NT y (Map.sel ss.m y) ]) (tail ss) | val ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
[SMTPat (ss_comp c ss)]
let rec ss_comp_commutes (c: comp) (ss: ss_t)
: Lemma
(ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==>
r == C_STAtomic (ss_term (comp_inames c) ss) (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==>
r == C_STGhost (ss_term (comp_inames c) ss) (ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l)
[SMTPat (ss_comp c ss)] = | false | null | true | match ss.l with
| [] -> ()
| y :: tl -> ss_comp_commutes (subst_comp c [NT y (Map.sel ss.m y)]) (tail ss) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"lemma"
] | [
"Pulse.Syntax.Base.comp",
"Pulse.Checker.Prover.Substs.ss_t",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__l",
"Pulse.Syntax.Base.var",
"Prims.list",
"Pulse.Checker.Prover.Substs.ss_comp_commutes",
"Pulse.Syntax.Naming.subst_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.NT",
"FStar.Map.sel",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Prover.Substs.__proj__Mkss_t__item__m",
"Prims.Nil",
"Pulse.Checker.Prover.Substs.tail",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Prims.l_imp",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_Tot",
"Prims.eq2",
"Pulse.Syntax.Base.C_Tot",
"Pulse.Checker.Prover.Substs.ss_term",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.uu___is_C_ST",
"Pulse.Syntax.Base.C_ST",
"Pulse.Checker.Prover.Substs.ss_st_comp",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Syntax.Base.uu___is_C_STAtomic",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Syntax.Base.comp_inames",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Syntax.Base.C_STGhost",
"Pulse.Checker.Prover.Substs.ss_comp",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss)
let rec ss_env (g:env) (ss:ss_t)
: Tot (g':env { fstar_env g' == fstar_env g /\
Env.dom g' == Env.dom g })
(decreases L.length ss.l) =
admit ();
match ss.l with
| [] -> g
| y::tl -> ss_env (subst_env g [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_st_comp_commutes (subst_st_comp s [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
[SMTPat (ss_comp c ss)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.ss_comp_commutes | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | c: Pulse.Syntax.Base.comp -> ss: Pulse.Checker.Prover.Substs.ss_t
-> FStar.Pervasives.Lemma
(ensures
(let r = Pulse.Checker.Prover.Substs.ss_comp c ss in
(C_Tot? c ==>
r ==
Pulse.Syntax.Base.C_Tot
(Pulse.Checker.Prover.Substs.ss_term (Pulse.Syntax.Base.comp_res c) ss)) /\
(C_ST? c ==>
r ==
Pulse.Syntax.Base.C_ST
(Pulse.Checker.Prover.Substs.ss_st_comp (Pulse.Syntax.Base.st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==>
r ==
Pulse.Syntax.Base.C_STAtomic
(Pulse.Checker.Prover.Substs.ss_term (Pulse.Syntax.Base.comp_inames c) ss)
(Pulse.Checker.Prover.Substs.ss_st_comp (Pulse.Syntax.Base.st_comp_of_comp c) ss)) /\
(C_STGhost? c ==>
r ==
Pulse.Syntax.Base.C_STGhost
(Pulse.Checker.Prover.Substs.ss_term (Pulse.Syntax.Base.comp_inames c) ss)
(Pulse.Checker.Prover.Substs.ss_st_comp (Pulse.Syntax.Base.st_comp_of_comp c) ss))))
(decreases FStar.List.Tot.Base.length (Mkss_t?.l ss))
[SMTPat (Pulse.Checker.Prover.Substs.ss_comp c ss)] | {
"end_col": 80,
"end_line": 206,
"start_col": 2,
"start_line": 204
} |
FStar.Pervasives.Lemma | val is_dom_remove (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{Map.contains m x})
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x)) | val is_dom_remove (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{Map.contains m x})
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)]
let rec is_dom_remove (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{Map.contains m x})
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] = | false | null | true | match l with
| [] -> ()
| y :: tl ->
if x = y
then ()
else
let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y) (remove_map m x)) | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"lemma"
] | [
"Pulse.Checker.Prover.Substs.ss_dom",
"Pulse.Checker.Prover.Substs.ss_map",
"Pulse.Checker.Prover.Substs.is_dom",
"Pulse.Syntax.Base.var",
"Prims.b2t",
"FStar.Map.contains",
"Pulse.Syntax.Base.term",
"Prims.list",
"Prims.op_Equality",
"Prims.bool",
"Prims._assert",
"FStar.Map.equal",
"FStar.Map.upd",
"Pulse.Checker.Prover.Substs.remove_map",
"Prims.unit",
"Pulse.Checker.Prover.Substs.is_dom_push",
"Pulse.Checker.Prover.Substs.remove_l",
"Pulse.Checker.Prover.Substs.is_dom_remove",
"FStar.Map.t",
"FStar.Map.sel",
"Prims.l_True",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] = | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_dom_remove (l: ss_dom) (m: ss_map{is_dom l m}) (x: var{Map.contains m x})
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.is_dom_remove | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
l: Pulse.Checker.Prover.Substs.ss_dom ->
m: Pulse.Checker.Prover.Substs.ss_map{Pulse.Checker.Prover.Substs.is_dom l m} ->
x: Pulse.Syntax.Base.var{FStar.Map.contains m x}
-> FStar.Pervasives.Lemma
(ensures
Pulse.Checker.Prover.Substs.is_dom (Pulse.Checker.Prover.Substs.remove_l l x)
(Pulse.Checker.Prover.Substs.remove_map m x))
[
SMTPat (Pulse.Checker.Prover.Substs.remove_l l x);
SMTPat (Pulse.Checker.Prover.Substs.remove_map m x)
] | {
"end_col": 44,
"end_line": 132,
"start_col": 2,
"start_line": 122
} |
FStar.Pervasives.Lemma | val nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
[SMTPat (nt_subst_comp c nts)] | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "Env"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Env",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
(decreases nts)
[SMTPat (nt_subst_comp c nts)] =
match nts with
| [] -> ()
| (NT x e)::nts_tl -> nt_subst_comp_commutes (nt_subst_comp c [ NT x e ]) nts_tl | val nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
[SMTPat (nt_subst_comp c nts)]
let rec nt_subst_comp_commutes (c: comp) (nts: nt_substs)
: Lemma
(ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==>
r ==
C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==>
r ==
C_STGhost (nt_subst_term (comp_inames c) nts) (nt_subst_st_comp (st_comp_of_comp c) nts)
))) (decreases nts) [SMTPat (nt_subst_comp c nts)] = | false | null | true | match nts with
| [] -> ()
| NT x e :: nts_tl -> nt_subst_comp_commutes (nt_subst_comp c [NT x e]) nts_tl | {
"checked_file": "Pulse.Checker.Prover.Substs.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Substs.fst"
} | [
"",
"lemma"
] | [
"Pulse.Syntax.Base.comp",
"Pulse.Checker.Prover.Substs.nt_substs",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.term",
"Prims.list",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Checker.Prover.Substs.nt_subst_comp_commutes",
"Pulse.Checker.Prover.Substs.nt_subst_comp",
"Prims.Cons",
"Pulse.Syntax.Naming.NT",
"Prims.Nil",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Prims.l_imp",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_C_Tot",
"Prims.eq2",
"Pulse.Syntax.Base.C_Tot",
"Pulse.Checker.Prover.Substs.nt_subst_term",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.uu___is_C_ST",
"Pulse.Syntax.Base.C_ST",
"Pulse.Checker.Prover.Substs.nt_subst_st_comp",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Syntax.Base.uu___is_C_STAtomic",
"Pulse.Syntax.Base.C_STAtomic",
"Pulse.Syntax.Base.comp_inames",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Syntax.Base.C_STGhost",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | module Pulse.Checker.Prover.Substs
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing.Env
open Pulse.Typing
module L = FStar.List.Tot
module Env = Pulse.Typing.Env
module Metatheory = Pulse.Typing.Metatheory
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b {y == x} = x
let rec no_repeats (l:list var) : Type0 =
match l with
| [] -> True
| x::tl -> (~ (L.memP x tl)) /\ no_repeats tl
type ss_dom = l:list var { no_repeats l }
type ss_map = m:Map.t var term {
forall (x:var). (~ (Map.contains m x)) ==> Map.sel m x == tm_unknown
}
let remove_map (m:ss_map) (x:var) =
Map.restrict (Set.complement (Set.singleton x)) (Map.upd m x tm_unknown)
let rec is_dom (l:ss_dom) (m:ss_map) : Type0 =
match l with
| [] -> Set.equal (Map.domain m) Set.empty
| x::tl ->
Map.contains m x /\ is_dom tl (remove_map m x)
let rec is_dom_mem (l:ss_dom) (m:ss_map)
: Lemma
(requires is_dom l m)
(ensures forall (x:var).{:pattern L.memP x l \/ Map.contains m x}
L.memP x l <==> Map.contains m x)
[SMTPat (is_dom l m)] =
match l with
| [] -> ()
| y::tl -> is_dom_mem tl (remove_map m y)
noeq
type ss_t = {
l : ss_dom;
m : m:ss_map { is_dom l m }
}
let as_map (ss:ss_t) = ss.m
let empty = { l = []; m = Map.const_on Set.empty tm_unknown }
let is_dom_push
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { ~ (Map.contains m x ) })
(t:term)
: Lemma (is_dom (x::l) (Map.upd m x t)) =
assert (Map.equal (remove_map (Map.upd m x t) x) m)
let push (ss:ss_t) (x:var { ~ (contains ss x) }) (t:term) : ss_t =
is_dom_push ss.l ss.m x t;
{ l = x::ss.l;
m = Map.upd ss.m x t }
let tail (ss:ss_t { Cons? ss.l }) : ss_t =
{ l = L.tl ss.l; m = remove_map ss.m (L.hd ss.l) }
let rec push_ss (ss1:ss_t) (ss2:ss_t { Set.disjoint (dom ss1) (dom ss2) })
: Tot ss_t (decreases L.length ss2.l) =
match ss2.l with
| [] -> ss1
| x::tl ->
push_ss (push ss1 x (Map.sel ss2.m x)) (tail ss2)
let check_disjoint ss1 ss2 =
admit ();
not (L.existsb (fun v1 -> L.mem v1 ss2.l) ss1.l)
#push-options "--warn_error -271"
let push_as_map (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat (as_map (push_ss ss1 ss2))] =
let rec aux (ss1 ss2:ss_t)
: Lemma (requires Set.disjoint (dom ss1) (dom ss2))
(ensures Map.equal (as_map (push_ss ss1 ss2))
(Map.concat (as_map ss1) (as_map ss2)))
(decreases L.length ss2.l)
[SMTPat ()] =
match ss2.l with
| [] -> ()
| x::tl -> aux (push ss1 x (Map.sel ss2.m x)) (tail ss2)
in
()
#pop-options
let rec remove_l (l:ss_dom) (x:var { L.memP x l })
: Pure ss_dom
(requires True)
(ensures fun r -> forall (y:var). L.memP y r <==> (L.memP y l /\ y =!= x)) =
match l with
| [] -> assert False; []
| y::tl ->
if y = x then tl
else y::(remove_l tl x)
let rec is_dom_remove
(l:ss_dom)
(m:ss_map { is_dom l m })
(x:var { Map.contains m x })
: Lemma (is_dom (remove_l l x) (remove_map m x))
[SMTPat (remove_l l x); SMTPat (remove_map m x)] =
match l with
| [] -> ()
| y::tl ->
if x = y then ()
else let t_y = Map.sel m y in
let m1 = remove_map m y in
is_dom_remove tl m1 x;
assert (is_dom (remove_l tl x) (remove_map m1 x));
is_dom_push (remove_l tl x) (remove_map m1 x) y t_y;
assert (Map.equal (Map.upd (remove_map m1 x) y t_y)
(remove_map m x))
let rec ss_term (t:term) (ss:ss_t) : Tot term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_term t [ NT y (Map.sel ss.m y) ] in
ss_term t (tail ss)
let rec ss_st_term (t:st_term) (ss:ss_t) : Tot st_term (decreases L.length ss.l) =
match ss.l with
| [] -> t
| y::tl ->
let t = subst_st_term t [ NT y (Map.sel ss.m y) ] in
ss_st_term t (tail ss)
let rec ss_st_comp (s:st_comp) (ss:ss_t)
: Tot st_comp (decreases L.length ss.l) =
match ss.l with
| [] -> s
| y::tl ->
let s = subst_st_comp s [ NT y (Map.sel ss.m y) ] in
ss_st_comp s (tail ss)
let rec ss_comp (c:comp) (ss:ss_t)
: Tot comp (decreases L.length ss.l) =
match ss.l with
| [] -> c
| y::tl ->
let c = subst_comp c [ NT y (Map.sel ss.m y) ] in
ss_comp c (tail ss)
let rec ss_binder (b:binder) (ss:ss_t)
: Tot binder (decreases L.length ss.l) =
match ss.l with
| [] -> b
| y::tl ->
let b = subst_binder b [ NT y (Map.sel ss.m y) ] in
ss_binder b (tail ss)
let rec ss_env (g:env) (ss:ss_t)
: Tot (g':env { fstar_env g' == fstar_env g /\
Env.dom g' == Env.dom g })
(decreases L.length ss.l) =
admit ();
match ss.l with
| [] -> g
| y::tl -> ss_env (subst_env g [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_st_comp_commutes (s:st_comp) (ss:ss_t)
: Lemma (ensures
ss_st_comp s ss ==
{ s with res = ss_term s.res ss;
pre = ss_term s.pre ss;
post = ss_term s.post ss; }) // no shifting required
(decreases L.length ss.l)
[SMTPat (ss_st_comp s ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_st_comp_commutes (subst_st_comp s [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec ss_comp_commutes (c:comp) (ss:ss_t)
: Lemma (ensures
(let r = ss_comp c ss in
(C_Tot? c ==> r == C_Tot (ss_term (comp_res c) ss)) /\
(C_ST? c ==> r == C_ST (ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STAtomic? c ==> r == C_STAtomic (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss)) /\
(C_STGhost? c ==> r == C_STGhost (ss_term (comp_inames c) ss)
(ss_st_comp (st_comp_of_comp c) ss))))
(decreases L.length ss.l)
[SMTPat (ss_comp c ss)] =
match ss.l with
| [] -> ()
| y::tl -> ss_comp_commutes (subst_comp c [ NT y (Map.sel ss.m y) ]) (tail ss)
let rec nt_substs_st_comp_commutes (s:st_comp) (nts:nt_substs)
: Lemma (ensures
nt_subst_st_comp s nts ==
{ s with res = nt_subst_term s.res nts;
pre = nt_subst_term s.pre nts;
post = nt_subst_term s.post nts; }) // no shifting required
(decreases nts)
[SMTPat (nt_subst_st_comp s nts)] =
match nts with
| [] -> ()
| (NT x e)::nts_tl -> nt_substs_st_comp_commutes (nt_subst_st_comp s [ NT x e ]) nts_tl
let rec nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
(decreases nts) | false | false | Pulse.Checker.Prover.Substs.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nt_subst_comp_commutes (c:comp) (nts:nt_substs)
: Lemma (ensures
(let r = nt_subst_comp c nts in
(C_Tot? c ==> r == C_Tot (nt_subst_term (comp_res c) nts)) /\
(C_ST? c ==> r == C_ST (nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STAtomic? c ==> r == C_STAtomic (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts)) /\
(C_STGhost? c ==> r == C_STGhost (nt_subst_term (comp_inames c) nts)
(nt_subst_st_comp (st_comp_of_comp c) nts))))
[SMTPat (nt_subst_comp c nts)] | [
"recursion"
] | Pulse.Checker.Prover.Substs.nt_subst_comp_commutes | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Substs.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | c: Pulse.Syntax.Base.comp -> nts: Pulse.Checker.Prover.Substs.nt_substs
-> FStar.Pervasives.Lemma
(ensures
(let r = Pulse.Checker.Prover.Substs.nt_subst_comp c nts in
(C_Tot? c ==>
r ==
Pulse.Syntax.Base.C_Tot
(Pulse.Checker.Prover.Substs.nt_subst_term (Pulse.Syntax.Base.comp_res c) nts)) /\
(C_ST? c ==>
r ==
Pulse.Syntax.Base.C_ST
(Pulse.Checker.Prover.Substs.nt_subst_st_comp (Pulse.Syntax.Base.st_comp_of_comp c) nts)
) /\
(C_STAtomic? c ==>
r ==
Pulse.Syntax.Base.C_STAtomic
(Pulse.Checker.Prover.Substs.nt_subst_term (Pulse.Syntax.Base.comp_inames c) nts)
(Pulse.Checker.Prover.Substs.nt_subst_st_comp (Pulse.Syntax.Base.st_comp_of_comp c)
nts)) /\
(C_STGhost? c ==>
r ==
Pulse.Syntax.Base.C_STGhost
(Pulse.Checker.Prover.Substs.nt_subst_term (Pulse.Syntax.Base.comp_inames c) nts)
(Pulse.Checker.Prover.Substs.nt_subst_st_comp (Pulse.Syntax.Base.st_comp_of_comp c)
nts)))) (decreases nts) [SMTPat (Pulse.Checker.Prover.Substs.nt_subst_comp c nts)] | {
"end_col": 82,
"end_line": 233,
"start_col": 2,
"start_line": 231
} |
FStar.Tactics.Effect.Tac | val term_construct (t : term) : Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let term_construct (t : term) : Tac string =
term_view_construct (inspect t) | val term_construct (t : term) : Tac string
let term_construct (t: term) : Tac string = | true | null | false | term_view_construct (inspect t) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.term_view_construct",
"Prims.string",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val term_construct (t : term) : Tac string | [] | FStar.InteractiveHelpers.Base.term_construct | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 33,
"end_line": 160,
"start_col": 2,
"start_line": 160
} |
FStar.Tactics.Effect.Tac | val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables
(there is no longer a sort). But, shift the substitution. *)
bv, (bv, pack (Tv_Var bv))::subst
(*
* AR: TODO: should apply subst in attrs?
*)
and deep_apply_subst_in_binder e br subst =
let open inspect_binder br <: binder_view in
let binder_sort = deep_apply_subst e binder_sort subst in
let binder_bv, subst = deep_apply_subst_in_bv e binder_bv subst in
pack_binder {
binder_bv=binder_bv;
binder_qual=binder_qual;
binder_attrs=binder_attrs;
binder_sort=binder_sort;
}, subst
and deep_apply_subst_in_comp e c subst =
let subst = (fun x -> deep_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
and deep_apply_subst_in_pattern e pat subst =
match pat with
| Pat_Constant _ -> pat, subst
| Pat_Cons fv us patterns ->
(* The types of the variables in the patterns should be independent of each
* other: we use fold_left only to incrementally update the substitution *)
let patterns, subst =
fold_right (fun (pat, b) (pats, subst) ->
let pat, subst = deep_apply_subst_in_pattern e pat subst in
((pat, b) :: pats, subst)) patterns ([], subst)
in
Pat_Cons fv us patterns, subst
| Pat_Var bv st ->
let st = Sealed.seal (deep_apply_subst e (unseal st) subst) in
let bv, subst = deep_apply_subst_in_bv e bv subst in
Pat_Var bv st, subst
| Pat_Dot_Term eopt ->
Pat_Dot_Term (map_opt (fun t -> deep_apply_subst e t subst) eopt), subst | val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
let rec deep_apply_subst_in_bv e bv subst = | true | null | false | bv, (bv, pack (Tv_Var bv)) :: subst | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Types.bv",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Cons",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var"
] | [
"deep_apply_subst",
"deep_apply_subst_in_bv",
"deep_apply_subst_in_binder",
"deep_apply_subst_in_comp",
"deep_apply_subst_in_pattern"
] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp
let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2
let norm_apply_subst_in_comp e c subst =
let subst = (fun x -> norm_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
/// As substitution with normalization is very expensive, we implemented another
/// technique which works by exploring terms. This is super fast, but the terms
/// seem not to be reconstructed in the same way, which has a big impact on pretty printing.
/// For example, terms like [A /\ B] get printed as [Prims.l_and A B].
val deep_apply_subst : env -> term -> list (bv & term) -> Tac term
// Whenever we encounter a construction which introduces a binder, we need to apply
// the substitution in the binder type. Note that this gives a new binder, with
// which we need to replace the old one in what follows.
// Also note that it should be possible to rewrite [deep_apply_subst] in terms of [visit_tm],
// but [deep_apply_subst] seems to be a bit more precise with regard to type replacements (not
// sure it is really important, though).
val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
val deep_apply_subst_in_binder : env -> binder -> list (bv & term) -> Tac (binder & list (bv & term))
val deep_apply_subst_in_comp : env -> comp -> list (bv & term) -> Tac comp
val deep_apply_subst_in_pattern : env -> pattern -> list (bv & term) -> Tac (pattern & list (bv & term))
let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term)) | [
"mutual recursion"
] | FStar.InteractiveHelpers.Base.deep_apply_subst_in_bv | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
bv: FStar.Reflection.Types.bv ->
subst: Prims.list (FStar.Reflection.Types.bv * FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac
(FStar.Reflection.Types.bv *
Prims.list (FStar.Reflection.Types.bv * FStar.Reflection.Types.term)) | {
"end_col": 35,
"end_line": 516,
"start_col": 2,
"start_line": 516
} |
FStar.Tactics.Effect.Tac | val genv_push_fresh_bv (ge: genv) (basename: string) (ty: typ) : Tac (genv & bv) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b | val genv_push_fresh_bv (ge: genv) (basename: string) (ty: typ) : Tac (genv & bv)
let genv_push_fresh_bv (ge: genv) (basename: string) (ty: typ) : Tac (genv & bv) = | true | null | false | let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.genv_push_fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_fresh_bv (ge: genv) (basename: string) (ty: typ) : Tac (genv & bv) | [] | FStar.InteractiveHelpers.Base.genv_push_fresh_bv | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac (FStar.InteractiveHelpers.Base.genv * FStar.Reflection.Types.bv) | {
"end_col": 21,
"end_line": 345,
"start_col": 85,
"start_line": 343
} |
FStar.Tactics.Effect.Tac | val print_binders_info (full: bool) (e: env) : Tac unit | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e) | val print_binders_info (full: bool) (e: env) : Tac unit
let print_binders_info (full: bool) (e: env) : Tac unit = | true | null | false | iter (print_binder_info full) (binders_of_env e) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.bool",
"FStar.Reflection.Types.env",
"FStar.Tactics.Util.iter",
"FStar.Reflection.Types.binder",
"FStar.InteractiveHelpers.Base.print_binder_info",
"FStar.Reflection.V1.Builtins.binders_of_env",
"Prims.unit"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val print_binders_info (full: bool) (e: env) : Tac unit | [] | FStar.InteractiveHelpers.Base.print_binders_info | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | full: Prims.bool -> e: FStar.Reflection.Types.env -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 50,
"end_line": 108,
"start_col": 2,
"start_line": 108
} |
FStar.Tactics.Effect.Tac | val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]" | val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls = | true | null | false | (Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]" | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.string",
"Prims.list",
"Prims.op_Hat",
"FStar.Tactics.Util.fold_left"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string | [] | FStar.InteractiveHelpers.Base.list_to_string | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> FStar.Tactics.Effect.Tac Prims.string) -> ls: Prims.list a
-> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 74,
"end_line": 58,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m | let bind_map_push (#a: Type) (m: bind_map a) (b: bv) (x: a) = | false | null | false | (b, x) :: m | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.bind_map",
"FStar.Reflection.Types.bv",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.list"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_map_push : m: FStar.InteractiveHelpers.Base.bind_map a -> b: FStar.Reflection.Types.bv -> x: a
-> Prims.list (FStar.Reflection.Types.bv * a) | [] | FStar.InteractiveHelpers.Base.bind_map_push | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.InteractiveHelpers.Base.bind_map a -> b: FStar.Reflection.Types.bv -> x: a
-> Prims.list (FStar.Reflection.Types.bv * a) | {
"end_col": 66,
"end_line": 196,
"start_col": 58,
"start_line": 196
} |
|
Prims.Tot | val get_bind_map (e: genv) : bind_map (typ & bool & term) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap | val get_bind_map (e: genv) : bind_map (typ & bool & term)
let get_bind_map (e: genv) : bind_map (typ & bool & term) = | false | null | false | e.bmap | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap",
"FStar.InteractiveHelpers.Base.bind_map",
"FStar.Pervasives.Native.tuple3",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Reflection.Types.term"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
} | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_bind_map (e: genv) : bind_map (typ & bool & term) | [] | FStar.InteractiveHelpers.Base.get_bind_map | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.InteractiveHelpers.Base.genv
-> FStar.InteractiveHelpers.Base.bind_map ((FStar.Reflection.Types.typ * Prims.bool) *
FStar.Reflection.Types.term) | {
"end_col": 65,
"end_line": 239,
"start_col": 59,
"start_line": 239
} |
FStar.Tactics.Effect.Tac | val term_view_construct (t : term_view) : Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown" | val term_view_construct (t : term_view) : Tac string
let term_view_construct (t: term_view) : Tac string = | true | null | false | match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown" | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.fv",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Reflection.Types.universe",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V1.Data.vconst",
"Prims.nat",
"FStar.Reflection.Types.ctx_uvar_and_subst",
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.match_returns_ascription",
"FStar.Reflection.V1.Data.branch",
"Prims.string"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val term_view_construct (t : term_view) : Tac string | [] | FStar.InteractiveHelpers.Base.term_view_construct | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.V1.Data.term_view -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 21,
"end_line": 155,
"start_col": 2,
"start_line": 140
} |
FStar.Tactics.Effect.Tac | val fresh_binder (e: env) (basename: string) (ty: typ) : Tac binder | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty | val fresh_binder (e: env) (basename: string) (ty: typ) : Tac binder
let fresh_binder (e: env) (basename: string) (ty: typ) : Tac binder = | true | null | false | let bv = fresh_bv e basename in
mk_binder bv ty | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V1.Derived.mk_binder",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.bv",
"FStar.InteractiveHelpers.Base.fresh_bv"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0 | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_binder (e: env) (basename: string) (ty: typ) : Tac binder | [] | FStar.InteractiveHelpers.Base.fresh_binder | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.binder | {
"end_col": 17,
"end_line": 329,
"start_col": 72,
"start_line": 327
} |
Prims.Tot | val get_env (e: genv) : env | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_env (e:genv) : env = e.env | val get_env (e: genv) : env
let get_env (e: genv) : env = | false | null | false | e.env | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env",
"FStar.Reflection.Types.env"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
} | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_env (e: genv) : env | [] | FStar.InteractiveHelpers.Base.get_env | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.InteractiveHelpers.Base.genv -> FStar.Reflection.Types.env | {
"end_col": 34,
"end_line": 238,
"start_col": 29,
"start_line": 238
} |
FStar.Tactics.Effect.Tac | val print_dbg : bool -> string -> Tac unit | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let print_dbg debug s =
if debug then print s | val print_dbg : bool -> string -> Tac unit
let print_dbg debug s = | true | null | false | if debug then print s | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.bool",
"Prims.string",
"FStar.Tactics.V1.Builtins.print",
"Prims.unit"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val print_dbg : bool -> string -> Tac unit | [] | FStar.InteractiveHelpers.Base.print_dbg | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | debug: Prims.bool -> s: Prims.string -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 23,
"end_line": 134,
"start_col": 2,
"start_line": 134
} |
FStar.Tactics.Effect.Tac | val fresh_bv (e: env) (basename: string) : Tac bv | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0 | val fresh_bv (e: env) (basename: string) : Tac bv
let fresh_bv (e: env) (basename: string) : Tac bv = | true | null | false | let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.InteractiveHelpers.Base._fresh_bv",
"FStar.Reflection.Types.bv",
"Prims.list",
"FStar.Tactics.Util.map",
"FStar.Reflection.Types.binder",
"FStar.Tactics.V1.Derived.name_of_binder",
"FStar.Reflection.Types.binders",
"FStar.Reflection.V1.Builtins.binders_of_env"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_bv (e: env) (basename: string) : Tac bv | [] | FStar.InteractiveHelpers.Base.fresh_bv | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> basename: Prims.string
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.bv | {
"end_col": 35,
"end_line": 325,
"start_col": 53,
"start_line": 322
} |
FStar.Tactics.Effect.Tac | val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2 | val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
let norm_apply_subst e t subst = | true | null | false | let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv, ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.Builtins.norm_term_env",
"Prims.Nil",
"FStar.Pervasives.norm_step",
"FStar.Reflection.V1.Derived.mk_e_app",
"FStar.Tactics.V1.Derived.mk_abs",
"FStar.Reflection.Types.binder",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V1.Derived.mk_binder",
"FStar.InteractiveHelpers.Base.unzip"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term | [] | FStar.InteractiveHelpers.Base.norm_apply_subst | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
t: FStar.Reflection.Types.term ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 23,
"end_line": 391,
"start_col": 32,
"start_line": 386
} |
FStar.Tactics.Effect.Tac | val opt_mk_app_norm : env -> option term -> list term -> Tac (option term) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t | val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params = | true | null | false | opt_tapply (fun t -> mk_app_norm e t params) opt_t | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.InteractiveHelpers.Base.opt_tapply",
"FStar.InteractiveHelpers.Base.mk_app_norm"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opt_mk_app_norm : env -> option term -> list term -> Tac (option term) | [] | FStar.InteractiveHelpers.Base.opt_mk_app_norm | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
opt_t: FStar.Pervasives.Native.option FStar.Reflection.Types.term ->
params: Prims.list FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.Reflection.Types.term) | {
"end_col": 52,
"end_line": 71,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val binder_is_shadowed (ge: genv) (b: binder) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b) | val binder_is_shadowed (ge: genv) (b: binder) : Tot bool
let binder_is_shadowed (ge: genv) (b: binder) : Tot bool = | false | null | false | bv_is_shadowed ge (bv_of_binder b) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.binder",
"FStar.InteractiveHelpers.Base.bv_is_shadowed",
"FStar.Reflection.V1.Derived.bv_of_binder",
"Prims.bool"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binder_is_shadowed (ge: genv) (b: binder) : Tot bool | [] | FStar.InteractiveHelpers.Base.binder_is_shadowed | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> b: FStar.Reflection.Types.binder -> Prims.bool | {
"end_col": 36,
"end_line": 289,
"start_col": 2,
"start_line": 289
} |
FStar.Tactics.Effect.Tac | val prettify_term : bool -> term -> Tac term | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prettify_term dbg t = filter_ascriptions dbg t | val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = | true | null | false | filter_ascriptions dbg t | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.filter_ascriptions"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away. | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prettify_term : bool -> term -> Tac term | [] | FStar.InteractiveHelpers.Base.prettify_term | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | dbg: Prims.bool -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 50,
"end_line": 186,
"start_col": 26,
"start_line": 186
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let apply_subst_in_comp = norm_apply_subst_in_comp | let apply_subst_in_comp = | true | null | false | norm_apply_subst_in_comp | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.norm_apply_subst_in_comp"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp
let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2
let norm_apply_subst_in_comp e c subst =
let subst = (fun x -> norm_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
/// As substitution with normalization is very expensive, we implemented another
/// technique which works by exploring terms. This is super fast, but the terms
/// seem not to be reconstructed in the same way, which has a big impact on pretty printing.
/// For example, terms like [A /\ B] get printed as [Prims.l_and A B].
val deep_apply_subst : env -> term -> list (bv & term) -> Tac term
// Whenever we encounter a construction which introduces a binder, we need to apply
// the substitution in the binder type. Note that this gives a new binder, with
// which we need to replace the old one in what follows.
// Also note that it should be possible to rewrite [deep_apply_subst] in terms of [visit_tm],
// but [deep_apply_subst] seems to be a bit more precise with regard to type replacements (not
// sure it is really important, though).
val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
val deep_apply_subst_in_binder : env -> binder -> list (bv & term) -> Tac (binder & list (bv & term))
val deep_apply_subst_in_comp : env -> comp -> list (bv & term) -> Tac comp
val deep_apply_subst_in_pattern : env -> pattern -> list (bv & term) -> Tac (pattern & list (bv & term))
let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables
(there is no longer a sort). But, shift the substitution. *)
bv, (bv, pack (Tv_Var bv))::subst
(*
* AR: TODO: should apply subst in attrs?
*)
and deep_apply_subst_in_binder e br subst =
let open inspect_binder br <: binder_view in
let binder_sort = deep_apply_subst e binder_sort subst in
let binder_bv, subst = deep_apply_subst_in_bv e binder_bv subst in
pack_binder {
binder_bv=binder_bv;
binder_qual=binder_qual;
binder_attrs=binder_attrs;
binder_sort=binder_sort;
}, subst
and deep_apply_subst_in_comp e c subst =
let subst = (fun x -> deep_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
and deep_apply_subst_in_pattern e pat subst =
match pat with
| Pat_Constant _ -> pat, subst
| Pat_Cons fv us patterns ->
(* The types of the variables in the patterns should be independent of each
* other: we use fold_left only to incrementally update the substitution *)
let patterns, subst =
fold_right (fun (pat, b) (pats, subst) ->
let pat, subst = deep_apply_subst_in_pattern e pat subst in
((pat, b) :: pats, subst)) patterns ([], subst)
in
Pat_Cons fv us patterns, subst
| Pat_Var bv st ->
let st = Sealed.seal (deep_apply_subst e (unseal st) subst) in
let bv, subst = deep_apply_subst_in_bv e bv subst in
Pat_Var bv st, subst
| Pat_Dot_Term eopt ->
Pat_Dot_Term (map_opt (fun t -> deep_apply_subst e t subst) eopt), subst
/// The substitution functions actually used in the rest of the meta F* functions.
/// For now, we use normalization because even though it is sometimes slow it
/// gives prettier terms, and readability is the priority. In order to mitigate
/// the performance issue, we try to minimize the number of calls to those functions,
/// by doing lazy instantiations for example (rather than incrementally apply
/// substitutions in a term, accumulate the substitutions and perform them all at once).
/// TODO: would it be good to have a native substitution function in F* | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val apply_subst_in_comp : e: FStar.Reflection.Types.env ->
c: FStar.Reflection.Types.comp ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.comp | [] | FStar.InteractiveHelpers.Base.apply_subst_in_comp | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
c: FStar.Reflection.Types.comp ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.comp | {
"end_col": 50,
"end_line": 585,
"start_col": 26,
"start_line": 585
} |
|
FStar.Tactics.Effect.Tac | val genv_push_fresh_binder (ge: genv) (basename: string) (ty: typ) : Tac (genv & binder) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b | val genv_push_fresh_binder (ge: genv) (basename: string) (ty: typ) : Tac (genv & binder)
let genv_push_fresh_binder (ge: genv) (basename: string) (ty: typ) : Tac (genv & binder) = | true | null | false | let b = fresh_binder ge.env basename ty in
let ge' = genv_push_binder ge b true None in
ge', b | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.genv_push_binder",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.fresh_binder",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_fresh_binder (ge: genv) (basename: string) (ty: typ) : Tac (genv & binder) | [] | FStar.InteractiveHelpers.Base.genv_push_fresh_binder | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac (FStar.InteractiveHelpers.Base.genv * FStar.Reflection.Types.binder) | {
"end_col": 8,
"end_line": 335,
"start_col": 93,
"start_line": 331
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mfail str =
raise (MetaAnalysis str) | let mfail str = | true | null | false | raise (MetaAnalysis str) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.string",
"FStar.Tactics.Effect.raise",
"FStar.InteractiveHelpers.Base.MetaAnalysis"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mfail : str: Prims.string -> FStar.Tactics.Effect.Tac _ | [] | FStar.InteractiveHelpers.Base.mfail | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | str: Prims.string -> FStar.Tactics.Effect.Tac _ | {
"end_col": 26,
"end_line": 128,
"start_col": 2,
"start_line": 128
} |
|
FStar.Tactics.Effect.Tac | val genv_push_binder (ge: genv) (b: binder) (abs: bool) (t: option term) : Tac genv | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t | val genv_push_binder (ge: genv) (b: binder) (abs: bool) (t: option term) : Tac genv
let genv_push_binder (ge: genv) (b: binder) (abs: bool) (t: option term) : Tac genv = | true | null | false | genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.binder",
"Prims.bool",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.genv_push_bv",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.Derived.binder_sort"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars' | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_binder (ge: genv) (b: binder) (abs: bool) (t: option term) : Tac genv | [] | FStar.InteractiveHelpers.Base.genv_push_binder | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
ge: FStar.InteractiveHelpers.Base.genv ->
b: FStar.Reflection.Types.binder ->
abs: Prims.bool ->
t: FStar.Pervasives.Native.option FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.Base.genv | {
"end_col": 56,
"end_line": 282,
"start_col": 2,
"start_line": 282
} |
FStar.Tactics.Effect.Tac | val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1 | val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty = | true | null | false | let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.tuple3",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.genv_push_fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1 | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv) | [] | FStar.InteractiveHelpers.Base.genv_push_fresh_var | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge0: FStar.InteractiveHelpers.Base.genv -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac
((FStar.Reflection.Types.term * FStar.Reflection.Types.binder) *
FStar.InteractiveHelpers.Base.genv) | {
"end_col": 13,
"end_line": 357,
"start_col": 41,
"start_line": 354
} |
Prims.Tot | val fv_eq : fv -> fv -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2 | val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 = | false | null | false | let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.fv",
"Prims.op_Equality",
"FStar.Reflection.Types.name",
"FStar.Reflection.V1.Builtins.inspect_fv",
"Prims.bool"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fv_eq : fv -> fv -> Tot bool | [] | FStar.InteractiveHelpers.Base.fv_eq | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | fv1: FStar.Reflection.Types.fv -> fv2: FStar.Reflection.Types.fv -> Prims.bool | {
"end_col": 9,
"end_line": 23,
"start_col": 19,
"start_line": 20
} |
Prims.Tot | val find_shadowed_bvs (ge: genv) (bl: list bv) : Tot (list (bv & bool)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl | val find_shadowed_bvs (ge: genv) (bl: list bv) : Tot (list (bv & bool))
let find_shadowed_bvs (ge: genv) (bl: list bv) : Tot (list (bv & bool)) = | false | null | false | List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.list",
"FStar.Reflection.Types.bv",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.InteractiveHelpers.Base.bv_is_shadowed"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b) | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_shadowed_bvs (ge: genv) (bl: list bv) : Tot (list (bv & bool)) | [] | FStar.InteractiveHelpers.Base.find_shadowed_bvs | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> bl: Prims.list FStar.Reflection.Types.bv
-> Prims.list (FStar.Reflection.Types.bv * Prims.bool) | {
"end_col": 51,
"end_line": 292,
"start_col": 2,
"start_line": 292
} |
Prims.Tot | val find_shadowed_binders (ge: genv) (bl: list binder) : Tot (list (binder & bool)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl | val find_shadowed_binders (ge: genv) (bl: list binder) : Tot (list (binder & bool))
let find_shadowed_binders (ge: genv) (bl: list binder) : Tot (list (binder & bool)) = | false | null | false | List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.InteractiveHelpers.Base.binder_is_shadowed"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_shadowed_binders (ge: genv) (bl: list binder) : Tot (list (binder & bool)) | [] | FStar.InteractiveHelpers.Base.find_shadowed_binders | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> bl: Prims.list FStar.Reflection.Types.binder
-> Prims.list (FStar.Reflection.Types.binder * Prims.bool) | {
"end_col": 55,
"end_line": 295,
"start_col": 2,
"start_line": 295
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let apply_subst = norm_apply_subst | let apply_subst = | true | null | false | norm_apply_subst | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.norm_apply_subst"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp
let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2
let norm_apply_subst_in_comp e c subst =
let subst = (fun x -> norm_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
/// As substitution with normalization is very expensive, we implemented another
/// technique which works by exploring terms. This is super fast, but the terms
/// seem not to be reconstructed in the same way, which has a big impact on pretty printing.
/// For example, terms like [A /\ B] get printed as [Prims.l_and A B].
val deep_apply_subst : env -> term -> list (bv & term) -> Tac term
// Whenever we encounter a construction which introduces a binder, we need to apply
// the substitution in the binder type. Note that this gives a new binder, with
// which we need to replace the old one in what follows.
// Also note that it should be possible to rewrite [deep_apply_subst] in terms of [visit_tm],
// but [deep_apply_subst] seems to be a bit more precise with regard to type replacements (not
// sure it is really important, though).
val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
val deep_apply_subst_in_binder : env -> binder -> list (bv & term) -> Tac (binder & list (bv & term))
val deep_apply_subst_in_comp : env -> comp -> list (bv & term) -> Tac comp
val deep_apply_subst_in_pattern : env -> pattern -> list (bv & term) -> Tac (pattern & list (bv & term))
let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables
(there is no longer a sort). But, shift the substitution. *)
bv, (bv, pack (Tv_Var bv))::subst
(*
* AR: TODO: should apply subst in attrs?
*)
and deep_apply_subst_in_binder e br subst =
let open inspect_binder br <: binder_view in
let binder_sort = deep_apply_subst e binder_sort subst in
let binder_bv, subst = deep_apply_subst_in_bv e binder_bv subst in
pack_binder {
binder_bv=binder_bv;
binder_qual=binder_qual;
binder_attrs=binder_attrs;
binder_sort=binder_sort;
}, subst
and deep_apply_subst_in_comp e c subst =
let subst = (fun x -> deep_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
and deep_apply_subst_in_pattern e pat subst =
match pat with
| Pat_Constant _ -> pat, subst
| Pat_Cons fv us patterns ->
(* The types of the variables in the patterns should be independent of each
* other: we use fold_left only to incrementally update the substitution *)
let patterns, subst =
fold_right (fun (pat, b) (pats, subst) ->
let pat, subst = deep_apply_subst_in_pattern e pat subst in
((pat, b) :: pats, subst)) patterns ([], subst)
in
Pat_Cons fv us patterns, subst
| Pat_Var bv st ->
let st = Sealed.seal (deep_apply_subst e (unseal st) subst) in
let bv, subst = deep_apply_subst_in_bv e bv subst in
Pat_Var bv st, subst
| Pat_Dot_Term eopt ->
Pat_Dot_Term (map_opt (fun t -> deep_apply_subst e t subst) eopt), subst
/// The substitution functions actually used in the rest of the meta F* functions.
/// For now, we use normalization because even though it is sometimes slow it
/// gives prettier terms, and readability is the priority. In order to mitigate
/// the performance issue, we try to minimize the number of calls to those functions,
/// by doing lazy instantiations for example (rather than incrementally apply
/// substitutions in a term, accumulate the substitutions and perform them all at once). | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val apply_subst : e: FStar.Reflection.Types.env ->
t: FStar.Reflection.Types.term ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | [] | FStar.InteractiveHelpers.Base.apply_subst | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
t: FStar.Reflection.Types.term ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 34,
"end_line": 584,
"start_col": 18,
"start_line": 584
} |
|
FStar.Tactics.Effect.Tac | val push_fresh_binder (e: env) (basename: string) (ty: typ) : Tac (env & binder) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b | val push_fresh_binder (e: env) (basename: string) (ty: typ) : Tac (env & binder)
let push_fresh_binder (e: env) (basename: string) (ty: typ) : Tac (env & binder) = | true | null | false | let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V1.Builtins.push_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push_fresh_binder (e: env) (basename: string) (ty: typ) : Tac (env & binder) | [] | FStar.InteractiveHelpers.Base.push_fresh_binder | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac (FStar.Reflection.Types.env * FStar.Reflection.Types.binder) | {
"end_col": 7,
"end_line": 341,
"start_col": 85,
"start_line": 338
} |
Prims.Tot | val genv_abstract_bvs : genv -> Tot (list (bv & typ)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap | val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge = | false | null | false | List.Tot.concatMap (fun (bv, (ty, abs, _)) -> if abs then [bv, ty] else []) ge.bmap | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.List.Tot.Base.concatMap",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Pervasives.Native.tuple3",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Reflection.Types.term",
"Prims.Cons",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"Prims.list",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ)) | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_abstract_bvs : genv -> Tot (list (bv & typ)) | [] | FStar.InteractiveHelpers.Base.genv_abstract_bvs | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv
-> Prims.list (FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) | {
"end_col": 67,
"end_line": 310,
"start_col": 2,
"start_line": 309
} |
FStar.Tactics.Effect.Tac | val filter_ascriptions : bool -> term -> Tac term | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t | val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t = | true | null | false | print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t);
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _ | Tv_AscribedC e _ _ _ -> e
| _ -> t)
t | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.Tactics.Visit.visit_tm",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.comp",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect",
"Prims.unit",
"FStar.InteractiveHelpers.Base.print_dbg",
"Prims.string",
"Prims.op_Hat",
"FStar.Tactics.V1.Builtins.term_to_string",
"FStar.InteractiveHelpers.Base.term_view_construct"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val filter_ascriptions : bool -> term -> Tac term | [] | FStar.InteractiveHelpers.Base.filter_ascriptions | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | dbg: Prims.bool -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 15,
"end_line": 178,
"start_col": 2,
"start_line": 173
} |
FStar.Tactics.Effect.Tac | val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2 | val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty = | true | null | false | let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.tuple5",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.genv_push_fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2 | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv) | [] | FStar.InteractiveHelpers.Base.genv_push_two_fresh_vars | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge0: FStar.InteractiveHelpers.Base.genv -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac
((((FStar.Reflection.Types.term * FStar.Reflection.Types.binder) * FStar.Reflection.Types.term) *
FStar.Reflection.Types.binder) *
FStar.InteractiveHelpers.Base.genv) | {
"end_col": 21,
"end_line": 373,
"start_col": 46,
"start_line": 368
} |
FStar.Tactics.Effect.Tac | val genv_to_string : genv -> Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str | val genv_to_string : genv -> Tac string
let genv_to_string ge = | true | null | false | let binder_to_string (b: binder) : Tac string = abv_to_string (bv_of_binder b) ^ "\n" in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e: bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^ " -> (" ^ string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^ "> bmap:\n" ^ flatten bmap_str ^ "> svars:\n" ^ flatten svars_str | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.op_Hat",
"Prims.list",
"Prims.string",
"FStar.List.Tot.Base.fold_left",
"FStar.Tactics.Util.map",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"FStar.InteractiveHelpers.Base.abv_to_string",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__svars",
"FStar.Pervasives.Native.tuple3",
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap",
"Prims.string_of_bool",
"FStar.Tactics.V1.Builtins.term_to_string",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V1.Builtins.binders_of_env",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env",
"FStar.Reflection.V1.Derived.bv_of_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] [] | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_to_string : genv -> Tac string | [] | FStar.InteractiveHelpers.Base.genv_to_string | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 34,
"end_line": 259,
"start_col": 23,
"start_line": 244
} |
FStar.Tactics.Effect.Tac | val mk_app_norm : env -> term -> list term -> Tac term | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2 | val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params = | true | null | false | let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Tactics.V1.Builtins.norm_term_env",
"Prims.Nil",
"FStar.Pervasives.norm_step",
"FStar.Reflection.V1.Derived.mk_e_app"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_app_norm : env -> term -> list term -> Tac term | [] | FStar.InteractiveHelpers.Base.mk_app_norm | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
t: FStar.Reflection.Types.term ->
params: Prims.list FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 4,
"end_line": 67,
"start_col": 28,
"start_line": 64
} |
Prims.Tot | val genv_get (ge: genv) (b: bv) : Tot (option (typ & bool & term)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b | val genv_get (ge: genv) (b: bv) : Tot (option (typ & bool & term))
let genv_get (ge: genv) (b: bv) : Tot (option (typ & bool & term)) = | false | null | false | bind_map_get ge.bmap b | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.bv",
"FStar.InteractiveHelpers.Base.bind_map_get",
"FStar.Pervasives.Native.tuple3",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap",
"FStar.Pervasives.Native.option"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_get (ge: genv) (b: bv) : Tot (option (typ & bool & term)) | [] | FStar.InteractiveHelpers.Base.genv_get | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> b: FStar.Reflection.Types.bv
-> FStar.Pervasives.Native.option ((FStar.Reflection.Types.typ * Prims.bool) *
FStar.Reflection.Types.term) | {
"end_col": 24,
"end_line": 262,
"start_col": 2,
"start_line": 262
} |
Prims.Tot | val bv_is_shadowed (ge: genv) (bv: bv) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars | val bv_is_shadowed (ge: genv) (bv: bv) : Tot bool
let bv_is_shadowed (ge: genv) (bv: bv) : Tot bool = | false | null | false | List.Tot.existsb (fun (b, _) -> bv_eq bv b) ge.svars | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.bv",
"FStar.List.Tot.Base.existsb",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.typ",
"FStar.InteractiveHelpers.Base.bv_eq",
"Prims.bool",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__svars"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bv_is_shadowed (ge: genv) (bv: bv) : Tot bool | [] | FStar.InteractiveHelpers.Base.bv_is_shadowed | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> bv: FStar.Reflection.Types.bv -> Prims.bool | {
"end_col": 53,
"end_line": 286,
"start_col": 2,
"start_line": 286
} |
Prims.Tot | val fv_eq_name : fv -> name -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n | val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n = | false | null | false | let fvn = inspect_fv fv in
fvn = n | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.fv",
"FStar.Reflection.Types.name",
"Prims.op_Equality",
"FStar.Reflection.V1.Builtins.inspect_fv",
"Prims.bool"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fv_eq_name : fv -> name -> Tot bool | [] | FStar.InteractiveHelpers.Base.fv_eq_name | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | fv: FStar.Reflection.Types.fv -> n: FStar.Reflection.Types.name -> Prims.bool | {
"end_col": 9,
"end_line": 29,
"start_col": 21,
"start_line": 27
} |
Prims.Tot | val binder_is_abstract : genv -> binder -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b) | val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b = | false | null | false | bv_is_abstract ge (bv_of_binder b) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.binder",
"FStar.InteractiveHelpers.Base.bv_is_abstract",
"FStar.Reflection.V1.Derived.bv_of_binder",
"Prims.bool"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binder_is_abstract : genv -> binder -> Tot bool | [] | FStar.InteractiveHelpers.Base.binder_is_abstract | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> b: FStar.Reflection.Types.binder -> Prims.bool | {
"end_col": 36,
"end_line": 305,
"start_col": 2,
"start_line": 305
} |
FStar.Tactics.Effect.Tac | val push_fresh_var : env -> string -> typ -> Tac (term & binder & env) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1 | val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty = | true | null | false | let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.tuple3",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.push_fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push_fresh_var : env -> string -> typ -> Tac (term & binder & env) | [] | FStar.InteractiveHelpers.Base.push_fresh_var | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e0: FStar.Reflection.Types.env -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac
((FStar.Reflection.Types.term * FStar.Reflection.Types.binder) * FStar.Reflection.Types.env) | {
"end_col": 12,
"end_line": 351,
"start_col": 35,
"start_line": 348
} |
FStar.Tactics.Effect.Tac | val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2 | val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty = | true | null | false | let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2 | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"Prims.string",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.tuple5",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.Reflection.V1.Derived.bv_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.InteractiveHelpers.Base.push_fresh_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1 | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env) | [] | FStar.InteractiveHelpers.Base.push_two_fresh_vars | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e0: FStar.Reflection.Types.env -> basename: Prims.string -> ty: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac
((((FStar.Reflection.Types.term * FStar.Reflection.Types.binder) * FStar.Reflection.Types.term) *
FStar.Reflection.Types.binder) *
FStar.Reflection.Types.env) | {
"end_col": 20,
"end_line": 365,
"start_col": 40,
"start_line": 360
} |
Prims.Tot | val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x') | val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x = | false | null | false | match x with
| None -> None
| Some x' -> Some (f x') | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b) | [] | FStar.InteractiveHelpers.Base.opt_apply | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> b) -> x: FStar.Pervasives.Native.option a -> FStar.Pervasives.Native.option b | {
"end_col": 26,
"end_line": 36,
"start_col": 2,
"start_line": 34
} |
FStar.Tactics.Effect.Tac | val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x') | val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x = | true | null | false | match x with
| None -> None
| Some x' -> Some (f x') | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b) | [] | FStar.InteractiveHelpers.Base.opt_tapply | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> FStar.Tactics.Effect.Tac b) -> x: FStar.Pervasives.Native.option a
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option b) | {
"end_col": 26,
"end_line": 42,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | val bv_eq : bv -> bv -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index | val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2: bv) = | false | null | false | let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
bvv1.bv_index = bvv2.bv_index | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.bv",
"Prims.op_Equality",
"Prims.nat",
"FStar.Reflection.V1.Data.__proj__Mkbv_view__item__bv_index",
"FStar.Reflection.V1.Data.bv_view",
"Prims.precedes",
"FStar.Reflection.V1.Builtins.inspect_bv",
"Prims.bool"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *) | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bv_eq : bv -> bv -> Tot bool | [] | FStar.InteractiveHelpers.Base.bv_eq | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bv1: FStar.Reflection.Types.bv -> bv2: FStar.Reflection.Types.bv -> Prims.bool | {
"end_col": 31,
"end_line": 17,
"start_col": 26,
"start_line": 11
} |
Prims.Tot | val bv_is_abstract : genv -> bv -> Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs | val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv = | false | null | false | match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.bv",
"FStar.InteractiveHelpers.Base.genv_get",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Reflection.Types.term"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool | false | true | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bv_is_abstract : genv -> bv -> Tot bool | [] | FStar.InteractiveHelpers.Base.bv_is_abstract | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> bv: FStar.Reflection.Types.bv -> Prims.bool | {
"end_col": 27,
"end_line": 301,
"start_col": 2,
"start_line": 299
} |
FStar.Tactics.Effect.Tac | val genv_get_from_name (ge: genv) (name: string) : Tac (option ((bv & typ) & (bool & term))) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x)) | val genv_get_from_name (ge: genv) (name: string) : Tac (option ((bv & typ) & (bool & term)))
let genv_get_from_name (ge: genv) (name: string) : Tac (option ((bv & typ) & (bool & term))) = | true | null | false | match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x)) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple3",
"FStar.InteractiveHelpers.Base.bind_map_get_from_name",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) = | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_get_from_name (ge: genv) (name: string) : Tac (option ((bv & typ) & (bool & term))) | [] | FStar.InteractiveHelpers.Base.genv_get_from_name | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> name: Prims.string
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.Native.option ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
(Prims.bool * FStar.Reflection.Types.term))) | {
"end_col": 56,
"end_line": 268,
"start_col": 2,
"start_line": 266
} |
FStar.Tactics.Effect.Tac | val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")" | val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x = | true | null | false | match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")" | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"Prims.string",
"FStar.Pervasives.Native.option",
"Prims.op_Hat"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string | [] | FStar.InteractiveHelpers.Base.option_to_string | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> FStar.Tactics.Effect.Tac Prims.string) -> x: FStar.Pervasives.Native.option a
-> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 36,
"end_line": 48,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | val opt_cons (#a: Type) (opt_x: option a) (ls: list a) : Tot (list a) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls | val opt_cons (#a: Type) (opt_x: option a) (ls: list a) : Tot (list a)
let opt_cons (#a: Type) (opt_x: option a) (ls: list a) : Tot (list a) = | false | null | false | match opt_x with
| Some x -> x :: ls
| None -> ls | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"Prims.list",
"Prims.Cons"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")" | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opt_cons (#a: Type) (opt_x: option a) (ls: list a) : Tot (list a) | [] | FStar.InteractiveHelpers.Base.opt_cons | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | opt_x: FStar.Pervasives.Native.option a -> ls: Prims.list a -> Prims.list a | {
"end_col": 14,
"end_line": 54,
"start_col": 2,
"start_line": 52
} |
FStar.Tactics.Effect.Tac | val genv_push_bv (ge: genv) (b: bv) (sort: typ) (abs: bool) (t: option term) : Tac genv | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars' | val genv_push_bv (ge: genv) (b: bv) (sort: typ) (abs: bool) (t: option term) : Tac genv
let genv_push_bv (ge: genv) (b: bv) (sort: typ) (abs: bool) (t: option term) : Tac genv = | true | null | false | let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars' | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"Prims.bool",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term",
"FStar.InteractiveHelpers.Base.mk_genv",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"FStar.InteractiveHelpers.Base.bind_map_push",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__bmap",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.Reflection.Types.env",
"FStar.Reflection.V1.Builtins.push_binder",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env",
"Prims.Cons",
"FStar.Pervasives.Native.fst",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__svars",
"FStar.InteractiveHelpers.Base.genv_get_from_name",
"Prims.string",
"FStar.Tactics.V1.Derived.name_of_bv",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V1.Derived.mk_binder"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val genv_push_bv (ge: genv) (b: bv) (sort: typ) (abs: bool) (t: option term) : Tac genv | [] | FStar.InteractiveHelpers.Base.genv_push_bv | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
ge: FStar.InteractiveHelpers.Base.genv ->
b: FStar.Reflection.Types.bv ->
sort: FStar.Reflection.Types.typ ->
abs: Prims.bool ->
t: FStar.Pervasives.Native.option FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.Base.genv | {
"end_col": 25,
"end_line": 279,
"start_col": 84,
"start_line": 272
} |
Prims.Tot | val bind_map_get (#a: Type) (m: bind_map a) (b: bv) : Tot (option a) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b | val bind_map_get (#a: Type) (m: bind_map a) (b: bv) : Tot (option a)
let rec bind_map_get (#a: Type) (m: bind_map a) (b: bv) : Tot (option a) = | false | null | false | match m with
| [] -> None
| (b', x) :: m' -> if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"FStar.InteractiveHelpers.Base.bind_map",
"FStar.Reflection.Types.bv",
"FStar.Pervasives.Native.None",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Equality",
"FStar.Order.order",
"FStar.Reflection.V1.Builtins.compare_bv",
"FStar.Order.Eq",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.InteractiveHelpers.Base.bind_map_get",
"FStar.Pervasives.Native.option"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_map_get (#a: Type) (m: bind_map a) (b: bv) : Tot (option a) | [
"recursion"
] | FStar.InteractiveHelpers.Base.bind_map_get | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.InteractiveHelpers.Base.bind_map a -> b: FStar.Reflection.Types.bv
-> FStar.Pervasives.Native.option a | {
"end_col": 68,
"end_line": 202,
"start_col": 2,
"start_line": 199
} |
FStar.Tactics.Effect.Tac | val opt_apply_subst : env -> option term -> list ((bv & typ) & term) -> Tac (option term) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opt_apply_subst e opt_t subst =
match opt_t with
| None -> None
| Some t -> Some (apply_subst e t subst) | val opt_apply_subst : env -> option term -> list ((bv & typ) & term) -> Tac (option term)
let opt_apply_subst e opt_t subst = | true | null | false | match opt_t with
| None -> None
| Some t -> Some (apply_subst e t subst) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.InteractiveHelpers.Base.apply_subst"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp
let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2
let norm_apply_subst_in_comp e c subst =
let subst = (fun x -> norm_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
/// As substitution with normalization is very expensive, we implemented another
/// technique which works by exploring terms. This is super fast, but the terms
/// seem not to be reconstructed in the same way, which has a big impact on pretty printing.
/// For example, terms like [A /\ B] get printed as [Prims.l_and A B].
val deep_apply_subst : env -> term -> list (bv & term) -> Tac term
// Whenever we encounter a construction which introduces a binder, we need to apply
// the substitution in the binder type. Note that this gives a new binder, with
// which we need to replace the old one in what follows.
// Also note that it should be possible to rewrite [deep_apply_subst] in terms of [visit_tm],
// but [deep_apply_subst] seems to be a bit more precise with regard to type replacements (not
// sure it is really important, though).
val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
val deep_apply_subst_in_binder : env -> binder -> list (bv & term) -> Tac (binder & list (bv & term))
val deep_apply_subst_in_comp : env -> comp -> list (bv & term) -> Tac comp
val deep_apply_subst_in_pattern : env -> pattern -> list (bv & term) -> Tac (pattern & list (bv & term))
let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables
(there is no longer a sort). But, shift the substitution. *)
bv, (bv, pack (Tv_Var bv))::subst
(*
* AR: TODO: should apply subst in attrs?
*)
and deep_apply_subst_in_binder e br subst =
let open inspect_binder br <: binder_view in
let binder_sort = deep_apply_subst e binder_sort subst in
let binder_bv, subst = deep_apply_subst_in_bv e binder_bv subst in
pack_binder {
binder_bv=binder_bv;
binder_qual=binder_qual;
binder_attrs=binder_attrs;
binder_sort=binder_sort;
}, subst
and deep_apply_subst_in_comp e c subst =
let subst = (fun x -> deep_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
and deep_apply_subst_in_pattern e pat subst =
match pat with
| Pat_Constant _ -> pat, subst
| Pat_Cons fv us patterns ->
(* The types of the variables in the patterns should be independent of each
* other: we use fold_left only to incrementally update the substitution *)
let patterns, subst =
fold_right (fun (pat, b) (pats, subst) ->
let pat, subst = deep_apply_subst_in_pattern e pat subst in
((pat, b) :: pats, subst)) patterns ([], subst)
in
Pat_Cons fv us patterns, subst
| Pat_Var bv st ->
let st = Sealed.seal (deep_apply_subst e (unseal st) subst) in
let bv, subst = deep_apply_subst_in_bv e bv subst in
Pat_Var bv st, subst
| Pat_Dot_Term eopt ->
Pat_Dot_Term (map_opt (fun t -> deep_apply_subst e t subst) eopt), subst
/// The substitution functions actually used in the rest of the meta F* functions.
/// For now, we use normalization because even though it is sometimes slow it
/// gives prettier terms, and readability is the priority. In order to mitigate
/// the performance issue, we try to minimize the number of calls to those functions,
/// by doing lazy instantiations for example (rather than incrementally apply
/// substitutions in a term, accumulate the substitutions and perform them all at once).
/// TODO: would it be good to have a native substitution function in F*
let apply_subst = norm_apply_subst
let apply_subst_in_comp = norm_apply_subst_in_comp
val opt_apply_subst : env -> option term -> list ((bv & typ) & term) -> Tac (option term) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opt_apply_subst : env -> option term -> list ((bv & typ) & term) -> Tac (option term) | [] | FStar.InteractiveHelpers.Base.opt_apply_subst | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
opt_t: FStar.Pervasives.Native.option FStar.Reflection.Types.term ->
subst:
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.term)
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.Reflection.Types.term) | {
"end_col": 42,
"end_line": 591,
"start_col": 2,
"start_line": 589
} |
FStar.Tactics.Effect.Tac | val _generate_shadowed_subst (ge: genv) (t: term) (bvl: list (bv & typ))
: Tac (genv & list (bv & typ & bv)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec _generate_shadowed_subst (ge:genv) (t:term) (bvl : list (bv & typ)) :
Tac (genv & list (bv & typ & bv)) =
match bvl with
| [] -> ge, []
| old_bv :: bvl' ->
match inspect t with
| Tv_Abs b _ ->
(* Introduce the new binder *)
let bv = (inspect_binder b).binder_bv in
let bvv = inspect_bv bv in
let ty = binder_sort b in
let name = unseal bvv.bv_ppname in
let ge1, fresh = genv_push_fresh_bv ge ("__" ^ name) ty in
let t1 = mk_e_app t [pack (Tv_Var fresh)] in
let t2 = norm_term_env ge1.env [] t1 in
(* Recursion *)
let ge2, nbvl = _generate_shadowed_subst ge1 t2 bvl' in
(* Return *)
ge2, (fst old_bv, ty, fresh) :: nbvl
| _ -> mfail "_subst_with_fresh_vars: not a Tv_Abs" | val _generate_shadowed_subst (ge: genv) (t: term) (bvl: list (bv & typ))
: Tac (genv & list (bv & typ & bv))
let rec _generate_shadowed_subst (ge: genv) (t: term) (bvl: list (bv & typ))
: Tac (genv & list (bv & typ & bv)) = | true | null | false | match bvl with
| [] -> ge, []
| old_bv :: bvl' ->
match inspect t with
| Tv_Abs b _ ->
let bv = (inspect_binder b).binder_bv in
let bvv = inspect_bv bv in
let ty = binder_sort b in
let name = unseal bvv.bv_ppname in
let ge1, fresh = genv_push_fresh_bv ge ("__" ^ name) ty in
let t1 = mk_e_app t [pack (Tv_Var fresh)] in
let t2 = norm_term_env ge1.env [] t1 in
let ge2, nbvl = _generate_shadowed_subst ge1 t2 bvl' in
ge2, (fst old_bv, ty, fresh) :: nbvl
| _ -> mfail "_subst_with_fresh_vars: not a Tv_Abs" | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple3",
"Prims.Nil",
"FStar.Reflection.Types.binder",
"Prims.Cons",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.fst",
"FStar.InteractiveHelpers.Base._generate_shadowed_subst",
"FStar.Tactics.V1.Builtins.norm_term_env",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env",
"FStar.Pervasives.norm_step",
"FStar.Reflection.V1.Derived.mk_e_app",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Var",
"FStar.InteractiveHelpers.Base.genv_push_fresh_bv",
"Prims.op_Hat",
"Prims.string",
"FStar.Tactics.Unseal.unseal",
"FStar.Reflection.V1.Data.__proj__Mkbv_view__item__bv_ppname",
"FStar.Tactics.V1.Derived.binder_sort",
"FStar.Reflection.V1.Data.bv_view",
"Prims.precedes",
"FStar.Reflection.V1.Builtins.inspect_bv",
"FStar.Reflection.V1.Data.__proj__Mkbinder_view__item__binder_bv",
"FStar.Reflection.V1.Builtins.inspect_binder",
"FStar.Reflection.V1.Data.term_view",
"FStar.InteractiveHelpers.Base.mfail",
"FStar.Tactics.V1.Builtins.inspect"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name
noeq type genv =
{
env : env;
(* Whenever we evaluate a let binding, we keep track of the relation between
* the binder and its definition.
* The boolean indicates whether or not the variable is considered abstract. We
* often need to introduce variables which don't appear in the user context, for
* example when we need to deal with a postcondition for Stack or ST, which handles
* the previous and new memory states, and which may not be available in the user
* context, or where we don't always know which variable to use.
* In this case, whenever we output the term, we write its content as an
* abstraction applied to those missing parameters. For instance, in the
* case of the assertion introduced for a post-condition:
* [> assert((fun h1 h2 -> post) h1 h2);
* Besides the informative goal, the user can replace those parameters (h1
* and h2 above) by the proper ones then normalize the assertion by using
* the appropriate command to get a valid assertion. *)
bmap : bind_map (typ & bool & term);
(* Whenever we introduce a new variable, we check whether it shadows another
* variable because it has the same name, and put it in the below
* list. Of course, for the F* internals such shadowing is not an issue, because
* the index of every variable should be different, but this is very important
* when generating code for the user *)
svars : list (bv & typ);
}
let get_env (e:genv) : env = e.env
let get_bind_map (e:genv) : bind_map (typ & bool & term) = e.bmap
let mk_genv env bmap svars : genv = Mkgenv env bmap svars
let mk_init_genv env : genv = mk_genv env [] []
val genv_to_string : genv -> Tac string
let genv_to_string ge =
let binder_to_string (b : binder) : Tac string =
abv_to_string (bv_of_binder b) ^ "\n"
in
let binders_str = map binder_to_string (binders_of_env ge.env) in
let bmap_elem_to_string (e : bv & (typ & bool & term)) : Tac string =
let bv, (_sort, abs, t) = e in
"(" ^ abv_to_string bv ^" -> (" ^
string_of_bool abs ^ ", " ^ term_to_string t ^ "))\n"
in
let bmap_str = map bmap_elem_to_string ge.bmap in
let svars_str = map (fun (bv, _) -> abv_to_string bv ^ "\n") ge.svars in
let flatten = List.Tot.fold_left (fun x y -> x ^ y) "" in
"> env:\n" ^ flatten binders_str ^
"> bmap:\n" ^ flatten bmap_str ^
"> svars:\n" ^ flatten svars_str
let genv_get (ge:genv) (b:bv) : Tot (option (typ & bool & term)) =
bind_map_get ge.bmap b
let genv_get_from_name (ge:genv) (name:string) : Tac (option ((bv & typ) & (bool & term))) =
(* tweak return a bit to include sort *)
match bind_map_get_from_name ge.bmap name with
| None -> None
| Some (bv, (sort, b, x)) -> Some ((bv, sort), (b, x))
/// Push a binder to a ``genv``. Optionally takes a ``term`` which provides the
/// term the binder is bound to (in a `let _ = _ in` construct for example).
let genv_push_bv (ge:genv) (b:bv) (sort:typ) (abs:bool) (t:option term) : Tac genv =
let br = mk_binder b sort in
let sv = genv_get_from_name ge (name_of_bv b) in
let svars' = if Some? sv then fst (Some?.v sv) :: ge.svars else ge.svars in
let e' = push_binder ge.env br in
let tm = if Some? t then Some?.v t else pack (Tv_Var b) in
let bmap' = bind_map_push ge.bmap b (sort, abs, tm) in
mk_genv e' bmap' svars'
let genv_push_binder (ge:genv) (b:binder) (abs:bool) (t:option term) : Tac genv =
genv_push_bv ge (bv_of_binder b) (binder_sort b) abs t
/// Check if a binder is shadowed by another more recent binder
let bv_is_shadowed (ge : genv) (bv : bv) : Tot bool =
List.Tot.existsb (fun (b,_) -> bv_eq bv b) ge.svars
let binder_is_shadowed (ge : genv) (b : binder) : Tot bool =
bv_is_shadowed ge (bv_of_binder b)
let find_shadowed_bvs (ge : genv) (bl : list bv) : Tot (list (bv & bool)) =
List.Tot.map (fun b -> b, bv_is_shadowed ge b) bl
let find_shadowed_binders (ge : genv) (bl : list binder) : Tot (list (binder & bool)) =
List.Tot.map (fun b -> b, binder_is_shadowed ge b) bl
val bv_is_abstract : genv -> bv -> Tot bool
let bv_is_abstract ge bv =
match genv_get ge bv with
| None -> false
| Some (_, abs, _) -> abs
val binder_is_abstract : genv -> binder -> Tot bool
let binder_is_abstract ge b =
bv_is_abstract ge (bv_of_binder b)
val genv_abstract_bvs : genv -> Tot (list (bv & typ))
let genv_abstract_bvs ge =
List.Tot.concatMap
(fun (bv, (ty, abs, _)) -> if abs then [bv,ty] else []) ge.bmap
/// Versions of ``fresh_bv`` and ``fresh_binder`` inspired by the standard library
/// We make sure the name is fresh because we need to be able to generate valid code
/// (it is thus not enough to have a fresh integer).
let rec _fresh_bv binder_names basename i : Tac bv =
let name = basename ^ string_of_int i in
(* In worst case the performance is quadratic in the number of binders.
* TODO: fix that, it actually probably happens for anonymous variables ('_') *)
if List.mem name binder_names then _fresh_bv binder_names basename (i+1)
else fresh_bv_named name
let fresh_bv (e : env) (basename : string) : Tac bv =
let binders = binders_of_env e in
let binder_names = Tactics.map name_of_binder binders in
_fresh_bv binder_names basename 0
let fresh_binder (e : env) (basename : string) (ty : typ) : Tac binder =
let bv = fresh_bv e basename in
mk_binder bv ty
let genv_push_fresh_binder (ge : genv) (basename : string) (ty : typ) : Tac (genv & binder) =
let b = fresh_binder ge.env basename ty in
(* TODO: we can have a shortcircuit push (which performs less checks) *)
let ge' = genv_push_binder ge b true None in
ge', b
// TODO: actually we should use push_fresh_bv more
let push_fresh_binder (e : env) (basename : string) (ty : typ) : Tac (env & binder) =
let b = fresh_binder e basename ty in
let e' = push_binder e b in
e', b
let genv_push_fresh_bv (ge : genv) (basename : string) (ty : typ) : Tac (genv & bv) =
let ge', b = genv_push_fresh_binder ge basename ty in
ge', bv_of_binder b
val push_fresh_var : env -> string -> typ -> Tac (term & binder & env)
let push_fresh_var e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, e1
val genv_push_fresh_var : genv -> string -> typ -> Tac (term & binder & genv)
let genv_push_fresh_var ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
v1, b1, ge1
val push_two_fresh_vars : env -> string -> typ -> Tac (term & binder & term & binder & env)
let push_two_fresh_vars e0 basename ty =
let e1, b1 = push_fresh_binder e0 basename ty in
let e2, b2 = push_fresh_binder e1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, e2
val genv_push_two_fresh_vars : genv -> string -> typ -> Tac (term & binder & term & binder & genv)
let genv_push_two_fresh_vars ge0 basename ty =
let ge1, b1 = genv_push_fresh_binder ge0 basename ty in
let ge2, b2 = genv_push_fresh_binder ge1 basename ty in
let v1 = pack (Tv_Var (bv_of_binder b1)) in
let v2 = pack (Tv_Var (bv_of_binder b2)) in
v1, b1, v2, b2, ge2
(*** Substitutions *)
/// Substitutions
/// Custom substitutions using the normalizer. This is the easiest and safest
/// way to perform a substitution: if you want to substitute [v] with [t] in [exp],
/// just normalize [(fun v -> exp) t]. Note that this may be computationally expensive.
val norm_apply_subst : env -> term -> list ((bv & typ) & term) -> Tac term
val norm_apply_subst_in_comp : env -> comp -> list ((bv & typ) & term) -> Tac comp
let norm_apply_subst e t subst =
let bl, vl = unzip subst in
let bl = List.Tot.map (fun (bv,ty) -> mk_binder bv ty) bl in
let t1 = mk_abs bl t in
let t2 = mk_e_app t1 vl in
norm_term_env e [] t2
let norm_apply_subst_in_comp e c subst =
let subst = (fun x -> norm_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
/// As substitution with normalization is very expensive, we implemented another
/// technique which works by exploring terms. This is super fast, but the terms
/// seem not to be reconstructed in the same way, which has a big impact on pretty printing.
/// For example, terms like [A /\ B] get printed as [Prims.l_and A B].
val deep_apply_subst : env -> term -> list (bv & term) -> Tac term
// Whenever we encounter a construction which introduces a binder, we need to apply
// the substitution in the binder type. Note that this gives a new binder, with
// which we need to replace the old one in what follows.
// Also note that it should be possible to rewrite [deep_apply_subst] in terms of [visit_tm],
// but [deep_apply_subst] seems to be a bit more precise with regard to type replacements (not
// sure it is really important, though).
val deep_apply_subst_in_bv : env -> bv -> list (bv & term) -> Tac (bv & list (bv & term))
val deep_apply_subst_in_binder : env -> binder -> list (bv & term) -> Tac (binder & list (bv & term))
val deep_apply_subst_in_comp : env -> comp -> list (bv & term) -> Tac comp
val deep_apply_subst_in_pattern : env -> pattern -> list (bv & term) -> Tac (pattern & list (bv & term))
let rec deep_apply_subst e t subst =
match inspect t with
| Tv_Var b ->
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_BVar b ->
(* Note: Tv_BVar shouldn't happen *)
begin match bind_map_get subst b with
| None -> t
| Some t' -> t'
end
| Tv_FVar _ -> t
| Tv_App hd (a,qual) ->
let hd = deep_apply_subst e hd subst in
let a = deep_apply_subst e a subst in
pack (Tv_App hd (a, qual))
| Tv_Abs br body ->
let body = deep_apply_subst e body subst in
pack (Tv_Abs br body)
| Tv_Arrow br c ->
let br, subst = deep_apply_subst_in_binder e br subst in
let c = deep_apply_subst_in_comp e c subst in
pack (Tv_Arrow br c)
| Tv_Type _ -> t
| Tv_Refine bv sort ref ->
let sort = deep_apply_subst e sort subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let ref = deep_apply_subst e ref subst in
pack (Tv_Refine bv sort ref)
| Tv_Const _ -> t
| Tv_Uvar _ _ -> t
| Tv_Let recf attrs bv ty def body ->
(* No need to substitute in the attributes - that we filter for safety *)
let ty = deep_apply_subst e ty subst in
let def = deep_apply_subst e def subst in
let bv, subst = deep_apply_subst_in_bv e bv subst in
let body = deep_apply_subst e body subst in
pack (Tv_Let recf [] bv ty def body)
| Tv_Match scrutinee ret_opt branches -> (* TODO: type of pattern variables *)
let scrutinee = deep_apply_subst e scrutinee subst in
let ret_opt = map_opt (fun (b, asc) ->
let b, subst = deep_apply_subst_in_binder e b subst in
let asc =
match asc with
| Inl t, tacopt, use_eq ->
Inl (deep_apply_subst e t subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq
| Inr c, tacopt, use_eq ->
Inr (deep_apply_subst_in_comp e c subst),
map_opt (fun tac -> deep_apply_subst e tac subst) tacopt,
use_eq in
b, asc) ret_opt in
(* For the branches: we don't need to explore the patterns *)
let deep_apply_subst_in_branch branch =
let pat, tm = branch in
let pat, subst = deep_apply_subst_in_pattern e pat subst in
let tm = deep_apply_subst e tm subst in
pat, tm
in
let branches = map deep_apply_subst_in_branch branches in
pack (Tv_Match scrutinee ret_opt branches)
| Tv_AscribedT exp ty tac use_eq ->
let exp = deep_apply_subst e exp subst in
let ty = deep_apply_subst e ty subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedT exp ty None use_eq)
| Tv_AscribedC exp c tac use_eq ->
let exp = deep_apply_subst e exp subst in
let c = deep_apply_subst_in_comp e c subst in
(* no need to apply it on the tactic - that we filter for safety *)
pack (Tv_AscribedC exp c None use_eq)
| _ ->
(* Unknown *)
t
and deep_apply_subst_in_bv e bv subst =
(* No substitution needs to happen for variables
(there is no longer a sort). But, shift the substitution. *)
bv, (bv, pack (Tv_Var bv))::subst
(*
* AR: TODO: should apply subst in attrs?
*)
and deep_apply_subst_in_binder e br subst =
let open inspect_binder br <: binder_view in
let binder_sort = deep_apply_subst e binder_sort subst in
let binder_bv, subst = deep_apply_subst_in_bv e binder_bv subst in
pack_binder {
binder_bv=binder_bv;
binder_qual=binder_qual;
binder_attrs=binder_attrs;
binder_sort=binder_sort;
}, subst
and deep_apply_subst_in_comp e c subst =
let subst = (fun x -> deep_apply_subst e x subst) in
let subst_in_aqualv a : Tac aqualv =
match a with
| Q_Implicit
| Q_Explicit -> a
| Q_Meta t -> Q_Meta (subst t)
in
match inspect_comp c with
| C_Total ret ->
let ret = subst ret in
pack_comp (C_Total ret)
| C_GTotal ret ->
let ret = subst ret in
pack_comp (C_GTotal ret)
| C_Lemma pre post patterns ->
let pre = subst pre in
let post = subst post in
let patterns = subst patterns in
pack_comp (C_Lemma pre post patterns)
| C_Eff us eff_name result eff_args decrs ->
let result = subst result in
let eff_args = map (fun (x, a) -> (subst x, subst_in_aqualv a)) eff_args in
let decrs = map subst decrs in
pack_comp (C_Eff us eff_name result eff_args decrs)
and deep_apply_subst_in_pattern e pat subst =
match pat with
| Pat_Constant _ -> pat, subst
| Pat_Cons fv us patterns ->
(* The types of the variables in the patterns should be independent of each
* other: we use fold_left only to incrementally update the substitution *)
let patterns, subst =
fold_right (fun (pat, b) (pats, subst) ->
let pat, subst = deep_apply_subst_in_pattern e pat subst in
((pat, b) :: pats, subst)) patterns ([], subst)
in
Pat_Cons fv us patterns, subst
| Pat_Var bv st ->
let st = Sealed.seal (deep_apply_subst e (unseal st) subst) in
let bv, subst = deep_apply_subst_in_bv e bv subst in
Pat_Var bv st, subst
| Pat_Dot_Term eopt ->
Pat_Dot_Term (map_opt (fun t -> deep_apply_subst e t subst) eopt), subst
/// The substitution functions actually used in the rest of the meta F* functions.
/// For now, we use normalization because even though it is sometimes slow it
/// gives prettier terms, and readability is the priority. In order to mitigate
/// the performance issue, we try to minimize the number of calls to those functions,
/// by doing lazy instantiations for example (rather than incrementally apply
/// substitutions in a term, accumulate the substitutions and perform them all at once).
/// TODO: would it be good to have a native substitution function in F*
let apply_subst = norm_apply_subst
let apply_subst_in_comp = norm_apply_subst_in_comp
val opt_apply_subst : env -> option term -> list ((bv & typ) & term) -> Tac (option term)
let opt_apply_subst e opt_t subst =
match opt_t with
| None -> None
| Some t -> Some (apply_subst e t subst)
(*** Variable shadowing *)
/// Introduce fresh variables to generate a substitution for the variables shadowed
/// in the current environment.
val generate_shadowed_subst : genv -> Tac (genv & list (bv & typ & bv))
/// In order to introduce variables with coherent types (the variables' types
/// may be dependent) and make things simpler, we build one big term:
/// [> (fun x1 x2 ... xn -> ())
/// Then, for each variable, we introduce a fresh variable with the same type as
/// the outermost abstraction, apply the above term to this new variable and
/// normalize to "apply" the substitution and reveal the next binding.
let rec _generate_shadowed_subst (ge:genv) (t:term) (bvl : list (bv & typ)) : | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val _generate_shadowed_subst (ge: genv) (t: term) (bvl: list (bv & typ))
: Tac (genv & list (bv & typ & bv)) | [
"recursion"
] | FStar.InteractiveHelpers.Base._generate_shadowed_subst | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
ge: FStar.InteractiveHelpers.Base.genv ->
t: FStar.Reflection.Types.term ->
bvl: Prims.list (FStar.Reflection.Types.bv * FStar.Reflection.Types.typ)
-> FStar.Tactics.Effect.Tac
(FStar.InteractiveHelpers.Base.genv *
Prims.list ((FStar.Reflection.Types.bv * FStar.Reflection.Types.typ) *
FStar.Reflection.Types.bv)) | {
"end_col": 55,
"end_line": 624,
"start_col": 2,
"start_line": 607
} |
Prims.Tot | val unzip (#a #b: _) (l: list (a & b)) : Tot (list a & list b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2) | val unzip (#a #b: _) (l: list (a & b)) : Tot (list a & list b)
let rec unzip #a #b (l: list (a & b)) : Tot (list a & list b) = | false | null | false | match l with
| [] -> ([], [])
| (hd1, hd2) :: tl ->
let tl1, tl2 = unzip tl in
(hd1 :: tl1, hd2 :: tl2) | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"Prims.Cons",
"FStar.InteractiveHelpers.Base.unzip"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unzip (#a #b: _) (l: list (a & b)) : Tot (list a & list b) | [
"recursion"
] | FStar.InteractiveHelpers.Base.unzip | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: Prims.list (a * b) -> Prims.list a * Prims.list b | {
"end_col": 26,
"end_line": 79,
"start_col": 2,
"start_line": 75
} |
FStar.Tactics.Effect.Tac | val bind_map_get_from_name (#a: Type) (m: bind_map a) (name: string) : Tac (option (bv & a)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) :
Tac (option (bv & a)) =
match m with
| [] -> None
| (b', x)::m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name | val bind_map_get_from_name (#a: Type) (m: bind_map a) (name: string) : Tac (option (bv & a))
let rec bind_map_get_from_name (#a: Type) (m: bind_map a) (name: string) : Tac (option (bv & a)) = | true | null | false | match m with
| [] -> None
| (b', x) :: m' ->
let b'v = inspect_bv b' in
if unseal b'v.bv_ppname = name then Some (b', x) else bind_map_get_from_name m' name | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.bind_map",
"Prims.string",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.bv",
"FStar.Pervasives.Native.option",
"Prims.list",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"FStar.InteractiveHelpers.Base.bind_map_get_from_name",
"Prims.op_Equality",
"FStar.Tactics.Unseal.unseal",
"FStar.Reflection.V1.Data.__proj__Mkbv_view__item__bv_ppname",
"FStar.Reflection.V1.Data.bv_view",
"Prims.precedes",
"FStar.Reflection.V1.Builtins.inspect_bv"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e)
let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str
exception MetaAnalysis of string
let mfail str =
raise (MetaAnalysis str)
(*** Debugging *)
/// Some debugging facilities
val print_dbg : bool -> string -> Tac unit
let print_dbg debug s =
if debug then print s
/// Return the qualifier of a term as a string
val term_view_construct (t : term_view) : Tac string
let term_view_construct (t : term_view) : Tac string =
match t with
| Tv_Var _ -> "Tv_Var"
| Tv_BVar _ -> "Tv_BVar"
| Tv_FVar _ -> "Tv_FVar"
| Tv_App _ _ -> "Tv_App"
| Tv_Abs _ _ -> "Tv_Abs"
| Tv_Arrow _ _ -> "Tv_Arrow"
| Tv_Type _ -> "Tv_Type"
| Tv_Refine _ _ _ -> "Tv_Refine"
| Tv_Const _ -> "Tv_Const"
| Tv_Uvar _ _ -> "Tv_Uvar"
| Tv_Let _ _ _ _ _ _ -> "Tv_Let"
| Tv_Match _ _ _ -> "Tv_Match"
| Tv_AscribedT _ _ _ _ -> "Tv_AscribedT"
| Tv_AscribedC _ _ _ _ -> "Tv_AScribedC"
| _ -> "Tv_Unknown"
val term_construct (t : term) : Tac string
let term_construct (t : term) : Tac string =
term_view_construct (inspect t)
(*** Pretty printing *)
/// There are many issues linked to terms (pretty) printing.
/// The first issue is that when parsing terms, F* automatically inserts
/// ascriptions, which then clutter the terms printed to the user. The current
/// workaround is to filter those ascriptions in the terms before exploiting them.
/// TODO: this actually doesn't work for some unknown reason: some terms like [a /\ b]
/// become [l_and a b]...
val filter_ascriptions : bool -> term -> Tac term
let filter_ascriptions dbg t =
print_dbg dbg ("[> filter_ascriptions: " ^ term_view_construct t ^ ": " ^ term_to_string t );
visit_tm (fun t ->
match inspect t with
| Tv_AscribedT e _ _ _
| Tv_AscribedC e _ _ _ -> e
| _ -> t) t
/// Our prettification function. Apply it to all the terms which might be printed
/// back to the user. Note that the time at which the function is applied is
/// important: we can't apply it on all the assertions we export to the user, just
/// before exporting, because we may have inserted ascriptions on purpose, which
/// would then be filtered away.
val prettify_term : bool -> term -> Tac term
let prettify_term dbg t = filter_ascriptions dbg t
(*** Environments *)
/// We need a way to handle environments with variable bindings
/// and name shadowing, to properly display the context to the user.
/// A map linking variables to terms. For now we use a list to define it, because
/// there shouldn't be too many bindings.
type bind_map (a : Type) = list (bv & a)
let bind_map_push (#a:Type) (m:bind_map a) (b:bv) (x:a) = (b,x)::m
let rec bind_map_get (#a:Type) (m:bind_map a) (b:bv) : Tot (option a) =
match m with
| [] -> None
| (b', x)::m' ->
if compare_bv b b' = Order.Eq then Some x else bind_map_get m' b
let rec bind_map_get_from_name (#a:Type) (m:bind_map a) (name:string) : | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_map_get_from_name (#a: Type) (m: bind_map a) (name: string) : Tac (option (bv & a)) | [
"recursion"
] | FStar.InteractiveHelpers.Base.bind_map_get_from_name | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.InteractiveHelpers.Base.bind_map a -> name: Prims.string
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (FStar.Reflection.Types.bv * a)) | {
"end_col": 88,
"end_line": 210,
"start_col": 2,
"start_line": 206
} |
FStar.Tactics.Effect.Tac | val acomp_to_string (c: comp) : Tac string | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let acomp_to_string (c:comp) : Tac string =
match inspect_comp c with
| C_Total ret ->
"C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret ->
"C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns ->
"C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a : term) : Tac string =
" (" ^ term_to_string a ^ ")"
in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str | val acomp_to_string (c: comp) : Tac string
let acomp_to_string (c: comp) : Tac string = | true | null | false | match inspect_comp c with
| C_Total ret -> "C_Total (" ^ term_to_string ret ^ ")"
| C_GTotal ret -> "C_GTotal (" ^ term_to_string ret ^ ")"
| C_Lemma pre post patterns -> "C_Lemma (" ^ term_to_string pre ^ ") (" ^ term_to_string post ^ ")"
| C_Eff us eff_name result eff_args _ ->
let eff_arg_to_string (a: term) : Tac string = " (" ^ term_to_string a ^ ")" in
let args_str = map (fun (x, y) -> eff_arg_to_string x) eff_args in
let args_str = List.Tot.fold_left (fun x y -> x ^ y) "" args_str in
"C_Eff (" ^ flatten_name eff_name ^ ") (" ^ term_to_string result ^ ")" ^ args_str | {
"checked_file": "FStar.InteractiveHelpers.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Sealed.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Base.fst"
} | [] | [
"FStar.Reflection.Types.comp",
"FStar.Reflection.V1.Builtins.inspect_comp",
"FStar.Reflection.Types.typ",
"Prims.op_Hat",
"Prims.string",
"FStar.Tactics.V1.Builtins.term_to_string",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Data.universes",
"FStar.Reflection.Types.name",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.V1.Derived.flatten_name",
"FStar.List.Tot.Base.fold_left",
"FStar.Tactics.Util.map",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.aqualv"
] | [] | module FStar.InteractiveHelpers.Base
open FStar.List
open FStar.Tactics
open FStar.Mul
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Utilities *)
val bv_eq : bv -> bv -> Tot bool
let bv_eq (bv1 bv2 : bv) =
let bvv1 = inspect_bv bv1 in
let bvv2 = inspect_bv bv2 in
(* We don't check for type equality: the fact that no two different binders
* have the same name and index is an invariant which must be enforced -
* and actually we could limit ourselves to checking the index *)
bvv1.bv_index = bvv2.bv_index
val fv_eq : fv -> fv -> Tot bool
let fv_eq fv1 fv2 =
let n1 = inspect_fv fv1 in
let n2 = inspect_fv fv2 in
n1 = n2
// TODO: use everywhere
val fv_eq_name : fv -> name -> Tot bool
let fv_eq_name fv n =
let fvn = inspect_fv fv in
fvn = n
// TODO: use more
val opt_apply (#a #b : Type) (f : a -> Tot b) (x : option a) : Tot (option b)
let opt_apply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val opt_tapply (#a #b : Type) (f : a -> Tac b) (x : option a) : Tac (option b)
let opt_tapply #a #b f x =
match x with
| None -> None
| Some x' -> Some (f x')
val option_to_string : (#a : Type) -> (a -> Tac string) -> option a -> Tac string
let option_to_string #a f x =
match x with
| None -> "None"
| Some x' -> "Some (" ^ f x' ^ ")"
let opt_cons (#a : Type) (opt_x : option a) (ls : list a) : Tot (list a) =
match opt_x with
| Some x -> x :: ls
| None -> ls
val list_to_string : #a : Type -> (a -> Tac string) -> list a -> Tac string
let list_to_string #a f ls =
(Tactics.Util.fold_left (fun s x -> s ^ " (" ^ f x ^ ");") "[" ls) ^ "]"
/// Apply a term to a list of parameters, normalize the result to make sure
/// all the abstractions are simplified
val mk_app_norm : env -> term -> list term -> Tac term
let mk_app_norm e t params =
let t1 = mk_e_app t params in
let t2 = norm_term_env e [] t1 in
t2
val opt_mk_app_norm : env -> option term -> list term -> Tac (option term)
let opt_mk_app_norm e opt_t params =
opt_tapply (fun t -> mk_app_norm e t params) opt_t
// TODO: remove
let rec unzip #a #b (l : list (a & b)) : Tot (list a & list b) =
match l with
| [] -> ([],[])
| (hd1,hd2)::tl ->
let (tl1,tl2) = unzip tl in
(hd1::tl1,hd2::tl2)
/// Alternative ``bv_to_string`` function where we print the index of the bv.
/// It can be very useful for debugging.
let abv_to_string bv : Tac string =
let bvv = inspect_bv bv in
name_of_bv bv ^ " (%" ^ string_of_int (bvv.bv_index) ^ ")"
let print_binder_info (full : bool) (b : binder) : Tac unit =
let open inspect_binder b <: binder_view in
let qual_str = match binder_qual with
| Q_Implicit -> "Implicit"
| Q_Explicit -> "Explicit"
| Q_Meta t -> "Meta: " ^ term_to_string t
in
let bview = inspect_bv binder_bv in
if full then
print (
"> print_binder_info:" ^
"\n- name: " ^ (name_of_binder b) ^
"\n- as string: " ^ (binder_to_string b) ^
"\n- aqual: " ^ qual_str ^
"\n- ppname: " ^ name_of_bv binder_bv ^
"\n- index: " ^ string_of_int bview.bv_index ^
"\n- sort: " ^ term_to_string binder_sort
)
else print (binder_to_string b)
let print_binders_info (full : bool) (e:env) : Tac unit =
iter (print_binder_info full) (binders_of_env e) | false | false | FStar.InteractiveHelpers.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val acomp_to_string (c: comp) : Tac string | [] | FStar.InteractiveHelpers.Base.acomp_to_string | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Base.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Types.comp -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 86,
"end_line": 124,
"start_col": 2,
"start_line": 111
} |
Prims.Tot | val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0 | val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i = | false | null | false | if v t > v (cdf_table a).[ i ] then 1 else 0 | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.uint16",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.Frodo.Params.cdf_table_len",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"Spec.Frodo.Params.cdf_table",
"Prims.bool",
"Prims.nat",
"Prims.l_or",
"Prims.op_Equality",
"Prims.int"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1} | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1} | [] | Spec.Frodo.Sample.frodo_sample_f | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
t: Lib.IntTypes.uint16 ->
i: Lib.IntTypes.size_nat{i < Spec.Frodo.Params.cdf_table_len a}
-> res: Prims.nat{res = 0 \/ res = 1} | {
"end_col": 44,
"end_line": 26,
"start_col": 2,
"start_line": 26
} |
Prims.GTot | val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1) | val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i = | false | null | false | if i = 0 then 0 else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1) | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"sometrivial",
""
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.uint16",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Frodo.Params.cdf_table_len",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.op_Addition",
"Spec.Frodo.Sample.frodo_sample_f",
"Prims.op_Subtraction",
"Spec.Frodo.Sample.frodo_sample_fc",
"Prims.nat",
"Prims.l_and"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i) | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i) | [
"recursion"
] | Spec.Frodo.Sample.frodo_sample_fc | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
t: Lib.IntTypes.uint16 ->
i: Lib.IntTypes.size_nat{i <= Spec.Frodo.Params.cdf_table_len a}
-> Prims.GTot (res: Prims.nat{0 <= res /\ res <= i}) | {
"end_col": 63,
"end_line": 38,
"start_col": 2,
"start_line": 37
} |
Prims.Tot | val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_res a r0 e =
let open FStar.Math.Lib in
let e = (powx (-1) (v r0)) * e in
assert_norm (powx (-1) 1 == -1);
assert_norm (powx (-1) 0 == 1);
assert (-cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16) | val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16
let frodo_sample_res a r0 e = | false | null | false | let open FStar.Math.Lib in
let e = (powx (- 1) (v r0)) * e in
assert_norm (powx (- 1) 1 == - 1);
assert_norm (powx (- 1) 0 == 1);
assert (- cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16) | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.uint16",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.nat",
"Prims.op_LessThan",
"Spec.Frodo.Params.cdf_table_len",
"Lib.IntTypes.u16",
"Prims.op_Modulus",
"Lib.IntTypes.modulus",
"Prims.unit",
"Prims._assert",
"Prims.l_and",
"Prims.op_Minus",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.Math.Lib.powx",
"FStar.Mul.op_Star"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1)
val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16 | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16 | [] | Spec.Frodo.Sample.frodo_sample_res | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
sign: Lib.IntTypes.uint16{Lib.IntTypes.v sign <= 1} ->
e: Prims.nat{e < Spec.Frodo.Params.cdf_table_len a}
-> Lib.IntTypes.uint16 | {
"end_col": 23,
"end_line": 53,
"start_col": 2,
"start_line": 48
} |
Prims.Tot | val frodo_sample: a:frodo_alg -> r:uint16 -> uint16 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample a r =
let t = r >>. 1ul in
let r0 = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v r0 == 0 \/ v r0 == 1);
let e =
Loops.repeati_inductive
(cdf_table_len a - 1)
(fun z e -> 0 <= e /\ e <= z /\ e == frodo_sample_fc a t z)
(fun z e -> frodo_sample_f a t z + e) 0 in
frodo_sample_res a r0 e | val frodo_sample: a:frodo_alg -> r:uint16 -> uint16
let frodo_sample a r = | false | null | false | let t = r >>. 1ul in
let r0 = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v r0 == 0 \/ v r0 == 1);
let e =
Loops.repeati_inductive (cdf_table_len a - 1)
(fun z e -> 0 <= e /\ e <= z /\ e == frodo_sample_fc a t z)
(fun z e -> frodo_sample_f a t z + e)
0
in
frodo_sample_res a r0 e | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.uint16",
"Spec.Frodo.Sample.frodo_sample_res",
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Spec.Frodo.Params.cdf_table_len",
"Prims.eq2",
"Spec.Frodo.Sample.frodo_sample_fc",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Addition",
"Spec.Frodo.Sample.frodo_sample_f",
"Prims.unit",
"Prims._assert",
"Prims.l_or",
"Lib.IntTypes.v",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mod_mask",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.mod_mask_lemma",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u16",
"Lib.IntTypes.op_Greater_Greater_Dot"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1)
val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16
let frodo_sample_res a r0 e =
let open FStar.Math.Lib in
let e = (powx (-1) (v r0)) * e in
assert_norm (powx (-1) 1 == -1);
assert_norm (powx (-1) 0 == 1);
assert (-cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16)
#push-options "--fuel 1" | false | true | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample: a:frodo_alg -> r:uint16 -> uint16 | [] | Spec.Frodo.Sample.frodo_sample | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Frodo.Params.frodo_alg -> r: Lib.IntTypes.uint16 -> Lib.IntTypes.uint16 | {
"end_col": 25,
"end_line": 70,
"start_col": 22,
"start_line": 58
} |
Prims.Tot | val frodo_sample_matrix1:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> res:matrix n1 n2
-> matrix n1 n2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_matrix1 a n1 n2 r i res =
Loops.repeati n2 (frodo_sample_matrix0 a n1 n2 r i) res | val frodo_sample_matrix1:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> res:matrix n1 n2
-> matrix n1 n2
let frodo_sample_matrix1 a n1 n2 r i res = | false | null | false | Loops.repeati n2 (frodo_sample_matrix0 a n1 n2 r i) res | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.ByteSequence.lbytes",
"Prims.op_LessThan",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati",
"Spec.Frodo.Sample.frodo_sample_matrix0"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1)
val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16
let frodo_sample_res a r0 e =
let open FStar.Math.Lib in
let e = (powx (-1) (v r0)) * e in
assert_norm (powx (-1) 1 == -1);
assert_norm (powx (-1) 0 == 1);
assert (-cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16)
#push-options "--fuel 1"
val frodo_sample: a:frodo_alg -> r:uint16 -> uint16
let frodo_sample a r =
let t = r >>. 1ul in
let r0 = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v r0 == 0 \/ v r0 == 1);
let e =
Loops.repeati_inductive
(cdf_table_len a - 1)
(fun z e -> 0 <= e /\ e <= z /\ e == frodo_sample_fc a t z)
(fun z e -> frodo_sample_f a t z + e) 0 in
frodo_sample_res a r0 e
#pop-options
// frodo_sample_matrix can be replaced with `creati`
val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2
let frodo_sample_matrix0 a n1 n2 r i j res =
lemma_matrix_index_repeati1 n1 n2 i j;
res.(i, j) <- frodo_sample a (uint_from_bytes_le (LSeq.sub r (2 * (i * n2 + j)) 2))
val frodo_sample_matrix1:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> res:matrix n1 n2
-> matrix n1 n2 | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_matrix1:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> res:matrix n1 n2
-> matrix n1 n2 | [] | Spec.Frodo.Sample.frodo_sample_matrix1 | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat{(2 * n1) * n2 <= Lib.IntTypes.max_size_t} ->
r: Lib.ByteSequence.lbytes ((2 * n1) * n2) ->
i: Lib.IntTypes.size_nat{i < n1} ->
res: Spec.Matrix.matrix n1 n2
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 57,
"end_line": 100,
"start_col": 2,
"start_line": 100
} |
Prims.Tot | val frodo_sample_matrix:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> matrix n1 n2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_matrix a n1 n2 r =
let res = Matrix.create n1 n2 in
Loops.repeati n1 (frodo_sample_matrix1 a n1 n2 r) res | val frodo_sample_matrix:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> matrix n1 n2
let frodo_sample_matrix a n1 n2 r = | false | null | false | let res = Matrix.create n1 n2 in
Loops.repeati n1 (frodo_sample_matrix1 a n1 n2 r) res | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.ByteSequence.lbytes",
"Lib.LoopCombinators.repeati",
"Spec.Matrix.matrix",
"Spec.Frodo.Sample.frodo_sample_matrix1",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1)
val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16
let frodo_sample_res a r0 e =
let open FStar.Math.Lib in
let e = (powx (-1) (v r0)) * e in
assert_norm (powx (-1) 1 == -1);
assert_norm (powx (-1) 0 == 1);
assert (-cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16)
#push-options "--fuel 1"
val frodo_sample: a:frodo_alg -> r:uint16 -> uint16
let frodo_sample a r =
let t = r >>. 1ul in
let r0 = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v r0 == 0 \/ v r0 == 1);
let e =
Loops.repeati_inductive
(cdf_table_len a - 1)
(fun z e -> 0 <= e /\ e <= z /\ e == frodo_sample_fc a t z)
(fun z e -> frodo_sample_f a t z + e) 0 in
frodo_sample_res a r0 e
#pop-options
// frodo_sample_matrix can be replaced with `creati`
val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2
let frodo_sample_matrix0 a n1 n2 r i j res =
lemma_matrix_index_repeati1 n1 n2 i j;
res.(i, j) <- frodo_sample a (uint_from_bytes_le (LSeq.sub r (2 * (i * n2 + j)) 2))
val frodo_sample_matrix1:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> res:matrix n1 n2
-> matrix n1 n2
let frodo_sample_matrix1 a n1 n2 r i res =
Loops.repeati n2 (frodo_sample_matrix0 a n1 n2 r i) res
val frodo_sample_matrix:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> matrix n1 n2 | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_matrix:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> matrix n1 n2 | [] | Spec.Frodo.Sample.frodo_sample_matrix | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat{(2 * n1) * n2 <= Lib.IntTypes.max_size_t} ->
r: Lib.ByteSequence.lbytes ((2 * n1) * n2)
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 55,
"end_line": 112,
"start_col": 35,
"start_line": 110
} |
Prims.Tot | val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "Matrix"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_matrix0 a n1 n2 r i j res =
lemma_matrix_index_repeati1 n1 n2 i j;
res.(i, j) <- frodo_sample a (uint_from_bytes_le (LSeq.sub r (2 * (i * n2 + j)) 2)) | val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2
let frodo_sample_matrix0 a n1 n2 r i j res = | false | null | false | lemma_matrix_index_repeati1 n1 n2 i j;
res.(i, j) <- frodo_sample a (uint_from_bytes_le (LSeq.sub r (2 * (i * n2 + j)) 2)) | {
"checked_file": "Spec.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.ByteSequence.lbytes",
"Prims.op_LessThan",
"Spec.Matrix.matrix",
"Spec.Matrix.op_Array_Assignment",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Frodo.Sample.frodo_sample",
"Lib.ByteSequence.uint_from_bytes_le",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Prims.op_Addition",
"Prims.unit",
"Spec.Frodo.Lemmas.lemma_matrix_index_repeati1"
] | [] | module Spec.Frodo.Sample
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
open Spec.Frodo.Params
module LSeq = Lib.Sequence
module Matrix = Spec.Matrix
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val frodo_sample_f:
a:frodo_alg
-> t:uint16
-> i:size_nat{i < cdf_table_len a}
-> res:nat{res = 0 \/ res = 1}
let frodo_sample_f a t i =
if v t > v (cdf_table a).[i] then 1 else 0
val frodo_sample_fc:
a:frodo_alg
-> t:uint16
-> i:size_nat{i <= cdf_table_len a}
-> GTot (res:nat{0 <= res /\ res <= i})
(decreases i)
let rec frodo_sample_fc a t i =
if i = 0 then 0
else frodo_sample_f a t (i - 1) + frodo_sample_fc a t (i - 1)
val frodo_sample_res:
a:frodo_alg
-> sign:uint16{v sign <= 1}
-> e:nat{e < cdf_table_len a}
-> uint16
let frodo_sample_res a r0 e =
let open FStar.Math.Lib in
let e = (powx (-1) (v r0)) * e in
assert_norm (powx (-1) 1 == -1);
assert_norm (powx (-1) 0 == 1);
assert (-cdf_table_len a < e /\ e < cdf_table_len a);
u16 (e % modulus U16)
#push-options "--fuel 1"
val frodo_sample: a:frodo_alg -> r:uint16 -> uint16
let frodo_sample a r =
let t = r >>. 1ul in
let r0 = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v r0 == 0 \/ v r0 == 1);
let e =
Loops.repeati_inductive
(cdf_table_len a - 1)
(fun z e -> 0 <= e /\ e <= z /\ e == frodo_sample_fc a t z)
(fun z e -> frodo_sample_f a t z + e) 0 in
frodo_sample_res a r0 e
#pop-options
// frodo_sample_matrix can be replaced with `creati`
val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2 | false | false | Spec.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_sample_matrix0:
a:frodo_alg
-> n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> r:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> res:matrix n1 n2
-> matrix n1 n2 | [] | Spec.Frodo.Sample.frodo_sample_matrix0 | {
"file_name": "specs/frodo/Spec.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat{(2 * n1) * n2 <= Lib.IntTypes.max_size_t} ->
r: Lib.ByteSequence.lbytes ((2 * n1) * n2) ->
i: Lib.IntTypes.size_nat{i < n1} ->
j: Lib.IntTypes.size_nat{j < n2} ->
res: Spec.Matrix.matrix n1 n2
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 85,
"end_line": 87,
"start_col": 2,
"start_line": 86
} |
Prims.Tot | val flip (#a #b: Type) (c: (a * b)) : Tot (b * a) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca) | val flip (#a #b: Type) (c: (a * b)) : Tot (b * a)
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = | false | null | false | let ca, cb = c in
(cb, ca) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } ) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val flip (#a #b: Type) (c: (a * b)) : Tot (b * a) | [] | LowParse.Spec.Enum.flip | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | c: (a * b) -> b * a | {
"end_col": 80,
"end_line": 43,
"start_col": 51,
"start_line": 43
} |
Prims.GTot | val feq (u v: Type) (eq: (v -> v -> GTot Type0)) (f1 f2: (u -> Tot v)) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let feq
(u v: Type)
(eq: (v -> v -> GTot Type0))
(f1 f2: (u -> Tot v))
: GTot Type0
= (forall (x: u) . {:pattern (f1 x); (f2 x)} eq (f1 x) (f2 x)) | val feq (u v: Type) (eq: (v -> v -> GTot Type0)) (f1 f2: (u -> Tot v)) : GTot Type0
let feq (u v: Type) (eq: (v -> v -> GTot Type0)) (f1 f2: (u -> Tot v)) : GTot Type0 = | false | null | false | (forall (x: u). {:pattern (f1 x); (f2 x)} eq (f1 x) (f2 x)) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"sometrivial"
] | [
"Prims.l_Forall"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input
let parse_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_enum_key p e) input == (match parse p input with
| Some (x, consumed) ->
begin match maybe_enum_key_of_repr e x with
| Known k -> Some (k, consumed)
| _ -> None
end
| _ -> None
))
= parse_filter_eq p (parse_enum_key_cond e) input;
parse_synth_eq (p `parse_filter` parse_enum_key_cond e) (parse_enum_key_synth e) input
let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e)
: Tot (r: repr { maybe_enum_key_of_repr e r == x } )
= match x with
| Known k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| Unknown r -> r
let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e))
= serialize_synth p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) ()
let serialize_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: maybe_enum_key e)
: Lemma
(serialize (serialize_maybe_enum_key p s e) x == serialize s (repr_of_maybe_enum_key e x))
= serialize_synth_eq p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) () x
let is_total_enum (#key: eqtype) (#repr: eqtype) (l: list (key * repr)) : GTot Type0 =
forall (k: key) . {:pattern (list_mem k (list_map fst l))} list_mem k (list_map fst l)
let total_enum (key: eqtype) (repr: eqtype) : Tot eqtype =
(l: enum key repr { is_total_enum l } )
let synth_total_enum_key
(#key: eqtype)
(#repr: eqtype)
(l: total_enum key repr)
(k: enum_key l)
: Tot key
= let k' : key = k in
k'
let parse_total_enum_key
(#k: parser_kind)
(#key: eqtype)
(#repr: eqtype)
(p: parser k repr)
(l: total_enum key repr)
: Tot (parser (parse_filter_kind k) key)
= parse_enum_key p l `parse_synth` (synth_total_enum_key l)
let synth_total_enum_key_recip
(#key: eqtype)
(#repr: eqtype)
(l: total_enum key repr)
(k: key)
: Tot (k' : enum_key l { synth_total_enum_key l k' == k } )
= k
let serialize_total_enum_key
(#k: parser_kind)
(#key: eqtype)
(#repr: eqtype)
(p: parser k repr)
(s: serializer p)
(l: total_enum key repr)
: Tot (serializer (parse_total_enum_key p l))
= serialize_synth (parse_enum_key p l) (synth_total_enum_key l) (serialize_enum_key p s l) (synth_total_enum_key_recip l) ()
type maybe_total_enum_key (#key #repr: eqtype) (e: total_enum key repr) =
| TotalKnown of key
| TotalUnknown of (unknown_enum_repr e)
let maybe_total_enum_key_of_repr
(#key #repr: eqtype)
(e: total_enum key repr)
(r: repr)
: Tot (maybe_total_enum_key e)
= if list_mem r (list_map snd e)
then TotalKnown (enum_key_of_repr e r)
else TotalUnknown r
let parse_maybe_total_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: total_enum key repr)
: Tot (parser k (maybe_total_enum_key e))
= p `parse_synth` (maybe_total_enum_key_of_repr e)
let repr_of_maybe_total_enum_key
(#key #repr: eqtype)
(e: total_enum key repr)
(k: maybe_total_enum_key e)
: Tot (r: repr { maybe_total_enum_key_of_repr e r == k } )
= match k with
| TotalKnown k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| TotalUnknown r -> r
let serialize_maybe_total_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: total_enum key repr)
: Tot (serializer (parse_maybe_total_enum_key p e))
= serialize_synth p (maybe_total_enum_key_of_repr e) s (repr_of_maybe_total_enum_key e) ()
inline_for_extraction
let maybe_enum_key_of_total
(#key #repr: eqtype)
(e: total_enum key repr)
(k: maybe_total_enum_key e)
: Tot (maybe_enum_key e)
= match k with
| TotalKnown ek -> Known (ek <: key)
| TotalUnknown r -> Unknown r
inline_for_extraction
let total_of_maybe_enum_key
(#key #repr: eqtype)
(e: total_enum key repr)
(k: maybe_enum_key e)
: Tot (maybe_total_enum_key e)
= match k with
| Known ek -> TotalKnown (ek <: key)
| Unknown r -> TotalUnknown r
let maybe_total_enum_key_of_repr_eq
(#key #repr: eqtype)
(e: total_enum key repr)
(r: repr)
: Lemma
(maybe_total_enum_key_of_repr e r == total_of_maybe_enum_key e (maybe_enum_key_of_repr e r))
= ()
let parse_maybe_total_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: total_enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_total_enum_key p e) input == (parse (parse_maybe_enum_key p e `parse_synth` total_of_maybe_enum_key e) input))
= parse_synth_eq p (maybe_total_enum_key_of_repr e) input;
parse_synth_eq (parse_maybe_enum_key p e) (total_of_maybe_enum_key e) input;
parse_synth_eq p (maybe_enum_key_of_repr e) input
(* Destructors *)
(* Universal destructor *)
let r_reflexive_prop
(t: Type)
(r: (t -> t -> GTot Type0))
: GTot Type0
= forall (x: t) . {:pattern (r x x)} r x x
inline_for_extraction
let r_reflexive_t
(t: Type)
(r: (t -> t -> GTot Type0))
: Tot Type
= (x: t) -> Lemma (r x x)
let r_reflexive_t_elim
(t: Type)
(r: (t -> t -> GTot Type0))
(phi: r_reflexive_t t r)
: Lemma
(r_reflexive_prop t r)
= Classical.forall_intro phi
let r_transitive_prop
(t: Type)
(r: (t -> t -> GTot Type0))
: GTot Type0
= forall (x y z: t) . {:pattern (r x y); (r y z)} (r x y /\ r y z) ==> r x z
inline_for_extraction
let r_transitive_t
(t: Type)
(r: (t -> t -> GTot Type0))
: Tot Type
= (x: t) -> (y: t) -> (z: t) -> Lemma ((r x y /\ r y z) ==> r x z)
let r_transitive_t_elim
(t: Type)
(r: (t -> t -> GTot Type0))
(phi: r_transitive_t t r)
: Lemma
(r_transitive_prop t r)
= Classical.forall_intro_3 phi
inline_for_extraction
let if_combinator
(t: Type)
(eq: (t -> t -> GTot Type0))
: Tot Type
= (cond: bool) ->
(sv_true: (cond_true cond -> Tot t)) ->
(sv_false: (cond_false cond -> Tot t)) ->
Tot (y: t { eq y (if cond then sv_true () else sv_false ()) } )
inline_for_extraction
let default_if
(t: Type)
: Tot (if_combinator t (eq2 #t))
= fun
(cond: bool)
(s_true: (cond_true cond -> Tot t))
(s_false: (cond_false cond -> Tot t))
-> (if cond
then s_true ()
else s_false ()) <: (y: t { y == (if cond then s_true () else s_false ()) } )
let feq
(u v: Type)
(eq: (v -> v -> GTot Type0))
(f1 f2: (u -> Tot v)) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val feq (u v: Type) (eq: (v -> v -> GTot Type0)) (f1 f2: (u -> Tot v)) : GTot Type0 | [] | LowParse.Spec.Enum.feq | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
u267: Type ->
v: Type ->
eq: (_: v -> _: v -> Prims.GTot Type0) ->
f1: (_: u267 -> v) ->
f2: (_: u267 -> v)
-> Prims.GTot Type0 | {
"end_col": 62,
"end_line": 529,
"start_col": 2,
"start_line": 529
} |
Prims.Tot | val synth_total_enum_key (#key #repr: eqtype) (l: total_enum key repr) (k: enum_key l) : Tot key | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let synth_total_enum_key
(#key: eqtype)
(#repr: eqtype)
(l: total_enum key repr)
(k: enum_key l)
: Tot key
= let k' : key = k in
k' | val synth_total_enum_key (#key #repr: eqtype) (l: total_enum key repr) (k: enum_key l) : Tot key
let synth_total_enum_key (#key #repr: eqtype) (l: total_enum key repr) (k: enum_key l) : Tot key = | false | null | false | let k':key = k in
k' | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.total_enum",
"LowParse.Spec.Enum.enum_key"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input
let parse_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_enum_key p e) input == (match parse p input with
| Some (x, consumed) ->
begin match maybe_enum_key_of_repr e x with
| Known k -> Some (k, consumed)
| _ -> None
end
| _ -> None
))
= parse_filter_eq p (parse_enum_key_cond e) input;
parse_synth_eq (p `parse_filter` parse_enum_key_cond e) (parse_enum_key_synth e) input
let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e)
: Tot (r: repr { maybe_enum_key_of_repr e r == x } )
= match x with
| Known k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| Unknown r -> r
let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e))
= serialize_synth p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) ()
let serialize_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: maybe_enum_key e)
: Lemma
(serialize (serialize_maybe_enum_key p s e) x == serialize s (repr_of_maybe_enum_key e x))
= serialize_synth_eq p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) () x
let is_total_enum (#key: eqtype) (#repr: eqtype) (l: list (key * repr)) : GTot Type0 =
forall (k: key) . {:pattern (list_mem k (list_map fst l))} list_mem k (list_map fst l)
let total_enum (key: eqtype) (repr: eqtype) : Tot eqtype =
(l: enum key repr { is_total_enum l } )
let synth_total_enum_key
(#key: eqtype)
(#repr: eqtype)
(l: total_enum key repr)
(k: enum_key l) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val synth_total_enum_key (#key #repr: eqtype) (l: total_enum key repr) (k: enum_key l) : Tot key | [] | LowParse.Spec.Enum.synth_total_enum_key | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | l: LowParse.Spec.Enum.total_enum key repr -> k: LowParse.Spec.Enum.enum_key l -> key | {
"end_col": 4,
"end_line": 345,
"start_col": 1,
"start_line": 344
} |
Prims.GTot | val parse_enum_key_cond (#key #repr: eqtype) (e: enum key repr) (r: repr) : GTot bool | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e) | val parse_enum_key_cond (#key #repr: eqtype) (e: enum key repr) (r: repr) : GTot bool
let parse_enum_key_cond (#key #repr: eqtype) (e: enum key repr) (r: repr) : GTot bool = | false | null | false | list_mem r (list_map snd e) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"sometrivial"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Enum.list_mem",
"LowParse.Spec.Enum.list_map",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.snd",
"Prims.bool"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_enum_key_cond (#key #repr: eqtype) (e: enum key repr) (r: repr) : GTot bool | [] | LowParse.Spec.Enum.parse_enum_key_cond | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: LowParse.Spec.Enum.enum key repr -> r: repr -> Prims.GTot Prims.bool | {
"end_col": 29,
"end_line": 146,
"start_col": 2,
"start_line": 146
} |
Prims.Tot | val list_map (#a #b: Type) (f: (a -> Tot b)) (l: list a) : Tot (l': list b {l' == L.map f l}) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q | val list_map (#a #b: Type) (f: (a -> Tot b)) (l: list a) : Tot (l': list b {l' == L.map f l})
let rec list_map (#a #b: Type) (f: (a -> Tot b)) (l: list a) : Tot (l': list b {l' == L.map f l}) = | false | null | false | match l with
| [] -> []
| a :: q -> f a :: list_map f q | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"LowParse.Spec.Enum.list_map",
"Prims.eq2",
"FStar.List.Tot.Base.map"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val list_map (#a #b: Type) (f: (a -> Tot b)) (l: list a) : Tot (l': list b {l' == L.map f l}) | [
"recursion"
] | LowParse.Spec.Enum.list_map | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | f: (_: a -> b) -> l: Prims.list a -> l': Prims.list b {l' == FStar.List.Tot.Base.map f l} | {
"end_col": 33,
"end_line": 14,
"start_col": 2,
"start_line": 12
} |
Prims.Tot | val list_mem (#t: eqtype) (x: t) (l: list t) : Tot (y: bool{y == true <==> L.mem x l == true}) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q) | val list_mem (#t: eqtype) (x: t) (l: list t) : Tot (y: bool{y == true <==> L.mem x l == true})
let rec list_mem (#t: eqtype) (x: t) (l: list t) : Tot (y: bool{y == true <==> L.mem x l == true}) = | false | null | false | match l with
| [] -> false
| a :: q -> (x = a || list_mem x q) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"Prims.op_BarBar",
"Prims.op_Equality",
"LowParse.Spec.Enum.list_mem",
"Prims.bool",
"Prims.l_iff",
"Prims.eq2",
"FStar.List.Tot.Base.mem"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val list_mem (#t: eqtype) (x: t) (l: list t) : Tot (y: bool{y == true <==> L.mem x l == true}) | [
"recursion"
] | LowParse.Spec.Enum.list_mem | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: t -> l: Prims.list t -> y: Prims.bool{y == true <==> FStar.List.Tot.Base.mem x l == true} | {
"end_col": 37,
"end_line": 29,
"start_col": 2,
"start_line": 27
} |
Prims.GTot | val serialize_enum_key_synth_recip (#key #repr: eqtype) (e: enum key repr) (k: enum_key e)
: GTot (r: repr{parse_enum_key_cond e r == true}) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k | val serialize_enum_key_synth_recip (#key #repr: eqtype) (e: enum key repr) (k: enum_key e)
: GTot (r: repr{parse_enum_key_cond e r == true})
let serialize_enum_key_synth_recip (#key #repr: eqtype) (e: enum key repr) (k: enum_key e)
: GTot (r: repr{parse_enum_key_cond e r == true}) = | false | null | false | enum_repr_of_key e k | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"sometrivial"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Enum.enum_key",
"LowParse.Spec.Enum.enum_repr_of_key",
"Prims.eq2",
"Prims.bool",
"LowParse.Spec.Enum.parse_enum_key_cond"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize_enum_key_synth_recip (#key #repr: eqtype) (e: enum key repr) (k: enum_key e)
: GTot (r: repr{parse_enum_key_cond e r == true}) | [] | LowParse.Spec.Enum.serialize_enum_key_synth_recip | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: LowParse.Spec.Enum.enum key repr -> k: LowParse.Spec.Enum.enum_key e
-> Prims.GTot (r: repr{LowParse.Spec.Enum.parse_enum_key_cond e r == true}) | {
"end_col": 22,
"end_line": 203,
"start_col": 2,
"start_line": 203
} |
Prims.Tot | val repr_of_maybe_enum_key (#key #repr: eqtype) (e: enum key repr) (x: maybe_enum_key e)
: Tot (r: repr{maybe_enum_key_of_repr e r == x}) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e)
: Tot (r: repr { maybe_enum_key_of_repr e r == x } )
= match x with
| Known k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| Unknown r -> r | val repr_of_maybe_enum_key (#key #repr: eqtype) (e: enum key repr) (x: maybe_enum_key e)
: Tot (r: repr{maybe_enum_key_of_repr e r == x})
let repr_of_maybe_enum_key (#key #repr: eqtype) (e: enum key repr) (x: maybe_enum_key e)
: Tot (r: repr{maybe_enum_key_of_repr e r == x}) = | false | null | false | match x with
| Known k' ->
enum_key_of_repr_of_key e k';
enum_repr_of_key e k'
| Unknown r -> r | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Enum.maybe_enum_key",
"LowParse.Spec.Enum.enum_key",
"LowParse.Spec.Enum.enum_repr_of_key",
"Prims.unit",
"LowParse.Spec.Enum.enum_key_of_repr_of_key",
"LowParse.Spec.Enum.unknown_enum_repr",
"Prims.eq2",
"LowParse.Spec.Enum.maybe_enum_key_of_repr"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input
let parse_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_enum_key p e) input == (match parse p input with
| Some (x, consumed) ->
begin match maybe_enum_key_of_repr e x with
| Known k -> Some (k, consumed)
| _ -> None
end
| _ -> None
))
= parse_filter_eq p (parse_enum_key_cond e) input;
parse_synth_eq (p `parse_filter` parse_enum_key_cond e) (parse_enum_key_synth e) input
let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val repr_of_maybe_enum_key (#key #repr: eqtype) (e: enum key repr) (x: maybe_enum_key e)
: Tot (r: repr{maybe_enum_key_of_repr e r == x}) | [] | LowParse.Spec.Enum.repr_of_maybe_enum_key | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: LowParse.Spec.Enum.enum key repr -> x: LowParse.Spec.Enum.maybe_enum_key e
-> r: repr{LowParse.Spec.Enum.maybe_enum_key_of_repr e r == x} | {
"end_col": 18,
"end_line": 310,
"start_col": 2,
"start_line": 306
} |
Prims.Tot | val serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e))
= serialize_synth p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) () | val serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e))
let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e)) = | false | null | false | serialize_synth p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) () | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"Prims.eqtype",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.Enum.maybe_enum_key",
"LowParse.Spec.Enum.maybe_enum_key_of_repr",
"LowParse.Spec.Enum.repr_of_maybe_enum_key",
"LowParse.Spec.Enum.parse_maybe_enum_key"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input
let parse_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_enum_key p e) input == (match parse p input with
| Some (x, consumed) ->
begin match maybe_enum_key_of_repr e x with
| Known k -> Some (k, consumed)
| _ -> None
end
| _ -> None
))
= parse_filter_eq p (parse_enum_key_cond e) input;
parse_synth_eq (p `parse_filter` parse_enum_key_cond e) (parse_enum_key_synth e) input
let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e)
: Tot (r: repr { maybe_enum_key_of_repr e r == x } )
= match x with
| Known k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| Unknown r -> r
let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e)) | [] | LowParse.Spec.Enum.serialize_maybe_enum_key | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k repr ->
s: LowParse.Spec.Base.serializer p ->
e: LowParse.Spec.Enum.enum key repr
-> LowParse.Spec.Base.serializer (LowParse.Spec.Enum.parse_maybe_enum_key p e) | {
"end_col": 78,
"end_line": 319,
"start_col": 2,
"start_line": 319
} |
FStar.Pervasives.Lemma | val assoc_flip_intro (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\ L.assoc x l == Some y))
(ensures (L.assoc y (list_map flip l) == Some x)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y | val assoc_flip_intro (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\ L.assoc x l == Some y))
(ensures (L.assoc y (list_map flip l) == Some x))
let rec assoc_flip_intro (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\ L.assoc x l == Some y))
(ensures (L.assoc y (list_map flip l) == Some x)) = | false | null | true | map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"lemma"
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Enum.assoc_flip_elim",
"LowParse.Spec.Enum.list_map",
"LowParse.Spec.Enum.flip",
"Prims.unit",
"LowParse.Spec.Enum.map_flip_flip",
"LowParse.Spec.Enum.map_snd_flip",
"LowParse.Spec.Enum.map_fst_flip",
"Prims.l_and",
"Prims.b2t",
"FStar.List.Tot.Base.noRepeats",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.List.Tot.Base.assoc",
"FStar.Pervasives.Native.Some",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val assoc_flip_intro (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\ L.assoc x l == Some y))
(ensures (L.assoc y (list_map flip l) == Some x)) | [
"recursion"
] | LowParse.Spec.Enum.assoc_flip_intro | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | l: Prims.list (a * b) -> y: b -> x: a
-> FStar.Pervasives.Lemma
(requires
FStar.List.Tot.Base.noRepeats (LowParse.Spec.Enum.list_map FStar.Pervasives.Native.fst l) /\
FStar.List.Tot.Base.noRepeats (LowParse.Spec.Enum.list_map FStar.Pervasives.Native.snd l) /\
FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y)
(ensures
FStar.List.Tot.Base.assoc y (LowParse.Spec.Enum.list_map LowParse.Spec.Enum.flip l) ==
FStar.Pervasives.Native.Some x) | {
"end_col": 39,
"end_line": 124,
"start_col": 2,
"start_line": 121
} |
Prims.Pure | val make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key)
: Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k | val make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key)
: Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key)
: Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key))) = | false | null | false | k | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Enum.enum_key",
"Prims.b2t",
"LowParse.Spec.Enum.list_mem",
"LowParse.Spec.Enum.list_map",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.fst",
"Prims.eq2"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e))) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key)
: Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key))) | [] | LowParse.Spec.Enum.make_enum_key | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: LowParse.Spec.Enum.enum key repr -> k: key -> Prims.Pure (LowParse.Spec.Enum.enum_key e) | {
"end_col": 3,
"end_line": 38,
"start_col": 2,
"start_line": 38
} |
FStar.Pervasives.Lemma | val serialize_enum_key_synth_inverse (#key #repr: eqtype) (e: enum key repr)
: Lemma (synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e) | val serialize_enum_key_synth_inverse (#key #repr: eqtype) (e: enum key repr)
: Lemma (synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
let serialize_enum_key_synth_inverse (#key #repr: eqtype) (e: enum key repr)
: Lemma (synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e)) = | false | null | true | Classical.forall_intro (enum_key_of_repr_of_key e) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"lemma"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"FStar.Classical.forall_intro",
"LowParse.Spec.Enum.enum_key",
"Prims.eq2",
"LowParse.Spec.Enum.enum_key_of_repr",
"LowParse.Spec.Enum.enum_repr_of_key",
"LowParse.Spec.Enum.enum_key_of_repr_of_key",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Combinators.synth_inverse",
"Prims.bool",
"LowParse.Spec.Enum.parse_enum_key_cond",
"LowParse.Spec.Enum.parse_enum_key_synth",
"LowParse.Spec.Enum.serialize_enum_key_synth_recip",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize_enum_key_synth_inverse (#key #repr: eqtype) (e: enum key repr)
: Lemma (synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e)) | [] | LowParse.Spec.Enum.serialize_enum_key_synth_inverse | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | e: LowParse.Spec.Enum.enum key repr
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Combinators.synth_inverse (LowParse.Spec.Enum.parse_enum_key_synth e)
(LowParse.Spec.Enum.serialize_enum_key_synth_recip e)) | {
"end_col": 52,
"end_line": 210,
"start_col": 2,
"start_line": 210
} |
FStar.Pervasives.Lemma | val assoc_mem_snd (#a #b: eqtype) (l: list (a * b)) (x: a) (y: b)
: Lemma (requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y | val assoc_mem_snd (#a #b: eqtype) (l: list (a * b)) (x: a) (y: b)
: Lemma (requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
let rec assoc_mem_snd (#a #b: eqtype) (l: list (a * b)) (x: a) (y: b)
: Lemma (requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l) = | false | null | true | let (x', y') :: l' = l in
if x' = x then () else assoc_mem_snd l' x y | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"lemma",
""
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Equality",
"Prims.bool",
"LowParse.Spec.Enum.assoc_mem_snd",
"Prims.unit",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.List.Tot.Base.assoc",
"FStar.Pervasives.Native.Some",
"Prims.squash",
"LowParse.Spec.Enum.list_mem",
"LowParse.Spec.Enum.list_map",
"FStar.Pervasives.Native.snd",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true)) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val assoc_mem_snd (#a #b: eqtype) (l: list (a * b)) (x: a) (y: b)
: Lemma (requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l) | [
"recursion"
] | LowParse.Spec.Enum.assoc_mem_snd | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | l: Prims.list (a * b) -> x: a -> y: b
-> FStar.Pervasives.Lemma
(requires FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y)
(ensures
LowParse.Spec.Enum.list_mem y (LowParse.Spec.Enum.list_map FStar.Pervasives.Native.snd l) ==
true)
(decreases l) | {
"end_col": 27,
"end_line": 75,
"start_col": 1,
"start_line": 72
} |
FStar.Pervasives.Lemma | val assoc_flip_elim (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x)) (ensures (L.assoc x l == Some y)) (decreases l) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end | val assoc_flip_elim (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x)) (ensures (L.assoc x l == Some y)) (decreases l)
let rec assoc_flip_elim (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x)) (ensures (L.assoc x l == Some y)) (decreases l) = | false | null | true | let (x', y') :: l' = l in
if y' = y
then ()
else
if x' = x
then
(assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False)
else assoc_flip_elim l' y x | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"lemma",
""
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Equality",
"Prims.bool",
"Prims._assert",
"Prims.l_False",
"Prims.unit",
"LowParse.Spec.Enum.map_snd_flip",
"LowParse.Spec.Enum.assoc_mem_snd",
"LowParse.Spec.Enum.list_map",
"LowParse.Spec.Enum.flip",
"Prims.eq2",
"LowParse.Spec.Enum.list_mem",
"FStar.Pervasives.Native.fst",
"LowParse.Spec.Enum.assoc_flip_elim",
"Prims.l_and",
"Prims.b2t",
"FStar.List.Tot.Base.noRepeats",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.option",
"FStar.List.Tot.Base.assoc",
"FStar.Pervasives.Native.Some",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
)) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val assoc_flip_elim (#a #b: eqtype) (l: list (a * b)) (y: b) (x: a)
: Lemma
(requires
(L.noRepeats (list_map fst l) /\ L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x)) (ensures (L.assoc x l == Some y)) (decreases l) | [
"recursion"
] | LowParse.Spec.Enum.assoc_flip_elim | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | l: Prims.list (a * b) -> y: b -> x: a
-> FStar.Pervasives.Lemma
(requires
FStar.List.Tot.Base.noRepeats (LowParse.Spec.Enum.list_map FStar.Pervasives.Native.fst l) /\
FStar.List.Tot.Base.noRepeats (LowParse.Spec.Enum.list_map FStar.Pervasives.Native.snd l) /\
FStar.List.Tot.Base.assoc y (LowParse.Spec.Enum.list_map LowParse.Spec.Enum.flip l) ==
FStar.Pervasives.Native.Some x)
(ensures FStar.List.Tot.Base.assoc x l == FStar.Pervasives.Native.Some y)
(decreases l) | {
"end_col": 5,
"end_line": 105,
"start_col": 1,
"start_line": 92
} |
FStar.Pervasives.Lemma | val parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input ==
(match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input | val parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input ==
(match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None))
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input ==
(match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None)) = | false | null | true | parse_synth_eq p (maybe_enum_key_of_repr e) input | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"Prims.eqtype",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Enum.enum",
"LowParse.Bytes.bytes",
"LowParse.Spec.Combinators.parse_synth_eq",
"LowParse.Spec.Enum.maybe_enum_key",
"LowParse.Spec.Enum.maybe_enum_key_of_repr",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Enum.parse_maybe_enum_key",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.None",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input ==
(match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None)) | [] | LowParse.Spec.Enum.parse_maybe_enum_key_eq | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k repr ->
e: LowParse.Spec.Enum.enum key repr ->
input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.parse (LowParse.Spec.Enum.parse_maybe_enum_key p e) input ==
(match LowParse.Spec.Base.parse p input with
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ x consumed) ->
FStar.Pervasives.Native.Some (LowParse.Spec.Enum.maybe_enum_key_of_repr e x, consumed)
| _ -> FStar.Pervasives.Native.None)) | {
"end_col": 51,
"end_line": 281,
"start_col": 2,
"start_line": 281
} |
Prims.Tot | val parse_enum_key (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e | val parse_enum_key (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
let parse_enum_key (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e)) = | false | null | false | (p `parse_filter` (parse_enum_key_cond e)) `parse_synth` (parse_enum_key_synth e) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"Prims.eqtype",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.Enum.parse_enum_key_cond",
"LowParse.Spec.Enum.enum_key",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.Enum.parse_enum_key_synth"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr) | false | false | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_enum_key (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e)) | [] | LowParse.Spec.Enum.parse_enum_key | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: LowParse.Spec.Base.parser k repr -> e: LowParse.Spec.Enum.enum key repr
-> LowParse.Spec.Base.parser (LowParse.Spec.Combinators.parse_filter_kind k)
(LowParse.Spec.Enum.enum_key e) | {
"end_col": 24,
"end_line": 166,
"start_col": 2,
"start_line": 161
} |
Prims.Tot | val total_enum (key repr: eqtype) : Tot eqtype | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let total_enum (key: eqtype) (repr: eqtype) : Tot eqtype =
(l: enum key repr { is_total_enum l } ) | val total_enum (key repr: eqtype) : Tot eqtype
let total_enum (key repr: eqtype) : Tot eqtype = | false | null | false | (l: enum key repr {is_total_enum l}) | {
"checked_file": "LowParse.Spec.Enum.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Enum.fst"
} | [
"total"
] | [
"Prims.eqtype",
"LowParse.Spec.Enum.enum",
"LowParse.Spec.Enum.is_total_enum"
] | [] | module LowParse.Spec.Enum
include LowParse.Spec.Combinators
module L = FStar.List.Tot
[@Norm]
let rec list_map
(#a #b: Type)
(f: (a -> Tot b))
(l: list a)
: Tot (l' : list b { l' == L.map f l } )
= match l with
| [] -> []
| a :: q -> f a :: list_map f q
type enum (key: eqtype) (repr: eqtype) = (l: list (key * repr) {
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l)
})
[@Norm]
let rec list_mem
(#t: eqtype)
(x: t)
(l: list t)
: Tot (y: bool { y == true <==> L.mem x l == true } )
= match l with
| [] -> false
| a :: q -> (x = a || list_mem x q)
inline_for_extraction
let enum_key (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (s: key { list_mem s (list_map fst e) } )
inline_for_extraction
let make_enum_key (#key #repr: eqtype) (e: enum key repr) (k: key) : Pure (enum_key e)
(requires (list_mem k (list_map fst e)))
(ensures (fun k' -> k == (k' <: key)))
= k
inline_for_extraction
let enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot eqtype = (r: repr { list_mem r (list_map snd e) } )
let flip (#a #b: Type) (c: (a * b)) : Tot (b * a) = let (ca, cb) = c in (cb, ca)
let rec map_flip_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map flip (list_map flip l) == l)
= match l with
| [] -> ()
| _ :: q -> map_flip_flip q
let rec map_fst_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map fst (list_map flip l) == list_map snd l)
= match l with
| [] -> ()
| _ :: q -> map_fst_flip q
let rec map_snd_flip (#a #b: Type) (l: list (a * b)) : Lemma
(list_map snd (list_map flip l) == list_map fst l)
= match l with
| [] -> ()
| _ :: q -> map_snd_flip q
let rec assoc_mem_snd
(#a #b: eqtype)
(l: list (a * b))
(x: a)
(y: b)
: Lemma
(requires (L.assoc x l == Some y))
(ensures (list_mem y (list_map snd l) == true))
(decreases l)
= let ((x', y') :: l') = l in
if x' = x
then ()
else assoc_mem_snd l' x y
let rec assoc_flip_elim
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc y (list_map flip l) == Some x
))
(ensures (
L.assoc x l == Some y
))
(decreases l)
= let ((x', y') :: l') = l in
if y' = y
then ()
else begin
if x' = x
then begin
assert (list_mem x' (list_map fst l') == false);
assoc_mem_snd (list_map flip l') y x;
map_snd_flip l';
assert False
end
else
assoc_flip_elim l' y x
end
let rec assoc_flip_intro
(#a #b: eqtype)
(l: list (a * b))
(y: b)
(x: a)
: Lemma
(requires (
L.noRepeats (list_map fst l) /\
L.noRepeats (list_map snd l) /\
L.assoc x l == Some y
))
(ensures (
L.assoc y (list_map flip l) == Some x
))
= map_fst_flip l;
map_snd_flip l;
map_flip_flip l;
assoc_flip_elim (list_map flip l) x y
let enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Pure (enum_key e)
(requires True)
(ensures (fun y -> L.assoc y e == Some r))
= map_fst_flip e;
let e' = list_map #(key * repr) #(repr * key) flip e in
L.assoc_mem r e';
let k = Some?.v (L.assoc r e') in
assoc_flip_elim e r k;
L.assoc_mem k e;
(k <: enum_key e)
let parse_enum_key_cond
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: GTot bool
= list_mem r (list_map snd e)
let parse_enum_key_synth
(#key #repr: eqtype)
(e: enum key repr)
(r: repr { parse_enum_key_cond e r == true } )
: GTot (enum_key e)
= enum_key_of_repr e r
let parse_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser (parse_filter_kind k) (enum_key e))
= (p
`parse_filter`
parse_enum_key_cond e
)
`parse_synth`
parse_enum_key_synth e
let enum_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Pure (enum_repr e)
(requires True)
(ensures (fun r -> L.assoc k e == Some r))
= L.assoc_mem k e;
let r = Some?.v (L.assoc k e) in
assoc_flip_intro e r k;
L.assoc_mem r (list_map flip e);
map_fst_flip e;
(r <: enum_repr e)
let enum_repr_of_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: enum_repr e)
: Lemma
(enum_repr_of_key e (enum_key_of_repr e r) == r)
= ()
let enum_key_of_repr_of_key
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: Lemma
(enum_key_of_repr e (enum_repr_of_key e k) == k)
= assoc_flip_intro e (enum_repr_of_key e k) k
let serialize_enum_key_synth_recip
(#key #repr: eqtype)
(e: enum key repr)
(k: enum_key e)
: GTot (r: repr { parse_enum_key_cond e r == true } )
= enum_repr_of_key e k
let serialize_enum_key_synth_inverse
(#key #repr: eqtype)
(e: enum key repr)
: Lemma
(synth_inverse (parse_enum_key_synth e) (serialize_enum_key_synth_recip e))
= Classical.forall_intro (enum_key_of_repr_of_key e)
let serialize_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_enum_key p e))
= serialize_enum_key_synth_inverse e;
serialize_synth
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
let serialize_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: enum_key e)
: Lemma
(serialize (serialize_enum_key p s e) x == serialize s (enum_repr_of_key e x))
= serialize_enum_key_synth_inverse e;
serialize_synth_eq
(parse_filter p (parse_enum_key_cond e))
(parse_enum_key_synth e)
(serialize_filter s (parse_enum_key_cond e))
(serialize_enum_key_synth_recip e)
()
x
inline_for_extraction
let unknown_enum_repr (#key #repr: eqtype) (e: enum key repr) : Tot Type =
(r: repr { list_mem r (list_map snd e) == false } )
type maybe_enum_key (#key #repr: eqtype) (e: enum key repr) =
| Known of (enum_key e)
| Unknown of (unknown_enum_repr e)
let maybe_enum_key_of_repr
(#key #repr: eqtype)
(e: enum key repr)
(r: repr)
: Tot (maybe_enum_key e)
= if list_mem r (list_map snd e)
then Known (enum_key_of_repr e r)
else Unknown r
let parse_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
: Tot (parser k (maybe_enum_key e))
= p `parse_synth` (maybe_enum_key_of_repr e)
let parse_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_maybe_enum_key p e) input == (match parse p input with
| Some (x, consumed) -> Some (maybe_enum_key_of_repr e x, consumed)
| _ -> None
))
= parse_synth_eq p (maybe_enum_key_of_repr e) input
let parse_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(e: enum key repr)
(input: bytes)
: Lemma
(parse (parse_enum_key p e) input == (match parse p input with
| Some (x, consumed) ->
begin match maybe_enum_key_of_repr e x with
| Known k -> Some (k, consumed)
| _ -> None
end
| _ -> None
))
= parse_filter_eq p (parse_enum_key_cond e) input;
parse_synth_eq (p `parse_filter` parse_enum_key_cond e) (parse_enum_key_synth e) input
let repr_of_maybe_enum_key
(#key #repr: eqtype)
(e: enum key repr)
(x: maybe_enum_key e)
: Tot (r: repr { maybe_enum_key_of_repr e r == x } )
= match x with
| Known k' ->
enum_key_of_repr_of_key e k' ;
enum_repr_of_key e k'
| Unknown r -> r
let serialize_maybe_enum_key
(#k: parser_kind)
(#key #repr: eqtype)
(p: parser k repr)
(s: serializer p)
(e: enum key repr)
: Tot (serializer (parse_maybe_enum_key p e))
= serialize_synth p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) ()
let serialize_maybe_enum_key_eq
(#k: parser_kind)
(#key #repr: eqtype)
(#p: parser k repr)
(s: serializer p)
(e: enum key repr)
(x: maybe_enum_key e)
: Lemma
(serialize (serialize_maybe_enum_key p s e) x == serialize s (repr_of_maybe_enum_key e x))
= serialize_synth_eq p (maybe_enum_key_of_repr e) s (repr_of_maybe_enum_key e) () x
let is_total_enum (#key: eqtype) (#repr: eqtype) (l: list (key * repr)) : GTot Type0 =
forall (k: key) . {:pattern (list_mem k (list_map fst l))} list_mem k (list_map fst l) | false | true | LowParse.Spec.Enum.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val total_enum (key repr: eqtype) : Tot eqtype | [] | LowParse.Spec.Enum.total_enum | {
"file_name": "src/lowparse/LowParse.Spec.Enum.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | key: Prims.eqtype -> repr: Prims.eqtype -> Prims.eqtype | {
"end_col": 41,
"end_line": 336,
"start_col": 2,
"start_line": 336
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.