file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_app
val mk_app (t: term) (args: list argv) : Tot term (decreases args)
val mk_app (t: term) (args: list argv) : Tot term (decreases args)
let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 75, "start_col": 0, "start_line": 72 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' []
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> args: Prims.list FStar.Stubs.Reflection.V1.Data.argv -> Prims.Tot FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total", "" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Reflection.V1.Derived.mk_app", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_App" ]
[ "recursion" ]
false
false
false
true
false
let rec mk_app (t: term) (args: list argv) : Tot term (decreases args) =
match args with | [] -> t | x :: xs -> mk_app (pack_ln (Tv_App t x)) xs
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.un_uinst
val un_uinst (t: term) : term
val un_uinst (t: term) : term
let un_uinst (t:term) : term = match inspect_ln t with | Tv_UInst fv _ -> pack_ln (Tv_FVar fv) | _ -> t
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 230, "start_col": 0, "start_line": 227 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q} (** Set a vconfig for a sigelt *) val add_check_with : vconfig -> sigelt -> Tot sigelt let add_check_with vcfg se = let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V1.Data.universes", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Data.term_view" ]
[]
false
false
false
true
false
let un_uinst (t: term) : term =
match inspect_ln t with | Tv_UInst fv _ -> pack_ln (Tv_FVar fv) | _ -> t
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_tot_arr_ln
val mk_tot_arr_ln (bs: list binder) (cod: term) : Tot term (decreases bs)
val mk_tot_arr_ln (bs: list binder) (cod: term) : Tot term (decreases bs)
let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod))))
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 87, "start_col": 0, "start_line": 84 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
bs: Prims.list FStar.Stubs.Reflection.Types.binder -> cod: FStar.Stubs.Reflection.Types.term -> Prims.Tot FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_Arrow", "FStar.Stubs.Reflection.V1.Builtins.pack_comp", "FStar.Stubs.Reflection.V1.Data.C_Total", "FStar.Reflection.V1.Derived.mk_tot_arr_ln" ]
[ "recursion" ]
false
false
false
true
false
let rec mk_tot_arr_ln (bs: list binder) (cod: term) : Tot term (decreases bs) =
match bs with | [] -> cod | b :: bs -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod))))
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.unsquash_term
val unsquash_term (t: term) : option term
val unsquash_term (t: term) : option term
let unsquash_term (t : term) : option term = match inspect_ln_unascribe t with | Tv_App l (r, Q_Explicit) -> if is_name_imp squash_qn l then Some r else None | _ -> None
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 255, "start_col": 0, "start_line": 249 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q} (** Set a vconfig for a sigelt *) val add_check_with : vconfig -> sigelt -> Tot sigelt let add_check_with vcfg se = let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se let un_uinst (t:term) : term = match inspect_ln t with | Tv_UInst fv _ -> pack_ln (Tv_FVar fv) | _ -> t (* Returns [true] iff the term [t] is just the name [nm], though possibly universe-instantiated and applied to some implicit arguments. *) let rec is_name_imp (nm : name) (t : term) : bool = begin match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> if inspect_fv fv = nm then true else false | Tv_App l (_, Q_Implicit) -> is_name_imp nm l | _ -> false end (* If t is of the shape [squash t'], return [Some t'],
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Reflection.V1.Derived.is_name_imp", "FStar.Reflection.Const.squash_qn", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V1.Data.term_view" ]
[]
false
false
false
true
false
let unsquash_term (t: term) : option term =
match inspect_ln_unascribe t with | Tv_App l (r, Q_Explicit) -> if is_name_imp squash_qn l then Some r else None | _ -> None
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_app_ln'
val collect_app_ln' (args: list argv) (t: term) : Tot (term * list argv) (decreases t)
val collect_app_ln' (args: list argv) (t: term) : Tot (term * list argv) (decreases t)
let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 67, "start_col": 0, "start_line": 63 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
args: Prims.list FStar.Stubs.Reflection.V1.Data.argv -> t: FStar.Stubs.Reflection.Types.term -> Prims.Tot (FStar.Stubs.Reflection.Types.term * Prims.list FStar.Stubs.Reflection.V1.Data.argv)
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Reflection.V1.Derived.collect_app_ln'", "Prims.Cons", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2" ]
[ "recursion" ]
false
false
false
true
false
let rec collect_app_ln' (args: list argv) (t: term) : Tot (term * list argv) (decreases t) =
match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r :: args) l | _ -> (t, args)
false
CoreCrypto.fst
CoreCrypto.has_priv
val has_priv: key -> Type0
val has_priv: key -> Type0
let has_priv : key -> Type0 = function | KeyRSA k -> Some? k.rsa_prv_exp | KeyDSA k -> Some? k.dsa_private | KeyECDSA k -> Some? k.ec_priv
{ "file_name": "ucontrib/CoreCrypto/fst/CoreCrypto.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 240, "start_col": 0, "start_line": 237 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module CoreCrypto open Platform.Bytes (* ------------ Hashing ------------ *) type hash_alg = | MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 let hashSize = function | MD5 -> 16 | SHA1 -> 20 | SHA224 -> 28 | SHA256 -> 32 | SHA384 -> 48 | SHA512 -> 64 (* These implementations are not pure; to be upgraded! *) assume val hash : alg:hash_alg -> bytes -> Tot (h:bytes{length h = hashSize alg}) assume val hmac : alg:hash_alg -> bytes -> bytes -> Tot (h:bytes{length h = hashSize alg}) (* Digest functions *) assume type hash_ctx : Type0 (* SI: or assume_new_abstract_type?*) assume val digest_create : hash_alg -> EXT hash_ctx assume val digest_update : hash_ctx -> bytes -> EXT unit assume val digest_final : hash_ctx -> EXT bytes (* --------------------------- *) type sig_alg = | RSASIG | DSA | ECDSA | RSAPSS type block_cipher = | AES_128_CBC | AES_256_CBC | TDES_EDE_CBC type stream_cipher = | RC4_128 type rsa_padding = | Pad_none | Pad_PKCS1 (* NB these constant functions must *exactly* match those in the trusted CoreCrypto.ml. We should compile them instead! *) let blockSize = function | TDES_EDE_CBC -> 8 | AES_128_CBC -> 16 | AES_256_CBC -> 16 (* Authenticated Encryption for TLS. Note that their AAD contents depends on the protocol version. *) type aead_cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 | AES_128_CCM // "Counter with CBC-Message Authentication Code" | AES_256_CCM | AES_128_CCM_8 // variant with truncated 8-byte tags | AES_256_CCM_8 // the key materials consist of an encryption key, a static IV, and an authentication key. let aeadKeySize = function | AES_128_CCM -> 16 | AES_128_CCM_8 -> 16 | AES_128_GCM -> 16 | AES_256_CCM -> 32 | AES_256_CCM_8 -> 32 | AES_256_GCM -> 32 | CHACHA20_POLY1305 -> 32 let aeadRealIVSize (a:aead_cipher) = 12 // the ciphertext ends with an authentication tag let aeadTagSize = function | AES_128_CCM_8 -> 8 | AES_256_CCM_8 -> 8 | AES_128_CCM -> 16 | AES_256_CCM -> 16 | AES_128_GCM -> 16 | AES_256_GCM -> 16 | CHACHA20_POLY1305 -> 16 //16-09-12 added precise concrete spec, matching what we implement in low-level/crypto //16-09-12 for robustness, we should at least test it when using external crypto. assume val aead_encryptT: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> plain:bytes -> GTot (lbytes (length plain + aeadTagSize a)) assume val aead_encrypt: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> plain:bytes -> EXT (c:bytes {c = aead_encryptT a k iv ad plain}) assume val aead_decrypt: a: aead_cipher -> k: lbytes (aeadKeySize a) -> iv:lbytes (aeadRealIVSize a) -> ad:bytes -> cipher:bytes{length cipher >= aeadTagSize a} -> EXT (o:option (b:bytes{length b + aeadTagSize a = length cipher}) {forall (p:bytes). cipher = aead_encryptT a k iv ad p <==> (Some? o /\ Some?.v o == p) }) type rsa_key = { rsa_mod : bytes; rsa_pub_exp : bytes; rsa_prv_exp : option bytes; } type dsa_params = { dsa_p : bytes; dsa_q : bytes; dsa_g : bytes; } type dsa_key = { dsa_params : dsa_params; dsa_public : bytes; dsa_private : option bytes; } type dh_params = { dh_p : bytes; dh_g : bytes; dh_q : option bytes; safe_prime : bool; } type dh_key = { dh_params : dh_params; dh_public : bytes; dh_private : option bytes; } (* TODO: revisit the Tot annotations, switch to EXT when appropriate *) assume val block_encrypt : block_cipher -> bytes -> bytes -> bytes -> EXT bytes assume val block_decrypt : block_cipher -> bytes -> bytes -> bytes -> EXT bytes assume new type cipher_stream : Type0 assume val stream_encryptor : stream_cipher -> bytes -> EXT cipher_stream assume val stream_decryptor : stream_cipher -> bytes -> EXT cipher_stream assume val stream_process : cipher_stream -> bytes -> EXT bytes assume val stream_fini : cipher_stream -> EXT unit assume val random : l:nat -> EXT (lbytes l) assume val rsa_gen_key : int -> EXT (k:rsa_key{Some? k.rsa_prv_exp}) assume val rsa_encrypt : rsa_key -> rsa_padding -> bytes -> EXT bytes assume val rsa_decrypt : k:rsa_key{Some? k.rsa_prv_exp} -> rsa_padding -> bytes -> EXT (option bytes) assume val rsa_sign : option hash_alg -> k:rsa_key{Some? k.rsa_prv_exp} -> pss:bool -> bytes -> EXT bytes assume val rsa_verify : option hash_alg -> rsa_key -> pss:bool -> bytes -> bytes -> EXT bool assume val dsa_gen_key : int -> EXT (k:dsa_key{Some? k.dsa_private}) assume val dsa_sign : option hash_alg -> k:dsa_key{Some? k.dsa_private} -> bytes -> EXT bytes assume val dsa_verify : option hash_alg -> dsa_key -> bytes -> bytes -> Tot bool assume val dh_gen_params : int -> EXT dh_params assume val dh_gen_key : p:dh_params -> EXT (k:dh_key{Some? k.dh_private /\ k.dh_params = p /\ length k.dh_public <= length p.dh_p}) assume val dh_agreement : k:dh_key{Some? k.dh_private} -> bytes -> EXT bytes (* type ec_prime = { ecp_prime : string; ecp_order : string; ecp_a : string; ecp_b : string; ecp_gx : string; ecp_gy : string; ecp_bytelen : int; ecp_id : bytes; } *) type ec_curve = | ECC_P256 | ECC_P384 | ECC_P521 | ECC_X25519 | ECC_X448 (* Bytelen of field elements *) val ec_bytelen: ec_curve -> Tot (n:nat{n <= 127}) let ec_bytelen = function | ECC_P256 -> 32 | ECC_P384 -> 48 | ECC_P521 -> 66 (* ceil(521/8) *) | ECC_X25519 -> 32 | ECC_X448 -> 56 type ec_params = { curve: ec_curve; point_compression: bool; } type ec_point = { ecx : bytes; ecy : bytes; } type ec_key = { ec_params : ec_params; ec_point : ec_point; ec_priv : option bytes; } assume val ec_is_on_curve: ec_params -> ec_point -> Tot bool assume val ecdh_agreement: k:ec_key{Some? k.ec_priv} -> ec_point -> EXT bytes assume val ecdsa_sign: option hash_alg -> k:ec_key{Some? k.ec_priv} -> bytes -> EXT bytes assume val ecdsa_verify: option hash_alg -> ec_key -> bytes -> bytes -> EXT bool assume val ec_gen_key: p:ec_params -> EXT (k:ec_key{Some? k.ec_priv /\ k.ec_params = p /\ length k.ec_point.ecx = ec_bytelen k.ec_params.curve /\ length k.ec_point.ecy = ec_bytelen k.ec_params.curve}) //TODO: keep also abtsract OpenSSL representation for efficiency? type key = | KeyRSA of rsa_key | KeyDSA of dsa_key | KeyECDSA of ec_key // If we are careless we can cause openssl segfaults when signing or encrypting // with keys that are missing the "private" field.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "CoreCrypto.fst" }
[ { "abbrev": false, "full_module": "Platform.Bytes", "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 } ]
{ "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" }
false
_: CoreCrypto.key -> Type0
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.key", "CoreCrypto.rsa_key", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Platform.Bytes.bytes", "CoreCrypto.__proj__Mkrsa_key__item__rsa_prv_exp", "CoreCrypto.dsa_key", "CoreCrypto.__proj__Mkdsa_key__item__dsa_private", "CoreCrypto.ec_key", "CoreCrypto.__proj__Mkec_key__item__ec_priv" ]
[]
false
false
false
true
true
let has_priv: key -> Type0 =
function | KeyRSA k -> Some? k.rsa_prv_exp | KeyDSA k -> Some? k.dsa_private | KeyECDSA k -> Some? k.ec_priv
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_abs'
val collect_abs' (bs: list binder) (t: term) : Tot (list binder * term) (decreases t)
val collect_abs' (bs: list binder) (t: term) : Tot (list binder * term) (decreases t)
let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 115, "start_col": 0, "start_line": 111 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
bs: Prims.list FStar.Stubs.Reflection.Types.binder -> t: FStar.Stubs.Reflection.Types.term -> Prims.Tot (Prims.list FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.term)
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Reflection.V1.Derived.collect_abs'", "Prims.Cons", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2" ]
[ "recursion" ]
false
false
false
true
false
let rec collect_abs' (bs: list binder) (t: term) : Tot (list binder * term) (decreases t) =
match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b :: bs) t' | _ -> (bs, t)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mk_list
val mk_list (ts: list term) : term
val mk_list (ts: list term) : term
let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts)
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 139, "start_col": 0, "start_line": 136 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
ts: Prims.list FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Builtins.pack_fv", "FStar.Reflection.Const.nil_qn", "FStar.Reflection.V1.Derived.mk_cons", "FStar.Reflection.V1.Derived.mk_list" ]
[ "recursion" ]
false
false
false
true
false
let rec mk_list (ts: list term) : term =
match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t :: ts -> mk_cons t (mk_list ts)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.collect_arr'
val collect_arr' (bs: list binder) (c: comp) : Tot (list binder * comp) (decreases c)
val collect_arr' (bs: list binder) (c: comp) : Tot (list binder * comp) (decreases c)
let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 99, "start_col": 0, "start_line": 89 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
bs: Prims.list FStar.Stubs.Reflection.Types.binder -> c: FStar.Stubs.Reflection.Types.comp -> Prims.Tot (Prims.list FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.comp)
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V1.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Reflection.V1.Derived.collect_arr'", "Prims.Cons", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V1.Data.comp_view" ]
[ "recursion" ]
false
false
false
true
false
let rec collect_arr' (bs: list binder) (c: comp) : Tot (list binder * comp) (decreases c) =
match inspect_comp c with | C_Total t -> (match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b :: bs) c | _ -> (bs, c)) | _ -> (bs, c)
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.is_any_fvar
val is_any_fvar (t: term) (nms: list string) : bool
val is_any_fvar (t: term) (nms: list string) : bool
let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 208, "start_col": 0, "start_line": 205 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> nms: Prims.list Prims.string -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "Prims.string", "Prims.op_BarBar", "FStar.Reflection.V1.Derived.is_fvar", "FStar.Reflection.V1.Derived.is_any_fvar", "Prims.bool" ]
[ "recursion" ]
false
false
false
true
false
let rec is_any_fvar (t: term) (nms: list string) : bool =
match nms with | [] -> false | v :: vs -> is_fvar t v || is_any_fvar t vs
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.head
val head (t: term) : term
val head (t: term) : term
let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 193, "start_col": 0, "start_line": 174 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.inspect_ln", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.match_returns_ascription", "Prims.list", "FStar.Stubs.Reflection.V1.Data.branch", "FStar.Reflection.V1.Derived.head", "Prims.bool", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Stubs.Reflection.Types.comp", "Prims.nat", "FStar.Stubs.Reflection.Types.ctx_uvar_and_subst", "FStar.Stubs.Reflection.V1.Data.vconst", "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V1.Data.universes" ]
[ "recursion" ]
false
false
false
true
false
let rec head (t: term) : term =
match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.destruct_tuple
val destruct_tuple (t: term) : option (list term)
val destruct_tuple (t: term) : option (list term)
let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 169, "start_col": 0, "start_line": 157 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Native.option (Prims.list FStar.Stubs.Reflection.Types.term)
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V1.Data.argv", "FStar.Stubs.Reflection.V1.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "FStar.List.Tot.Base.mem", "Prims.string", "FStar.Stubs.Reflection.V1.Builtins.inspect_fv", "Prims.Cons", "FStar.Reflection.Const.mktuple2_qn", "FStar.Reflection.Const.mktuple3_qn", "FStar.Reflection.Const.mktuple4_qn", "FStar.Reflection.Const.mktuple5_qn", "FStar.Reflection.Const.mktuple6_qn", "FStar.Reflection.Const.mktuple7_qn", "FStar.Reflection.Const.mktuple8_qn", "Prims.Nil", "FStar.Pervasives.Native.Some", "FStar.List.Tot.Base.concatMap", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V1.Data.aqualv", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Reflection.V1.Derived.collect_app_ln" ]
[]
false
false
false
true
false
let destruct_tuple (t: term) : option (list term) =
let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mktuple_n
val mktuple_n (ts: list term {List.Tot.Base.length ts <= 8}) : term
val mktuple_n (ts: list term {List.Tot.Base.length ts <= 8}) : term
let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 155, "start_col": 0, "start_line": 141 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
ts: Prims.list FStar.Stubs.Reflection.Types.term {FStar.List.Tot.Base.length ts <= 8} -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.Types.term", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_Const", "FStar.Stubs.Reflection.V1.Data.C_Unit", "Prims.int", "FStar.Reflection.V1.Derived.mk_e_app", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Builtins.pack_fv", "FStar.Stubs.Reflection.Types.name", "FStar.Reflection.Const.mktuple2_qn", "FStar.Reflection.Const.mktuple3_qn", "FStar.Reflection.Const.mktuple4_qn", "FStar.Reflection.Const.mktuple5_qn", "FStar.Reflection.Const.mktuple6_qn", "FStar.Reflection.Const.mktuple7_qn", "FStar.Reflection.Const.mktuple8_qn" ]
[]
false
false
false
false
false
let mktuple_n (ts: list term {List.Tot.Base.length ts <= 8}) : term =
match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts
false
Hacl.Spec.Curve25519.Field64.Definition.fst
Hacl.Spec.Curve25519.Field64.Definition.feval4
val feval4 (f: felem4) : GTot P.elem
val feval4 (f: felem4) : GTot P.elem
let feval4 (f:felem4) : GTot P.elem = as_nat4 f % P.prime
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.Field64.Definition.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 21, "start_col": 0, "start_line": 21 }
module Hacl.Spec.Curve25519.Field64.Definition open Lib.Sequence open Lib.IntTypes module P = Spec.Curve25519 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let felem4 = (uint64 * uint64 * uint64 * uint64) open FStar.Mul noextract val as_nat4: f:felem4 -> GTot nat let as_nat4 f = let (s0, s1, s2, s3) = f in v s0 + v s1 * pow2 64 + v s2 * pow2 64 * pow2 64 + v s3 * pow2 64 * pow2 64 * pow2 64
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.Curve25519.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.Field64.Definition.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "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 } ]
{ "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" }
false
f: Hacl.Spec.Curve25519.Field64.Definition.felem4 -> Prims.GTot Spec.Curve25519.elem
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Spec.Curve25519.Field64.Definition.felem4", "Prims.op_Modulus", "Hacl.Spec.Curve25519.Field64.Definition.as_nat4", "Spec.Curve25519.prime", "Spec.Curve25519.elem" ]
[]
false
false
false
false
false
let feval4 (f: felem4) : GTot P.elem =
as_nat4 f % P.prime
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.mkpair
val mkpair (t1 t2: term) : term
val mkpair (t1 t2: term) : term
let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2]
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 172, "start_col": 0, "start_line": 171 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.mktuple_n", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
true
false
let mkpair (t1 t2: term) : term =
mktuple_n [t1; t2]
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.is_name_imp
val is_name_imp (nm: name) (t: term) : bool
val is_name_imp (nm: name) (t: term) : bool
let rec is_name_imp (nm : name) (t : term) : bool = begin match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> if inspect_fv fv = nm then true else false | Tv_App l (_, Q_Implicit) -> is_name_imp nm l | _ -> false end
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 245, "start_col": 0, "start_line": 235 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q} (** Set a vconfig for a sigelt *) val add_check_with : vconfig -> sigelt -> Tot sigelt let add_check_with vcfg se = let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se let un_uinst (t:term) : term = match inspect_ln t with | Tv_UInst fv _ -> pack_ln (Tv_FVar fv) | _ -> t (* Returns [true] iff the term [t] is just the name [nm], though possibly universe-instantiated and applied to some implicit arguments.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
nm: FStar.Stubs.Reflection.Types.name -> t: FStar.Stubs.Reflection.Types.term -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.fv", "Prims.op_Equality", "FStar.Stubs.Reflection.V1.Builtins.inspect_fv", "Prims.bool", "FStar.Stubs.Reflection.V1.Data.universes", "FStar.Reflection.V1.Derived.is_name_imp", "FStar.Stubs.Reflection.V1.Data.term_view" ]
[ "recursion" ]
false
false
false
true
false
let rec is_name_imp (nm: name) (t: term) : bool =
match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> if inspect_fv fv = nm then true else false | Tv_App l (_, Q_Implicit) -> is_name_imp nm l | _ -> false
false
FStar.Reflection.V1.Derived.fst
FStar.Reflection.V1.Derived.maybe_unsquash_term
val maybe_unsquash_term (t: term) : term
val maybe_unsquash_term (t: term) : term
let maybe_unsquash_term (t : term) : term = match unsquash_term t with | Some t' -> t' | None -> t
{ "file_name": "ulib/FStar.Reflection.V1.Derived.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 262, "start_col": 0, "start_line": 259 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V1.Derived open FStar.Stubs.Reflection.Types open FStar.Reflection.Const open FStar.Stubs.Reflection.V1.Builtins open FStar.Stubs.Reflection.V1.Data open FStar.Order open FStar.VConfig let bv_of_binder (b : binder) : bv = (inspect_binder b).binder_bv let rec inspect_ln_unascribe (t:term) : tv:term_view{tv << t /\ notAscription tv} = match inspect_ln t with | Tv_AscribedT t' _ _ _ | Tv_AscribedC t' _ _ _ -> inspect_ln_unascribe t' | tv -> tv (* * AR: add versions that take attributes as arguments? *) let mk_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Explicit; binder_attrs=[]; binder_sort = sort; } let mk_implicit_binder (bv : bv) (sort : typ) : binder = pack_binder { binder_bv=bv; binder_qual=Q_Implicit; binder_attrs=[]; binder_sort = sort; } let type_of_binder (b : binder) : typ = (inspect_binder b).binder_sort val flatten_name : name -> Tot string let rec flatten_name ns = match ns with | [] -> "" | [n] -> n | n::ns -> n ^ "." ^ flatten_name ns (* Helpers for dealing with nested applications and arrows *) let rec collect_app_ln' (args : list argv) (t : term) : Tot (term * list argv) (decreases t) = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_ln' (r::args) l | _ -> (t, args) val collect_app_ln : term -> term * list argv let collect_app_ln = collect_app_ln' [] let rec mk_app (t : term) (args : list argv) : Tot term (decreases args) = match args with | [] -> t | (x::xs) -> mk_app (pack_ln (Tv_App t x)) xs // Helper for when all arguments are explicit let mk_e_app (t : term) (args : list term) : Tot term = let e t = (t, Q_Explicit) in mk_app t (List.Tot.Base.map e args) let u_unk : universe = pack_universe Uv_Unk let rec mk_tot_arr_ln (bs: list binder) (cod : term) : Tot term (decreases bs) = match bs with | [] -> cod | (b::bs) -> pack_ln (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr_ln bs cod)))) let rec collect_arr' (bs : list binder) (c : comp) : Tot (list binder * comp) (decreases c) = begin match inspect_comp c with | C_Total t -> begin match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr' (b::bs) c | _ -> (bs, c) end | _ -> (bs, c) end val collect_arr_ln_bs : typ -> list binder * comp let collect_arr_ln_bs t = let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in (List.Tot.Base.rev bs, c) val collect_arr_ln : typ -> list typ * comp let collect_arr_ln t = let bs, c = collect_arr_ln_bs t in List.Tot.Base.map type_of_binder bs, c let rec collect_abs' (bs : list binder) (t : term) : Tot (list binder * term) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b t' -> collect_abs' (b::bs) t' | _ -> (bs, t) val collect_abs_ln : term -> list binder * term let collect_abs_ln t = let (bs, t') = collect_abs' [] t in (List.Tot.Base.rev bs, t') let fv_to_string (fv:fv) : string = implode_qn (inspect_fv fv) let mk_stringlit (s : string) : term = pack_ln (Tv_Const (C_String s)) let mk_strcat (t1 t2 : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv ["Prims"; "strcat"]))) [t1; t2] let mk_cons (h t : term) : term = mk_e_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [h; t] let mk_cons_t (ty h t : term) : term = mk_app (pack_ln (Tv_FVar (pack_fv cons_qn))) [(ty, Q_Implicit); (h, Q_Explicit); (t, Q_Explicit)] let rec mk_list (ts : list term) : term = match ts with | [] -> pack_ln (Tv_FVar (pack_fv nil_qn)) | t::ts -> mk_cons t (mk_list ts) let mktuple_n (ts : list term{List.Tot.Base.length ts <= 8}) : term = match List.Tot.Base.length ts with | 0 -> pack_ln (Tv_Const C_Unit) | 1 -> let [x] = ts in x | n -> begin let qn = match n with | 2 -> mktuple2_qn | 3 -> mktuple3_qn | 4 -> mktuple4_qn | 5 -> mktuple5_qn | 6 -> mktuple6_qn | 7 -> mktuple7_qn | 8 -> mktuple8_qn in mk_e_app (pack_ln (Tv_FVar (pack_fv qn))) ts end let destruct_tuple (t : term) : option (list term) = let head, args = collect_app_ln t in match inspect_ln head with | Tv_FVar fv -> if List.Tot.Base.mem (inspect_fv fv) [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] then Some (List.Tot.Base.concatMap (fun (t, q) -> match q with | Q_Explicit -> [t] | _ -> []) args) else None | _ -> None let mkpair (t1 t2 : term) : term = mktuple_n [t1;t2] let rec head (t : term) : term = match inspect_ln t with | Tv_Match t _ _ | Tv_Let _ _ _ _ t _ | Tv_Abs _ t | Tv_Refine _ _ t | Tv_App t _ | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> head t | Tv_Unknown | Tv_Uvar _ _ | Tv_Const _ | Tv_Type _ | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_UInst _ _ | Tv_Arrow _ _ | Tv_Unsupp -> t (** Checks if a term `t` is equal to some FV (a top level name). Ignores universes and ascriptions. *) let is_fvar (t : term) (nm:string) : bool = match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> implode_qn (inspect_fv fv) = nm | _ -> false (** Checks if a term `t` is equal to any FV (a top level name) from those given in the list. Ignores universes and ascriptions. *) let rec is_any_fvar (t : term) (nms:list string) : bool = match nms with | [] -> false | v::vs -> is_fvar t v || is_any_fvar t vs let is_uvar (t : term) : bool = match inspect_ln (head t) with | Tv_Uvar _ _ -> true | _ -> false let binder_set_qual (q:aqualv) (b:binder) : Tot binder = let bview = inspect_binder b in pack_binder {bview with binder_qual=q} (** Set a vconfig for a sigelt *) val add_check_with : vconfig -> sigelt -> Tot sigelt let add_check_with vcfg se = let attrs = sigelt_attrs se in let vcfg_t = embed_vconfig vcfg in let t = `(check_with (`#vcfg_t)) in set_sigelt_attrs (t :: attrs) se let un_uinst (t:term) : term = match inspect_ln t with | Tv_UInst fv _ -> pack_ln (Tv_FVar fv) | _ -> t (* Returns [true] iff the term [t] is just the name [nm], though possibly universe-instantiated and applied to some implicit arguments. *) let rec is_name_imp (nm : name) (t : term) : bool = begin match inspect_ln_unascribe t with | Tv_FVar fv | Tv_UInst fv _ -> if inspect_fv fv = nm then true else false | Tv_App l (_, Q_Implicit) -> is_name_imp nm l | _ -> false end (* If t is of the shape [squash t'], return [Some t'], otherwise [None]. *) let unsquash_term (t : term) : option term = match inspect_ln_unascribe t with | Tv_App l (r, Q_Explicit) -> if is_name_imp squash_qn l then Some r else None | _ -> None (* As [unsquash_term], but returns the original term if
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Stubs.Reflection.V1.Data.fsti.checked", "FStar.Stubs.Reflection.V1.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V1.Derived.fst" }
[ { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Order", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Const", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "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 } ]
{ "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" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V1.Derived.unsquash_term" ]
[]
false
false
false
true
false
let maybe_unsquash_term (t: term) : term =
match unsquash_term t with | Some t' -> t' | None -> t
false
Hacl.Spec.Curve25519.Field64.Definition.fst
Hacl.Spec.Curve25519.Field64.Definition.as_nat4
val as_nat4: f:felem4 -> GTot nat
val as_nat4: f:felem4 -> GTot nat
let as_nat4 f = let (s0, s1, s2, s3) = f in v s0 + v s1 * pow2 64 + v s2 * pow2 64 * pow2 64 + v s3 * pow2 64 * pow2 64 * pow2 64
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.Field64.Definition.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 19, "start_col": 0, "start_line": 16 }
module Hacl.Spec.Curve25519.Field64.Definition open Lib.Sequence open Lib.IntTypes module P = Spec.Curve25519 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let felem4 = (uint64 * uint64 * uint64 * uint64) open FStar.Mul noextract
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.Curve25519.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.Field64.Definition.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "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 } ]
{ "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" }
false
f: Hacl.Spec.Curve25519.Field64.Definition.felem4 -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Spec.Curve25519.Field64.Definition.felem4", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Prims.pow2", "Prims.nat" ]
[]
false
false
false
false
false
let as_nat4 f =
let s0, s1, s2, s3 = f in v s0 + v s1 * pow2 64 + (v s2 * pow2 64) * pow2 64 + ((v s3 * pow2 64) * pow2 64) * pow2 64
false
Hacl.Spec.Curve25519.Field64.Definition.fst
Hacl.Spec.Curve25519.Field64.Definition.bn_v_is_as_nat
val bn_v_is_as_nat: e:lseq uint64 4 -> Lemma (as_nat4 (e.[0], e.[1], e.[2], e.[3]) == Hacl.Spec.Bignum.Definitions.bn_v #U64 #4 e)
val bn_v_is_as_nat: e:lseq uint64 4 -> Lemma (as_nat4 (e.[0], e.[1], e.[2], e.[3]) == Hacl.Spec.Bignum.Definitions.bn_v #U64 #4 e)
let bn_v_is_as_nat e = Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 e; assert (as_nat4 (e.[0], e.[1], e.[2], e.[3]) == Lib.ByteSequence.nat_from_intseq_le e); Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma 4 e; assert (Hacl.Spec.Bignum.Definitions.bn_v #U64 #4 e == Lib.ByteSequence.nat_from_intseq_le e)
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.Field64.Definition.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 95, "end_line": 30, "start_col": 0, "start_line": 26 }
module Hacl.Spec.Curve25519.Field64.Definition open Lib.Sequence open Lib.IntTypes module P = Spec.Curve25519 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let felem4 = (uint64 * uint64 * uint64 * uint64) open FStar.Mul noextract val as_nat4: f:felem4 -> GTot nat let as_nat4 f = let (s0, s1, s2, s3) = f in v s0 + v s1 * pow2 64 + v s2 * pow2 64 * pow2 64 + v s3 * pow2 64 * pow2 64 * pow2 64 let feval4 (f:felem4) : GTot P.elem = as_nat4 f % P.prime val bn_v_is_as_nat: e:lseq uint64 4 ->
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Impl.Curve25519.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.Field64.Definition.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Curve25519.Field64", "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 } ]
{ "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" }
false
e: Lib.Sequence.lseq Lib.IntTypes.uint64 4 -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (e.[ 0 ], e.[ 1 ], e.[ 2 ], e.[ 3 ]) == Hacl.Spec.Bignum.Definitions.bn_v e)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.Sequence.lseq", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.nat", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.U64", "Lib.ByteSequence.nat_from_intseq_le", "Lib.IntTypes.SEC", "Prims.unit", "Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma", "Hacl.Spec.Curve25519.Field64.Definition.as_nat4", "FStar.Pervasives.Native.Mktuple4", "Lib.Sequence.op_String_Access", "Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4" ]
[]
true
false
true
false
false
let bn_v_is_as_nat e =
Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 e; assert (as_nat4 (e.[ 0 ], e.[ 1 ], e.[ 2 ], e.[ 3 ]) == Lib.ByteSequence.nat_from_intseq_le e); Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma 4 e; assert (Hacl.Spec.Bignum.Definitions.bn_v #U64 #4 e == Lib.ByteSequence.nat_from_intseq_le e)
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.proposition_to_string
val proposition_to_string : proposition -> Tac string
val proposition_to_string : proposition -> Tac string
let proposition_to_string p = term_to_string p
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 26, "start_col": 0, "start_line": 26 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
p: FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.Propositions.proposition", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "Prims.string" ]
[]
false
true
false
false
false
let proposition_to_string p =
term_to_string p
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.term_eq
val term_eq : _: FStar.Stubs.Reflection.Types.term -> _: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool
let term_eq = FStar.Tactics.term_eq_old
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 9, "start_col": 0, "start_line": 9 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
_: FStar.Stubs.Reflection.Types.term -> _: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Tactics.V1.Builtins.term_eq_old" ]
[]
false
true
false
false
false
let term_eq =
FStar.Tactics.term_eq_old
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.is_trivial_proposition
val is_trivial_proposition : proposition -> Tac bool
val is_trivial_proposition : proposition -> Tac bool
let is_trivial_proposition p = term_eq (`Prims.l_True) p
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 48, "start_col": 0, "start_line": 47 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term val proposition_to_string : proposition -> Tac string let proposition_to_string p = term_to_string p /// Propositions split between pre and post assertions noeq type assertions = { pres : list proposition; posts : list proposition; } let mk_assertions pres posts : assertions = Mkassertions pres posts (*** Simplification *) /// Whenever we generate assertions, we simplify them to make them cleaner, /// prettier and remove the trivial ones. The normalization steps we apply /// are listed below. let simpl_norm_steps = [primops; simplify; iota] /// Simplify the propositions and filter the trivial ones. /// Check if a proposition is trivial (i.e.: is True) val is_trivial_proposition : proposition -> Tac bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
p: FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.Propositions.proposition", "FStar.InteractiveHelpers.Propositions.term_eq", "Prims.bool" ]
[]
false
true
false
false
false
let is_trivial_proposition p =
term_eq (`Prims.l_True) p
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.simpl_norm_steps
val simpl_norm_steps : Prims.list FStar.Pervasives.norm_step
let simpl_norm_steps = [primops; simplify; iota]
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 41, "start_col": 0, "start_line": 41 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term val proposition_to_string : proposition -> Tac string let proposition_to_string p = term_to_string p /// Propositions split between pre and post assertions noeq type assertions = { pres : list proposition; posts : list proposition; } let mk_assertions pres posts : assertions = Mkassertions pres posts (*** Simplification *) /// Whenever we generate assertions, we simplify them to make them cleaner, /// prettier and remove the trivial ones. The normalization steps we apply
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
Prims.list FStar.Pervasives.norm_step
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.primops", "FStar.Pervasives.simplify", "FStar.Pervasives.iota", "Prims.Nil" ]
[]
false
false
false
true
false
let simpl_norm_steps =
[primops; simplify; iota]
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.simp_filter_propositions
val simp_filter_propositions (e: env) (steps: list norm_step) (pl: list proposition) : Tac (list proposition)
val simp_filter_propositions (e: env) (steps: list norm_step) (pl: list proposition) : Tac (list proposition)
let simp_filter_propositions (e:env) (steps:list norm_step) (pl:list proposition) : Tac (list proposition) = List.flatten (map (simp_filter_proposition e steps) pl)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 59, "start_col": 0, "start_line": 57 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term val proposition_to_string : proposition -> Tac string let proposition_to_string p = term_to_string p /// Propositions split between pre and post assertions noeq type assertions = { pres : list proposition; posts : list proposition; } let mk_assertions pres posts : assertions = Mkassertions pres posts (*** Simplification *) /// Whenever we generate assertions, we simplify them to make them cleaner, /// prettier and remove the trivial ones. The normalization steps we apply /// are listed below. let simpl_norm_steps = [primops; simplify; iota] /// Simplify the propositions and filter the trivial ones. /// Check if a proposition is trivial (i.e.: is True) val is_trivial_proposition : proposition -> Tac bool let is_trivial_proposition p = term_eq (`Prims.l_True) p let simp_filter_proposition (e:env) (steps:list norm_step) (p:proposition) : Tac (list proposition) = let prop1 = norm_term_env e steps p in (* If trivial, filter *) if term_eq (`Prims.l_True) prop1 then [] else [prop1]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
e: FStar.Stubs.Reflection.Types.env -> steps: Prims.list FStar.Pervasives.norm_step -> pl: Prims.list FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac (Prims.list FStar.InteractiveHelpers.Propositions.proposition)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "Prims.list", "FStar.Pervasives.norm_step", "FStar.InteractiveHelpers.Propositions.proposition", "FStar.List.Tot.Base.flatten", "FStar.Tactics.Util.map", "FStar.InteractiveHelpers.Propositions.simp_filter_proposition" ]
[]
false
true
false
false
false
let simp_filter_propositions (e: env) (steps: list norm_step) (pl: list proposition) : Tac (list proposition) =
List.flatten (map (simp_filter_proposition e steps) pl)
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.simp_filter_proposition
val simp_filter_proposition (e: env) (steps: list norm_step) (p: proposition) : Tac (list proposition)
val simp_filter_proposition (e: env) (steps: list norm_step) (p: proposition) : Tac (list proposition)
let simp_filter_proposition (e:env) (steps:list norm_step) (p:proposition) : Tac (list proposition) = let prop1 = norm_term_env e steps p in (* If trivial, filter *) if term_eq (`Prims.l_True) prop1 then [] else [prop1]
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 55, "start_col": 0, "start_line": 50 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term val proposition_to_string : proposition -> Tac string let proposition_to_string p = term_to_string p /// Propositions split between pre and post assertions noeq type assertions = { pres : list proposition; posts : list proposition; } let mk_assertions pres posts : assertions = Mkassertions pres posts (*** Simplification *) /// Whenever we generate assertions, we simplify them to make them cleaner, /// prettier and remove the trivial ones. The normalization steps we apply /// are listed below. let simpl_norm_steps = [primops; simplify; iota] /// Simplify the propositions and filter the trivial ones. /// Check if a proposition is trivial (i.e.: is True) val is_trivial_proposition : proposition -> Tac bool let is_trivial_proposition p = term_eq (`Prims.l_True) p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
e: FStar.Stubs.Reflection.Types.env -> steps: Prims.list FStar.Pervasives.norm_step -> p: FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac (Prims.list FStar.InteractiveHelpers.Propositions.proposition)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "Prims.list", "FStar.Pervasives.norm_step", "FStar.InteractiveHelpers.Propositions.proposition", "Prims.Nil", "Prims.bool", "Prims.Cons", "FStar.InteractiveHelpers.Propositions.term_eq", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Tactics.V1.Builtins.norm_term_env" ]
[]
false
true
false
false
false
let simp_filter_proposition (e: env) (steps: list norm_step) (p: proposition) : Tac (list proposition) =
let prop1 = norm_term_env e steps p in if term_eq (`Prims.l_True) prop1 then [] else [prop1]
false
DijkstraStateMonad.fst
DijkstraStateMonad.post_t
val post_t : s: Type0 -> a: Type -> Type
let post_t (s:Type0) (a:Type) = a * s -> Type0
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 44, "start_col": 0, "start_line": 44 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
s: Type0 -> a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
true
let post_t (s: Type0) (a: Type) =
(a * s) -> Type0
false
DijkstraStateMonad.fst
DijkstraStateMonad.pre_t
val pre_t : s: Type -> Type
let pre_t (s:Type) = s -> Type0
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 48, "start_col": 0, "start_line": 48 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
s: Type -> Type
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
true
let pre_t (s: Type) =
s -> Type0
false
FStar.InteractiveHelpers.Propositions.fst
FStar.InteractiveHelpers.Propositions.simp_filter_assertions
val simp_filter_assertions (e: env) (steps: list norm_step) (a: assertions) : Tac assertions
val simp_filter_assertions (e: env) (steps: list norm_step) (a: assertions) : Tac assertions
let simp_filter_assertions (e:env) (steps:list norm_step) (a:assertions) : Tac assertions = let pres = simp_filter_propositions e steps a.pres in let posts = simp_filter_propositions e steps a.posts in mk_assertions pres posts
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 65, "start_col": 0, "start_line": 61 }
module FStar.InteractiveHelpers.Propositions open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base open FStar.InteractiveHelpers.ExploreTerm let term_eq = FStar.Tactics.term_eq_old /// Propositions and assertions. /// Assertions are propositions to be inserted in the F* code: we differentiate /// between pre and post assertions, which are to be inserted before a point in /// the code. For instance, if we analyze an effectful term in F*: /// [> assert(y <> 0); // pre assertion /// [> let z = x / y in // term of interest /// [> assert(...); // post assertion #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" /// Analyze a term to retrieve its effectful information type proposition = term val proposition_to_string : proposition -> Tac string let proposition_to_string p = term_to_string p /// Propositions split between pre and post assertions noeq type assertions = { pres : list proposition; posts : list proposition; } let mk_assertions pres posts : assertions = Mkassertions pres posts (*** Simplification *) /// Whenever we generate assertions, we simplify them to make them cleaner, /// prettier and remove the trivial ones. The normalization steps we apply /// are listed below. let simpl_norm_steps = [primops; simplify; iota] /// Simplify the propositions and filter the trivial ones. /// Check if a proposition is trivial (i.e.: is True) val is_trivial_proposition : proposition -> Tac bool let is_trivial_proposition p = term_eq (`Prims.l_True) p let simp_filter_proposition (e:env) (steps:list norm_step) (p:proposition) : Tac (list proposition) = let prop1 = norm_term_env e steps p in (* If trivial, filter *) if term_eq (`Prims.l_True) prop1 then [] else [prop1] let simp_filter_propositions (e:env) (steps:list norm_step) (pl:list proposition) : Tac (list proposition) = List.flatten (map (simp_filter_proposition e steps) pl)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.ExploreTerm.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.Propositions.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.ExploreTerm", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "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 } ]
{ "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" }
false
e: FStar.Stubs.Reflection.Types.env -> steps: Prims.list FStar.Pervasives.norm_step -> a: FStar.InteractiveHelpers.Propositions.assertions -> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.Propositions.assertions
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "Prims.list", "FStar.Pervasives.norm_step", "FStar.InteractiveHelpers.Propositions.assertions", "FStar.InteractiveHelpers.Propositions.mk_assertions", "FStar.InteractiveHelpers.Propositions.proposition", "FStar.InteractiveHelpers.Propositions.simp_filter_propositions", "FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__posts", "FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__pres" ]
[]
false
true
false
false
false
let simp_filter_assertions (e: env) (steps: list norm_step) (a: assertions) : Tac assertions =
let pres = simp_filter_propositions e steps a.pres in let posts = simp_filter_propositions e steps a.posts in mk_assertions pres posts
false
DijkstraStateMonad.fst
DijkstraStateMonad.wp_t
val wp_t : s: Type0 -> a: Type -> Type
let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0)
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 62, "start_col": 0, "start_line": 62 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
s: Type0 -> a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.FunctionalExtensionality.op_Hat_Subtraction_Greater", "DijkstraStateMonad.post_t" ]
[]
false
false
false
true
true
let wp_t (s: Type0) (a: Type) =
s ^-> (post_t s a -> Type0)
false
DijkstraStateMonad.fst
DijkstraStateMonad.wp_put
val wp_put: #s: _ -> #a: _ -> f: wp_t s a -> s -> wp_t s a
val wp_put: #s: _ -> #a: _ -> f: wp_t s a -> s -> wp_t s a
let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s)
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 68, "start_col": 0, "start_line": 66 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action;
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
f: DijkstraStateMonad.wp_t s a -> _: s -> DijkstraStateMonad.wp_t s a
Prims.Tot
[ "total" ]
[]
[ "DijkstraStateMonad.wp_t", "FStar.FunctionalExtensionality.on", "DijkstraStateMonad.post_t" ]
[]
false
false
false
true
false
let wp_put #s #a (f: wp_t s a) : s -> wp_t s a =
fun s -> F.on _ (fun s0 -> f s)
false
DijkstraStateMonad.fst
DijkstraStateMonad.wp_return
val wp_return (#s #a: _) (x: a) : wp_t s a
val wp_return (#s #a: _) (x: a) : wp_t s a
let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0))
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 73, "start_col": 0, "start_line": 71 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
x: a -> DijkstraStateMonad.wp_t s a
Prims.Tot
[ "total" ]
[]
[ "FStar.FunctionalExtensionality.on", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "DijkstraStateMonad.wp_t" ]
[]
false
false
false
true
false
let wp_return #s #a (x: a) : wp_t s a =
F.on _ (fun s0 post -> post (x, s0))
false
Steel.ST.Array.fst
Steel.ST.Array.pts_to_range_join
val pts_to_range_join (#opened: _) (#elt: Type0) (#p: P.perm) (#s1 #s2: Seq.seq elt) (a: array elt) (i m j: nat) : STGhostT unit opened (pts_to_range a i m p s1 `star` pts_to_range a m j p s2) (fun _ -> pts_to_range a i j p (s1 `Seq.append` s2))
val pts_to_range_join (#opened: _) (#elt: Type0) (#p: P.perm) (#s1 #s2: Seq.seq elt) (a: array elt) (i m j: nat) : STGhostT unit opened (pts_to_range a i m p s1 `star` pts_to_range a m j p s2) (fun _ -> pts_to_range a i j p (s1 `Seq.append` s2))
let pts_to_range_join #_ #_ #p #s1 #s2 a i m j = length_fits a; pts_to_range_prop a i m p s1; pts_to_range_prop a m j p s2; let a1 = pts_to_range_elim' a i m p s1 in let a2 = pts_to_range_elim' a m j p s2 in ghost_join a1 a2 (); pts_to_range_intro' a i j p _ _
{ "file_name": "lib/steel/Steel.ST.Array.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 655, "start_col": 0, "start_line": 647 }
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array module US = FStar.SizeT /// Lifting a value of universe 0 to universe 1. We use /// FStar.Universe, since FStar.Extraction.Krml is set to extract /// those functions to identity. inline_for_extraction [@@ noextract_to "krml"] let raise_t (t: Type0) : Type u#1 = FStar.Universe.raise_t t inline_for_extraction [@@noextract_to "krml"] let raise (#t: Type) (x: t) : Tot (raise_t t) = FStar.Universe.raise_val x inline_for_extraction [@@noextract_to "krml"] let lower (#t: Type) (x: raise_t t) : Tot t = FStar.Universe.downgrade_val x /// A map operation on sequences. Here we only need Ghost versions, /// because such sequences are only used in vprops or with their /// selectors. let rec seq_map (#t: Type u#a) (#t' : Type u#b) (f: (t -> GTot t')) (s: Seq.seq t) : Ghost (Seq.seq t') (requires True) (ensures (fun s' -> Seq.length s' == Seq.length s /\ (forall i . {:pattern (Seq.index s' i)} Seq.index s' i == f (Seq.index s i)) )) (decreases (Seq.length s)) = if Seq.length s = 0 then Seq.empty else Seq.cons (f (Seq.index s 0)) (seq_map f (Seq.slice s 1 (Seq.length s))) let seq_map_append (#t: Type u#a) (#t': Type u#b) (f: (t -> GTot t')) (s1 s2: Seq.seq t) : Lemma (seq_map f (s1 `Seq.append` s2) `Seq.equal` (seq_map f s1 `Seq.append` seq_map f s2)) = () let seq_map_raise_inj (#elt: Type0) (s1 s2: Seq.seq elt) : Lemma (requires (seq_map raise s1 == seq_map raise s2)) (ensures (s1 == s2)) [SMTPat (seq_map raise s1); SMTPat (seq_map raise s2)] = assert (seq_map lower (seq_map raise s1) `Seq.equal` s1); assert (seq_map lower (seq_map raise s2) `Seq.equal` s2) /// Implementation of the interface /// base, ptr, array, pts_to module H = Steel.ST.HigherArray let base_t elt = H.base_t (raise_t elt) let base_len b = H.base_len b let ptr elt = H.ptr (raise_t elt) let null_ptr elt = H.null_ptr (raise_t elt) let is_null_ptr p = H.is_null_ptr p let base p = H.base p let offset p = H.offset p let ptr_base_offset_inj p1 p2 = H.ptr_base_offset_inj p1 p2 let base_len_null_ptr elt = H.base_len_null_ptr (raise_t elt) let length_fits a = H.length_fits a let pts_to a p s = H.pts_to a p (seq_map raise s) let pts_to_length a s = H.pts_to_length a _ let h_array_eq' (#t: Type u#1) (a1 a2: H.array t) : Lemma (requires ( dfst a1 == dfst a2 /\ (Ghost.reveal (dsnd a1) <: nat) == Ghost.reveal (dsnd a2) )) (ensures ( a1 == a2 )) = () let pts_to_not_null #_ #t #p a s = let _ = H.pts_to_not_null #_ #_ #p a (seq_map raise s) in assert (a =!= H.null #(raise_t t)); Classical.move_requires (h_array_eq' a) (H.null #(raise_t t)); noop () let pts_to_inj a p1 s1 p2 s2 = H.pts_to_inj a p1 (seq_map raise s1) p2 (seq_map raise s2) /// Non-selector operations. let malloc x n = let res = H.malloc (raise x) n in assert (seq_map raise (Seq.create (US.v n) x) `Seq.equal` Seq.create (US.v n) (raise x)); rewrite (H.pts_to res _ _) (pts_to res _ _); return res let free #_ x = let s = elim_exists () in rewrite (pts_to x _ _) (H.pts_to x P.full_perm (seq_map raise s)); H.free x let share #_ #_ #x a p p1 p2 = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); H.share a p p1 p2; rewrite (H.pts_to a p1 _) (pts_to a p1 x); rewrite (H.pts_to a p2 _) (pts_to a p2 x) let gather #_ #_ a #x1 p1 #x2 p2 = rewrite (pts_to a p1 _) (H.pts_to a p1 (seq_map raise x1)); rewrite (pts_to a p2 _) (H.pts_to a p2 (seq_map raise x2)); H.gather a p1 p2; rewrite (H.pts_to a _ _) (pts_to _ _ _) let index #_ #p a #s i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise s)); let res = H.index a i in rewrite (H.pts_to _ _ _) (pts_to _ _ _); return (lower res) let upd #_ a #s i v = rewrite (pts_to a _ _) (H.pts_to a P.full_perm (seq_map raise s)); H.upd a i (raise v); assert (seq_map raise (Seq.upd s (US.v i) v) `Seq.equal` Seq.upd (seq_map raise s) (US.v i) (raise v)); rewrite (H.pts_to _ _ _) (pts_to _ _ _) let ghost_join #_ #_ #x1 #x2 #p a1 a2 h = rewrite (pts_to a1 _ _) (H.pts_to a1 p (seq_map raise x1)); rewrite (pts_to a2 _ _) (H.pts_to a2 p (seq_map raise x2)); H.ghost_join a1 a2 h; assert (seq_map raise (x1 `Seq.append` x2) `Seq.equal` (seq_map raise x1 `Seq.append` seq_map raise x2)); rewrite (H.pts_to _ _ _) (H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2))); rewrite (H.pts_to _ _ _) (pts_to (merge a1 a2) _ _) let ptr_shift p off = H.ptr_shift p off let ghost_split #_ #_ #x #p a i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); let _ = H.ghost_split a i in //H.ghost_split a i; assert (seq_map raise (Seq.slice x 0 (US.v i)) `Seq.equal` Seq.slice (seq_map raise x) 0 (US.v i)); rewrite (H.pts_to (H.split_l a i) _ _) (H.pts_to (split_l a i) p (seq_map raise (Seq.slice x 0 (US.v i)))); rewrite (H.pts_to (split_l a i) _ _) (pts_to (split_l a i) _ _); assert (seq_map raise (Seq.slice x (US.v i) (Seq.length x)) `Seq.equal` Seq.slice (seq_map raise x) (US.v i) (Seq.length (seq_map raise x))); Seq.lemma_split x (US.v i); rewrite (H.pts_to (H.split_r a i) _ _) (H.pts_to (split_r a i) p (seq_map raise (Seq.slice x (US.v i) (Seq.length x)))); rewrite (H.pts_to (split_r a i) _ _) (pts_to (split_r a i) _ _) let memcpy a0 a1 l = H.memcpy a0 a1 l //////////////////////////////////////////////////////////////////////////////// // compare //////////////////////////////////////////////////////////////////////////////// module R = Steel.ST.Reference #push-options "--fuel 0 --ifuel 1 --z3rlimit_factor 2" let equal_up_to #t (s0: Seq.seq t) (s1: Seq.seq t) (v : option US.t) : prop = Seq.length s0 = Seq.length s1 /\ (match v with | None -> Ghost.reveal s0 =!= Ghost.reveal s1 | Some v -> US.v v <= Seq.length s0 /\ Seq.slice s0 0 (US.v v) `Seq.equal` Seq.slice s1 0 (US.v v)) let within_bounds (x:option US.t) (l:US.t) (b:Ghost.erased bool) : prop = if b then Some? x /\ US.(Some?.v x <^ l) else None? x \/ US.(Some?.v x >=^ l) let compare_inv (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (s0: Seq.seq t) (s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) = pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) let elim_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) : STGhostT (Ghost.erased (option US.t)) o (compare_inv a0 a1 s0 s1 l ctr b) (fun x -> let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) = let open US in assert_spinoff ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b)))); rewrite (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b))); let _v = elim_exists () in _v let intro_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) (b:bool { within_bounds x l b }) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> compare_inv a0 a1 s0 s1 l ctr (Ghost.hide b)) = let open US in intro_pure (within_bounds x l (Ghost.hide b)); intro_exists_erased x (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l (Ghost.hide b))); assert_norm ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b))))); rewrite (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b)))) (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) let intro_exists_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) = let b : bool = match Ghost.reveal x with | None -> false | Some x -> US.(x <^ l) in assert (within_bounds x l b); intro_compare_inv #_ #_ #p0 #p1 a0 a1 #s0 #s1 l ctr x b; intro_exists _ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr) let extend_equal_up_to_lemma (#t:Type0) (s0:Seq.seq t) (s1:Seq.seq t) (i:nat{ i < Seq.length s0 /\ Seq.length s0 == Seq.length s1 }) : Lemma (requires Seq.equal (Seq.slice s0 0 i) (Seq.slice s1 0 i) /\ Seq.index s0 i == Seq.index s1 i) (ensures Seq.equal (Seq.slice s0 0 (i + 1)) (Seq.slice s1 0 (i + 1))) = assert (forall k. k < i ==> Seq.index s0 k == Seq.index (Seq.slice s0 0 i) k /\ Seq.index s1 k == Seq.index (Seq.slice s1 0 i) k) let extend_equal_up_to (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 (Some US.(i +^ 1sz)))) (requires Seq.index s0 (US.v i) == Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; extend_equal_up_to_lemma s0 s1 (US.v i); intro_pure (equal_up_to s0 s1 (Some US.(i +^ 1sz))) let extend_equal_up_to_neg (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 None)) (requires Seq.index s0 (US.v i) =!= Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; intro_pure _ let init_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) : STGhost unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires ( length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0 )) (ensures (fun _ -> True)) = pts_to_length a0 _; pts_to_length a1 _; intro_pure (equal_up_to s0 s1 (Ghost.hide (Some 0sz))); rewrite (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (R.pts_to ctr Steel.FractionalPermission.full_perm (Ghost.hide (Some 0sz))); intro_exists_compare_inv a0 a1 l ctr (Ghost.hide (Some 0sz)) let compare_pts (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Ghost.erased (Seq.seq t)) (#s1: Ghost.erased (Seq.seq t)) (l:US.t) : ST bool (pts_to a0 p0 s0 `star` pts_to a1 p1 s1) (fun _ -> pts_to a0 p0 s0 `star` pts_to a1 p1 s1) (requires length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0 ) (ensures fun b -> b = (Ghost.reveal s0 = Ghost.reveal s1)) = pts_to_length a0 _; pts_to_length a1 _; let ctr = R.alloc (Some 0sz) in let cond () : STT bool (exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (fun b -> compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) = let _b = elim_exists () in let _ = elim_compare_inv _ _ _ _ _ in let x = R.read ctr in elim_pure (within_bounds _ _ _); match x with | None -> intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ false; return false | Some x -> let res = US.(x <^ l) in intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ res; return res in let body () : STT unit (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide true)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) = let _i = elim_compare_inv _ _ _ _ _ in elim_pure (within_bounds _ _ _); let Some i = R.read ctr in assert_spinoff ((pure (equal_up_to s0 s1 _i)) == (pure (equal_up_to s0 s1 (Some i)))); rewrite (pure (equal_up_to s0 s1 _i)) (pure (equal_up_to s0 s1 (Some i))); let v0 = index a0 i in let v1 = index a1 i in if v0 = v1 then ( R.write ctr (Some US.(i +^ 1sz)); extend_equal_up_to l i; intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide (Some (US.(i +^ 1sz)))) ) else ( R.write ctr None; extend_equal_up_to_neg l i; intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide None) ) in init_compare_inv a0 a1 l ctr; Steel.ST.Loops.while_loop (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr) cond body; let _ = elim_compare_inv _ _ _ _ _ in elim_pure (equal_up_to _ _ _); let v = R.read ctr in R.free ctr; elim_pure (within_bounds _ _ _); match v with | None -> return false | Some _ -> return true let compare #t #p0 #p1 a0 a1 #s0 #s1 l = pts_to_length a0 _; pts_to_length a1 _; if l = 0sz then ( assert (Seq.equal s0 s1); return true ) else ( compare_pts a0 a1 l ) #pop-options let intro_fits_u32 () = H.intro_fits_u32 () let intro_fits_u64 () = H.intro_fits_u64 () let intro_fits_ptrdiff32 () = H.intro_fits_ptrdiff32 () let intro_fits_ptrdiff64 () = H.intro_fits_ptrdiff64 () let ptrdiff #_ #p0 #p1 #s0 #s1 a0 a1 = rewrite (pts_to a0 _ _) (H.pts_to a0 p0 (seq_map raise s0)); rewrite (pts_to a1 _ _) (H.pts_to a1 p1 (seq_map raise s1)); let res = H.ptrdiff a0 a1 in rewrite (H.pts_to a1 _ _) (pts_to a1 _ _); rewrite (H.pts_to a0 _ _) (pts_to a0 _ _); return res let array_slice (#elt: Type0) (a: array elt) (i j: nat) (sq: squash (i <= j /\ j <= length a)) : Ghost (array elt) (requires True) (ensures (fun a' -> length a' == j - i)) = length_fits a; split_l (split_r a (US.uint_to_t i)) (US.uint_to_t (j - i)) [@@__reduce__] let pts_to_range_body (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (s: Seq.seq elt) (sq: squash (i <= j /\ j <= length a)) : Tot vprop = pts_to (array_slice a i j sq) p s let pts_to_range (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop = exists_ (pts_to_range_body a i j p s) let pts_to_range_intro' (#opened: _) (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (a': array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a' p s) (fun _ -> pts_to_range a i j p s) (i <= j /\ j <= length a /\ a' == array_slice a i j () ) (fun _ -> True) = let sq : squash (i <= j /\ j <= length a) = () in rewrite (pts_to a' p s) (pts_to (array_slice a i j sq) p s); rewrite (exists_ (pts_to_range_body a i j p s)) (pts_to_range a i j p s) let pts_to_range_elim' (#opened: _) (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (s: Seq.seq elt) : STGhost (Ghost.erased (array elt)) opened (pts_to_range a i j p s) (fun a' -> pts_to a' p s) True (fun a' -> i <= j /\ j <= length a /\ Ghost.reveal a' == array_slice a i j () ) = rewrite (pts_to_range a i j p s) (exists_ (pts_to_range_body a i j p s)); let _ = elim_exists () in vpattern_replace_erased (fun a' -> pts_to a' p s) let pts_to_range_prop a i j p s = let a' = pts_to_range_elim' a i j p s in pts_to_length a' s; pts_to_range_intro' a i j p a' s let pts_to_range_intro a p s = ptr_shift_zero (ptr_of a); pts_to_range_intro' a 0 (length a) p a s let pts_to_range_elim a p s = ptr_shift_zero (ptr_of a); let a' = pts_to_range_elim' a 0 (length a) p s in vpattern_rewrite (fun a' -> pts_to a' _ _) a let pts_to_range_split #_ #_ #p #s a i m j = length_fits a; pts_to_range_prop a i j p s; let a' = pts_to_range_elim' a i j p s in let mi = US.uint_to_t (m - i) in ptr_shift_add (ptr_of a) (US.uint_to_t i) mi; let _ = ghost_split a' mi in pts_to_range_intro' a m j p (split_r a' mi) _; pts_to_range_intro' a i m p (split_l a' mi) _; noop ()
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.HigherArray.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.HigherArray", "short_module": "H" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "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 } ]
{ "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" }
false
a: Steel.ST.Array.array elt -> i: Prims.nat -> m: Prims.nat -> j: Prims.nat -> Steel.ST.Effect.Ghost.STGhostT Prims.unit
Steel.ST.Effect.Ghost.STGhostT
[]
[]
[ "Steel.Memory.inames", "Steel.FractionalPermission.perm", "FStar.Seq.Base.seq", "Steel.ST.Array.array", "Prims.nat", "Steel.ST.Array.pts_to_range_intro'", "Steel.ST.Array.merge", "FStar.Ghost.reveal", "FStar.Ghost.hide", "FStar.Seq.Base.append", "Prims.unit", "Steel.ST.Array.ghost_join", "FStar.Ghost.erased", "Steel.ST.Array.pts_to_range_elim'", "Steel.ST.Array.pts_to_range_prop", "Steel.ST.Array.length_fits" ]
[]
false
true
false
false
false
let pts_to_range_join #_ #_ #p #s1 #s2 a i m j =
length_fits a; pts_to_range_prop a i m p s1; pts_to_range_prop a m j p s2; let a1 = pts_to_range_elim' a i m p s1 in let a2 = pts_to_range_elim' a m j p s2 in ghost_join a1 a2 (); pts_to_range_intro' a i j p _ _
false
DijkstraStateMonad.fst
DijkstraStateMonad.bind_wp
val bind_wp (#a #b #s: _) (wp_f: wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b
val bind_wp (#a #b #s: _) (wp_f: wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b
let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post))
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 67, "end_line": 137, "start_col": 0, "start_line": 135 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
wp_f: DijkstraStateMonad.wp_t s a -> wp_g: (_: a -> DijkstraStateMonad.wp_t s b) -> DijkstraStateMonad.wp_t s b
Prims.Tot
[ "total" ]
[]
[ "DijkstraStateMonad.wp_t", "FStar.FunctionalExtensionality.on", "DijkstraStateMonad.post_t", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
false
let bind_wp #a #b #s (wp_f: wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b =
F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post))
false
DijkstraStateMonad.fst
DijkstraStateMonad.irepr
val irepr : a: Type -> s: Type0 -> wp: DijkstraStateMonad.wp_t s a -> Type
let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp }
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 127, "start_col": 0, "start_line": 126 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) ///
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
a: Type -> s: Type0 -> wp: DijkstraStateMonad.wp_t s a -> Type
Prims.Tot
[ "total" ]
[]
[ "DijkstraStateMonad.wp_t", "Prims.unit", "DijkstraStateMonad.m", "FStar.FunctionalExtensionality.feq", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of" ]
[]
false
false
false
true
true
let irepr a s (wp: wp_t s a) =
unit -> m: m s a {(wp_of m) `F.feq` wp}
false
DijkstraStateMonad.fst
DijkstraStateMonad.bind_m
val bind_m (#s #a #b: _) (x: m s a) (y: (a -> m s b)) : m s b
val bind_m (#s #a #b: _) (x: m s a) (y: (a -> m s b)) : m s b
let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y)
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 37, "start_col": 0, "start_line": 33 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
x: DijkstraStateMonad.m s a -> y: (_: a -> DijkstraStateMonad.m s b) -> DijkstraStateMonad.m s b
Prims.Tot
[ "total" ]
[]
[ "DijkstraStateMonad.m", "DijkstraStateMonad.Get", "DijkstraStateMonad.bind_m", "DijkstraStateMonad.Put" ]
[ "recursion" ]
false
false
false
true
false
let rec bind_m #s #a #b (x: m s a) (y: (a -> m s b)) : m s b =
match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y)
false
DijkstraStateMonad.fst
DijkstraStateMonad.wp_of
val wp_of (#a #s: _) (x: m s a) : wp_t s a
val wp_of (#a #s: _) (x: m s a) : wp_t s a
let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 85, "start_col": 0, "start_line": 80 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
x: DijkstraStateMonad.m s a -> DijkstraStateMonad.wp_t s a
Prims.Tot
[ "total" ]
[]
[ "DijkstraStateMonad.m", "DijkstraStateMonad.wp_return", "FStar.FunctionalExtensionality.on", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.wp_put", "DijkstraStateMonad.wp_t" ]
[ "recursion" ]
false
false
false
true
false
let rec wp_of #a #s (x: m s a) : wp_t s a =
match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s
false
DijkstraStateMonad.fst
DijkstraStateMonad.lift_wp
val lift_wp (a: Type) (s: Type0) (wp: pure_wp a) : wp_t s a
val lift_wp (a: Type) (s: Type0) (wp: pure_wp a) : wp_t s a
let lift_wp (a:Type) (s:Type0) (wp:pure_wp a) : wp_t s a = F.on _ (fun (s0:s) (k:post_t s a) -> wp (fun a -> k (a, s0)))
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 274, "start_col": 0, "start_line": 270 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x /// bind_wp: This is a bind for the WP type `wp_t` let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post)) /// Now things get a bit technical in the main proof of the bind case /// of the morphisms /// First, we define a domain-restricted version of function composition let ( *. ) #a #b #c (f:b -> c) (g:a -> b) : (a ^-> c) = F.on _ (fun x -> f (g x)) /// An prove a auxiliary lemma about it (that's needed for functional /// extensionality) let lem_on_comp #a #b #c (f:b -> c) (g:a -> b) : Lemma (F.on _ (f *. g) == f *. g) = () /// We also rely on eta being a provable equality /// AR: 05/11, eta is no longer provable, so admitting it let eta (a:Type) (b:Type) (f:a -> b) : Lemma (f == (fun x -> f x)) = admit() /// Now, here's the main lemma of property (b). /// stating at first using extensional equality let rec bind_wp_lem' (#a:Type u#aa) (#b:Type u#bb) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) `F.feq` bind_wp (wp_of f) (wp_of *. g)) = match f with | Ret x -> assert (bind_m f g == g x); assert_norm (wp_of #a #s (Ret x) `F.feq` (fun s0 post -> post (x, s0))); assert (wp_of (bind_m (Ret x) g) `F.feq` bind_wp (wp_of (Ret x)) (wp_of *. g)) by (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1))) | Put s k -> bind_wp_lem' k g; assert_norm (wp_put (bind_wp (wp_of k) (wp_of *. g)) s `F.feq` bind_wp (wp_put (wp_of k) s) (wp_of *. g)) | Get k -> let aux (x:s) : Lemma (ensures (wp_of (bind_m (k x) g) `F.feq` bind_wp (wp_of (k x)) (wp_of *. g))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)) /// We now turn the extensional variant of the lemma into an equality let bind_wp_lem (#a:_) (#b:_) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g)) = bind_wp_lem' f g /// Now, we're ready to define a bind on the representation of our /// indexed computation type /// /// The index of the result is just the bind of indexes of the /// arguments (* * AR: 02/24: this is a bit funky * the combinator needs wp_g to be an F.restricted_t * * previously this was added as a refinement to wp_g * but now that we require the combinator to be typeable with use_eq_strict, that fails * * now, we can add it to the precondition of ibind (we not support Pure type for binds) * * and then the bind combinator and the layered effect typecheck * * but we can't use it, since the typechecker will now require a proof that * the continuation is a restricted_t, which fails *) let ibind a b s wp_f (wp_g: a -> wp_t s b) (f:irepr a s wp_f) (g : (x:a -> irepr b s (wp_g x))) : irepr b s (bind_wp wp_f wp_g) = let m_f = f () in let m_g = fun x -> g x () in fun () -> bind_wp_lem m_f m_g; assert (forall x. (wp_of *. m_g) x == wp_g x); assert (wp_f == wp_of m_f); assert ((wp_of *. m_g) `F.feq` wp_g); F.extensionality _ _ ((wp_of *. m_g)) wp_g; assert (F.on _ (wp_of *. m_g) == F.on _ wp_g); assume (F.on _ wp_g == wp_g); lem_on_comp wp_of m_g; assert (F.on _ (wp_of *. m_g) == (wp_of *. m_g)); bind_m m_f m_g /// Here are a couple of actions lifted into the indexed type /// Their WPs are just the WPs of the corresponding `m` actions let iget s : irepr s s (wp_of (Get Ret)) = fun () -> Get Ret let iput s (x:s) : irepr unit s (wp_of (Put x (Ret ()))) = fun () -> Put x (Ret ()) /// As explained above, for steps 4--6, This representation doesn't /// yet allow for subsumption So faking out these rules for now /// What we really want is a way to subsume the WP of a computation /// with another WP that implies the original one. /// /// But we can't prove that on the representation for now /// /// So, I just admit it let isubcomp (a:Type) (s:Type) (wp wp':wp_t s a) (f:irepr a s wp) : Pure (irepr a s wp') (requires forall s0 post. wp' s0 post ==> wp s0 post) (ensures fun _ -> True) = admit() /// Here's a rule for composing `f` and `g` under a conditional /// This is proven sound with respect to the subsumption rule let i_if_then_else (a:Type) (s:Type) (wpf wpg:wp_t s a) (f:irepr a s wpf) (g:irepr a s wpg) (p:bool) : Type = irepr a s (F.on _ (fun s0 post -> (p ==> wpf s0 post) /\ (~p ==> wpg s0 post)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
a: Type -> s: Type0 -> wp: Prims.pure_wp a -> DijkstraStateMonad.wp_t s a
Prims.Tot
[ "total" ]
[]
[ "Prims.pure_wp", "FStar.FunctionalExtensionality.on", "DijkstraStateMonad.post_t", "Prims.pure_pre", "Prims.l_True", "FStar.Pervasives.Native.Mktuple2", "DijkstraStateMonad.wp_t" ]
[]
false
false
false
true
false
let lift_wp (a: Type) (s: Type0) (wp: pure_wp a) : wp_t s a =
F.on _ (fun (s0: s) (k: post_t s a) -> wp (fun a -> k (a, s0)))
false
DijkstraStateMonad.fst
DijkstraStateMonad.run
val run (#a #s: _) (m: m s a) (s0: s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post)
val run (#a #s: _) (m: m s a) (s0: s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post)
let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 100, "start_col": 0, "start_line": 89 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
m: DijkstraStateMonad.m s a -> s0: s -> post: DijkstraStateMonad.post_t s a -> Prims.Pure (a * s)
Prims.Pure
[]
[]
[ "DijkstraStateMonad.m", "DijkstraStateMonad.post_t", "FStar.Pervasives.Native.Mktuple2", "DijkstraStateMonad.run", "FStar.Pervasives.Native.tuple2", "DijkstraStateMonad.wp_of" ]
[ "recursion" ]
false
false
false
false
false
let rec run (#a #s: _) (m: m s a) (s0: s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) =
match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post
false
DijkstraStateMonad.fst
DijkstraStateMonad.iput
val iput (s: _) (x: s) : irepr unit s (wp_of (Put x (Ret ())))
val iput (s: _) (x: s) : irepr unit s (wp_of (Put x (Ret ())))
let iput s (x:s) : irepr unit s (wp_of (Put x (Ret ()))) = fun () -> Put x (Ret ())
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 242, "start_col": 0, "start_line": 241 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x /// bind_wp: This is a bind for the WP type `wp_t` let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post)) /// Now things get a bit technical in the main proof of the bind case /// of the morphisms /// First, we define a domain-restricted version of function composition let ( *. ) #a #b #c (f:b -> c) (g:a -> b) : (a ^-> c) = F.on _ (fun x -> f (g x)) /// An prove a auxiliary lemma about it (that's needed for functional /// extensionality) let lem_on_comp #a #b #c (f:b -> c) (g:a -> b) : Lemma (F.on _ (f *. g) == f *. g) = () /// We also rely on eta being a provable equality /// AR: 05/11, eta is no longer provable, so admitting it let eta (a:Type) (b:Type) (f:a -> b) : Lemma (f == (fun x -> f x)) = admit() /// Now, here's the main lemma of property (b). /// stating at first using extensional equality let rec bind_wp_lem' (#a:Type u#aa) (#b:Type u#bb) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) `F.feq` bind_wp (wp_of f) (wp_of *. g)) = match f with | Ret x -> assert (bind_m f g == g x); assert_norm (wp_of #a #s (Ret x) `F.feq` (fun s0 post -> post (x, s0))); assert (wp_of (bind_m (Ret x) g) `F.feq` bind_wp (wp_of (Ret x)) (wp_of *. g)) by (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1))) | Put s k -> bind_wp_lem' k g; assert_norm (wp_put (bind_wp (wp_of k) (wp_of *. g)) s `F.feq` bind_wp (wp_put (wp_of k) s) (wp_of *. g)) | Get k -> let aux (x:s) : Lemma (ensures (wp_of (bind_m (k x) g) `F.feq` bind_wp (wp_of (k x)) (wp_of *. g))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)) /// We now turn the extensional variant of the lemma into an equality let bind_wp_lem (#a:_) (#b:_) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g)) = bind_wp_lem' f g /// Now, we're ready to define a bind on the representation of our /// indexed computation type /// /// The index of the result is just the bind of indexes of the /// arguments (* * AR: 02/24: this is a bit funky * the combinator needs wp_g to be an F.restricted_t * * previously this was added as a refinement to wp_g * but now that we require the combinator to be typeable with use_eq_strict, that fails * * now, we can add it to the precondition of ibind (we not support Pure type for binds) * * and then the bind combinator and the layered effect typecheck * * but we can't use it, since the typechecker will now require a proof that * the continuation is a restricted_t, which fails *) let ibind a b s wp_f (wp_g: a -> wp_t s b) (f:irepr a s wp_f) (g : (x:a -> irepr b s (wp_g x))) : irepr b s (bind_wp wp_f wp_g) = let m_f = f () in let m_g = fun x -> g x () in fun () -> bind_wp_lem m_f m_g; assert (forall x. (wp_of *. m_g) x == wp_g x); assert (wp_f == wp_of m_f); assert ((wp_of *. m_g) `F.feq` wp_g); F.extensionality _ _ ((wp_of *. m_g)) wp_g; assert (F.on _ (wp_of *. m_g) == F.on _ wp_g); assume (F.on _ wp_g == wp_g); lem_on_comp wp_of m_g; assert (F.on _ (wp_of *. m_g) == (wp_of *. m_g)); bind_m m_f m_g /// Here are a couple of actions lifted into the indexed type /// Their WPs are just the WPs of the corresponding `m` actions let iget s : irepr s s (wp_of (Get Ret)) =
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
s: Type0 -> x: s -> DijkstraStateMonad.irepr Prims.unit s (DijkstraStateMonad.wp_of (DijkstraStateMonad.Put x (DijkstraStateMonad.Ret ())))
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "DijkstraStateMonad.Put", "DijkstraStateMonad.Ret", "DijkstraStateMonad.m", "FStar.FunctionalExtensionality.feq", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.irepr" ]
[]
false
false
false
false
false
let iput s (x: s) : irepr unit s (wp_of (Put x (Ret ()))) =
fun () -> Put x (Ret ())
false
DijkstraStateMonad.fst
DijkstraStateMonad.iget
val iget (s: _) : irepr s s (wp_of (Get Ret))
val iget (s: _) : irepr s s (wp_of (Get Ret))
let iget s : irepr s s (wp_of (Get Ret)) = fun () -> Get Ret
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 240, "start_col": 0, "start_line": 239 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x /// bind_wp: This is a bind for the WP type `wp_t` let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post)) /// Now things get a bit technical in the main proof of the bind case /// of the morphisms /// First, we define a domain-restricted version of function composition let ( *. ) #a #b #c (f:b -> c) (g:a -> b) : (a ^-> c) = F.on _ (fun x -> f (g x)) /// An prove a auxiliary lemma about it (that's needed for functional /// extensionality) let lem_on_comp #a #b #c (f:b -> c) (g:a -> b) : Lemma (F.on _ (f *. g) == f *. g) = () /// We also rely on eta being a provable equality /// AR: 05/11, eta is no longer provable, so admitting it let eta (a:Type) (b:Type) (f:a -> b) : Lemma (f == (fun x -> f x)) = admit() /// Now, here's the main lemma of property (b). /// stating at first using extensional equality let rec bind_wp_lem' (#a:Type u#aa) (#b:Type u#bb) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) `F.feq` bind_wp (wp_of f) (wp_of *. g)) = match f with | Ret x -> assert (bind_m f g == g x); assert_norm (wp_of #a #s (Ret x) `F.feq` (fun s0 post -> post (x, s0))); assert (wp_of (bind_m (Ret x) g) `F.feq` bind_wp (wp_of (Ret x)) (wp_of *. g)) by (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1))) | Put s k -> bind_wp_lem' k g; assert_norm (wp_put (bind_wp (wp_of k) (wp_of *. g)) s `F.feq` bind_wp (wp_put (wp_of k) s) (wp_of *. g)) | Get k -> let aux (x:s) : Lemma (ensures (wp_of (bind_m (k x) g) `F.feq` bind_wp (wp_of (k x)) (wp_of *. g))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)) /// We now turn the extensional variant of the lemma into an equality let bind_wp_lem (#a:_) (#b:_) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g)) = bind_wp_lem' f g /// Now, we're ready to define a bind on the representation of our /// indexed computation type /// /// The index of the result is just the bind of indexes of the /// arguments (* * AR: 02/24: this is a bit funky * the combinator needs wp_g to be an F.restricted_t * * previously this was added as a refinement to wp_g * but now that we require the combinator to be typeable with use_eq_strict, that fails * * now, we can add it to the precondition of ibind (we not support Pure type for binds) * * and then the bind combinator and the layered effect typecheck * * but we can't use it, since the typechecker will now require a proof that * the continuation is a restricted_t, which fails *) let ibind a b s wp_f (wp_g: a -> wp_t s b) (f:irepr a s wp_f) (g : (x:a -> irepr b s (wp_g x))) : irepr b s (bind_wp wp_f wp_g) = let m_f = f () in let m_g = fun x -> g x () in fun () -> bind_wp_lem m_f m_g; assert (forall x. (wp_of *. m_g) x == wp_g x); assert (wp_f == wp_of m_f); assert ((wp_of *. m_g) `F.feq` wp_g); F.extensionality _ _ ((wp_of *. m_g)) wp_g; assert (F.on _ (wp_of *. m_g) == F.on _ wp_g); assume (F.on _ wp_g == wp_g); lem_on_comp wp_of m_g; assert (F.on _ (wp_of *. m_g) == (wp_of *. m_g)); bind_m m_f m_g /// Here are a couple of actions lifted into the indexed type
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
s: Type0 -> DijkstraStateMonad.irepr s s (DijkstraStateMonad.wp_of (DijkstraStateMonad.Get DijkstraStateMonad.Ret))
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "DijkstraStateMonad.Get", "DijkstraStateMonad.Ret", "DijkstraStateMonad.m", "FStar.FunctionalExtensionality.feq", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.irepr" ]
[]
false
false
false
true
false
let iget s : irepr s s (wp_of (Get Ret)) =
fun () -> Get Ret
false
DijkstraStateMonad.fst
DijkstraStateMonad.ireturn
val ireturn (a: Type) (x: a) (s: Type) : irepr a s (wp_return x)
val ireturn (a: Type) (x: a) (s: Type) : irepr a s (wp_return x)
let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 132, "start_col": 0, "start_line": 130 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
a: Type -> x: a -> s: Type0 -> DijkstraStateMonad.irepr a s (DijkstraStateMonad.wp_return x)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "DijkstraStateMonad.Ret", "DijkstraStateMonad.m", "FStar.FunctionalExtensionality.feq", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.wp_return", "DijkstraStateMonad.irepr" ]
[]
false
false
false
false
false
let ireturn (a: Type) (x: a) (s: Type) : irepr a s (wp_return x) =
fun () -> Ret x
false
Vale.Arch.HeapImpl.fsti
Vale.Arch.HeapImpl.heaplet_id
val heaplet_id : Type0
let heaplet_id = n:nat{n < 16}
{ "file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 16, "start_col": 0, "start_line": 16 }
module Vale.Arch.HeapImpl open FStar.Mul open Vale.Arch.HeapTypes_s module Map16 = Vale.Lib.Map16 (** Define abstract (or mostly abstract) types for use by Vale.X64.Decls.fsti. Note: the untrusted memory definitions are split among 3 modules: - Vale.Arch.HeapImpl - Vale.Arch.Heap - Vale.X64.Memory This splitting is done to avoid circular module dependencies. *)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Arch.HeapImpl.fsti" }
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
false
false
false
true
true
let heaplet_id =
n: nat{n < 16}
false
Vale.Arch.HeapImpl.fsti
Vale.Arch.HeapImpl.full_heap_taint
val full_heap_taint (vfh: vale_full_heap) : memTaint_t
val full_heap_taint (vfh: vale_full_heap) : memTaint_t
let full_heap_taint (vfh:vale_full_heap) : memTaint_t = vfh.vf_layout.vl_taint
{ "file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 48, "start_col": 7, "start_line": 47 }
module Vale.Arch.HeapImpl open FStar.Mul open Vale.Arch.HeapTypes_s module Map16 = Vale.Lib.Map16 (** Define abstract (or mostly abstract) types for use by Vale.X64.Decls.fsti. Note: the untrusted memory definitions are split among 3 modules: - Vale.Arch.HeapImpl - Vale.Arch.Heap - Vale.X64.Memory This splitting is done to avoid circular module dependencies. *) let heaplet_id = n:nat{n < 16} val buffer (t:base_typ) : Type0 type mutability = | Mutable | Immutable // Buffer information for heaplets noeq type buffer_info : Type0 = { bi_typ:base_typ; bi_buffer:buffer bi_typ; bi_heaplet:heaplet_id; bi_taint:taint; bi_mutable:mutability; } val vale_heap : Type u#1 val vale_heap_layout_inner : Type u#1 noeq type vale_heap_layout : Type u#1 = { vl_inner:vale_heap_layout_inner; vl_taint:memTaint_t; } let vale_heaplets = Map16.map16 vale_heap noeq type vale_full_heap = { vf_layout:vale_heap_layout; vf_heap:vale_heap; vf_heaplets:vale_heaplets; }
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Arch.HeapImpl.fsti" }
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
vfh: Vale.Arch.HeapImpl.vale_full_heap -> Vale.Arch.HeapTypes_s.memTaint_t
Prims.Tot
[ "total" ]
[]
[ "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.Arch.HeapTypes_s.memTaint_t" ]
[]
false
false
false
true
false
let full_heap_taint (vfh: vale_full_heap) : memTaint_t =
vfh.vf_layout.vl_taint
false
Vale.Arch.HeapImpl.fsti
Vale.Arch.HeapImpl.vale_heaplets
val vale_heaplets : Type
let vale_heaplets = Map16.map16 vale_heap
{ "file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 39, "start_col": 0, "start_line": 39 }
module Vale.Arch.HeapImpl open FStar.Mul open Vale.Arch.HeapTypes_s module Map16 = Vale.Lib.Map16 (** Define abstract (or mostly abstract) types for use by Vale.X64.Decls.fsti. Note: the untrusted memory definitions are split among 3 modules: - Vale.Arch.HeapImpl - Vale.Arch.Heap - Vale.X64.Memory This splitting is done to avoid circular module dependencies. *) let heaplet_id = n:nat{n < 16} val buffer (t:base_typ) : Type0 type mutability = | Mutable | Immutable // Buffer information for heaplets noeq type buffer_info : Type0 = { bi_typ:base_typ; bi_buffer:buffer bi_typ; bi_heaplet:heaplet_id; bi_taint:taint; bi_mutable:mutability; } val vale_heap : Type u#1 val vale_heap_layout_inner : Type u#1 noeq type vale_heap_layout : Type u#1 = { vl_inner:vale_heap_layout_inner; vl_taint:memTaint_t; }
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Arch.HeapImpl.fsti" }
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type
Prims.Tot
[ "total" ]
[]
[ "Vale.Lib.Map16.map16", "Vale.Arch.HeapImpl.vale_heap" ]
[]
false
false
false
true
true
let vale_heaplets =
Map16.map16 vale_heap
false
DijkstraStateMonad.fst
DijkstraStateMonad.bind_wp_lem
val bind_wp_lem (#a #b #s: _) (f: m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g))
val bind_wp_lem (#a #b #s: _) (f: m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g))
let bind_wp_lem (#a:_) (#b:_) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g)) = bind_wp_lem' f g
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 197, "start_col": 0, "start_line": 195 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x /// bind_wp: This is a bind for the WP type `wp_t` let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post)) /// Now things get a bit technical in the main proof of the bind case /// of the morphisms /// First, we define a domain-restricted version of function composition let ( *. ) #a #b #c (f:b -> c) (g:a -> b) : (a ^-> c) = F.on _ (fun x -> f (g x)) /// An prove a auxiliary lemma about it (that's needed for functional /// extensionality) let lem_on_comp #a #b #c (f:b -> c) (g:a -> b) : Lemma (F.on _ (f *. g) == f *. g) = () /// We also rely on eta being a provable equality /// AR: 05/11, eta is no longer provable, so admitting it let eta (a:Type) (b:Type) (f:a -> b) : Lemma (f == (fun x -> f x)) = admit() /// Now, here's the main lemma of property (b). /// stating at first using extensional equality let rec bind_wp_lem' (#a:Type u#aa) (#b:Type u#bb) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) `F.feq` bind_wp (wp_of f) (wp_of *. g)) = match f with | Ret x -> assert (bind_m f g == g x); assert_norm (wp_of #a #s (Ret x) `F.feq` (fun s0 post -> post (x, s0))); assert (wp_of (bind_m (Ret x) g) `F.feq` bind_wp (wp_of (Ret x)) (wp_of *. g)) by (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1))) | Put s k -> bind_wp_lem' k g; assert_norm (wp_put (bind_wp (wp_of k) (wp_of *. g)) s `F.feq` bind_wp (wp_put (wp_of k) s) (wp_of *. g)) | Get k -> let aux (x:s) : Lemma (ensures (wp_of (bind_m (k x) g) `F.feq` bind_wp (wp_of (k x)) (wp_of *. g))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
f: DijkstraStateMonad.m s a -> g: (_: a -> DijkstraStateMonad.m s b) -> FStar.Pervasives.Lemma (ensures DijkstraStateMonad.wp_of (DijkstraStateMonad.bind_m f g) == DijkstraStateMonad.bind_wp (DijkstraStateMonad.wp_of f) (DijkstraStateMonad.wp_of *. g))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "DijkstraStateMonad.m", "DijkstraStateMonad.bind_wp_lem'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "DijkstraStateMonad.wp_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.bind_m", "DijkstraStateMonad.bind_wp", "DijkstraStateMonad.op_Star_Dot", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let bind_wp_lem (#a #b #s: _) (f: m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) == bind_wp (wp_of f) (wp_of *. g)) =
bind_wp_lem' f g
false
DijkstraStateMonad.fst
DijkstraStateMonad.bind_wp_lem'
val bind_wp_lem' (#a: Type u#aa) (#b: Type u#bb) (#s: _) (f: m s a) (g: (a -> m s b)) : Lemma ((wp_of (bind_m f g)) `F.feq` (bind_wp (wp_of f) (wp_of *. g)))
val bind_wp_lem' (#a: Type u#aa) (#b: Type u#bb) (#s: _) (f: m s a) (g: (a -> m s b)) : Lemma ((wp_of (bind_m f g)) `F.feq` (bind_wp (wp_of f) (wp_of *. g)))
let rec bind_wp_lem' (#a:Type u#aa) (#b:Type u#bb) (#s:_) (f:m s a) (g: (a -> m s b)) : Lemma (wp_of (bind_m f g) `F.feq` bind_wp (wp_of f) (wp_of *. g)) = match f with | Ret x -> assert (bind_m f g == g x); assert_norm (wp_of #a #s (Ret x) `F.feq` (fun s0 post -> post (x, s0))); assert (wp_of (bind_m (Ret x) g) `F.feq` bind_wp (wp_of (Ret x)) (wp_of *. g)) by (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1))) | Put s k -> bind_wp_lem' k g; assert_norm (wp_put (bind_wp (wp_of k) (wp_of *. g)) s `F.feq` bind_wp (wp_put (wp_of k) s) (wp_of *. g)) | Get k -> let aux (x:s) : Lemma (ensures (wp_of (bind_m (k x) g) `F.feq` bind_wp (wp_of (k x)) (wp_of *. g))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0))
{ "file_name": "examples/layeredeffects/DijkstraStateMonad.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 192, "start_col": 0, "start_line": 157 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DijkstraStateMonad open FStar.FunctionalExtensionality module F = FStar.FunctionalExtensionality module T = FStar.Tactics.V2 /// This example illustrates how to derive a WP-indexed state monad /// from a free state monad, parametric in the type of the state /// `m s a`: A classic free state monad noeq type m (s:Type0) (a:Type) = | Ret : a -> m s a | Get : (s -> m s a) -> m s a | Put : x:s -> m s a -> m s a /// It's easy to sequentially compose terms in `m` let rec bind_m #s #a #b (x:m s a) (y: (a -> m s b)) : m s b = match x with | Ret x -> y x | Get k -> Get (fun s -> bind_m (k s) y) | Put s k -> Put s (bind_m k y) /// Now, we want to build an indexed version of m, where the index is /// a weakest precondition for the computation /// A postcondition is a predicate relating a result and final state let post_t (s:Type0) (a:Type) = a * s -> Type0 /// A precondition is a predicate on the initial state (we don't /// really use this type in what follows) let pre_t (s:Type) = s -> Type0 /// Although we usually write WPs as transformers from post-conditions /// to preconditions, I've swapped the order of arguments here since /// it makes some of the technicalities of the proof simpler. /// /// The main technicality that comes up is that WPs are essentially /// continuations and so our proofs are going to make use of /// functional extensionality to relate WPs /// /// So, notice that wp_t is a domain-restricited function from initial /// states `s`. See FStar.FunctionalExtensionality for more /// explanations, but it is only on these domain-restricted functions /// that that functional extensionality axiom is available let wp_t (s:Type0) (a:Type) = s ^-> (post_t s a -> Type0) /// Here's the WP of a Put action; /// (Notice that it has to be domain-restricted, that's the `F.on`) let wp_put #s #a (f: wp_t s a) : s -> wp_t s a = fun s -> F.on _ (fun s0 -> f s) /// The WP of return let wp_return #s #a (x:a) : wp_t s a = F.on _ (fun s0 post -> post (x, s0)) /// The WP of m is defined by recursion on the computation tree /// /// -- we need to explicitly invoke the library for well-founded /// since F*'s SMT automation does not encode that /// well-foundedness for function types automatically let rec wp_of #a #s (x:m s a) : wp_t s a = match x with | Ret v -> wp_return v | Get k -> F.on _ (fun s0 -> (wp_of (k s0)) s0) | Put s k -> wp_put (wp_of k) s /// We prove the soundness of the wp semantics by giving it a model in /// terms of F*'s pure computations let rec run (#a:_) (#s:_) (m:m s a) (s0:s) (post: post_t s a) : Pure (a * s) (requires wp_of m s0 post) (ensures post) = match m with | Ret x -> (x, s0) | Get k -> run (k s0) s0 post | Put s k -> run k s post /// Now we're going to package up this WP semantics into an effect in /// F* by building an WP-indexed computation type. We have to define: /// /// 1. a representation type /// 2. a return /// 3. a bind /// 4. a subsumption rule /// 5. a rule for conditionals /// 6. a way to lift F*'s native pure wp-indexed terms to the new effect /// /// We'll prove steps 1-3. And we'll define 4-6, but admitting their /// associated proofs. Essentially, in this small example, the /// representation I've chosen isn't really compatible with a /// meaningful subsumption rule (which is the essence of 4, 5, 6) /// /// The main work of doing steps 2 and 3 is to prove that that wp_of /// is a monad morphism from m to wp_t. i.e., we have to show that the /// return /// /// a. wp_of (return x) == wp_return x /// b. wp_of (bind f g) == wp_bind (wp_of f) (wp_of . g) /// /// `irepr`: The underlying representation of our computation type let irepr a s (wp: wp_t s a) = unit -> m:m s a { wp_of m `F.feq` wp } /// The WP of return is the return of the wp let ireturn (a:Type) (x:a) (s:Type) : irepr a s (wp_return x) = fun () -> Ret x /// bind_wp: This is a bind for the WP type `wp_t` let bind_wp #a #b #s (wp_f:wp_t s a) (wp_g: (a -> wp_t s b)) : wp_t s b = F.on _ (fun s0 post -> wp_f s0 (fun (x, s1) -> wp_g x s1 post)) /// Now things get a bit technical in the main proof of the bind case /// of the morphisms /// First, we define a domain-restricted version of function composition let ( *. ) #a #b #c (f:b -> c) (g:a -> b) : (a ^-> c) = F.on _ (fun x -> f (g x)) /// An prove a auxiliary lemma about it (that's needed for functional /// extensionality) let lem_on_comp #a #b #c (f:b -> c) (g:a -> b) : Lemma (F.on _ (f *. g) == f *. g) = () /// We also rely on eta being a provable equality /// AR: 05/11, eta is no longer provable, so admitting it let eta (a:Type) (b:Type) (f:a -> b) : Lemma (f == (fun x -> f x)) = admit() /// Now, here's the main lemma of property (b).
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "DijkstraStateMonad.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "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 } ]
{ "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" }
false
f: DijkstraStateMonad.m s a -> g: (_: a -> DijkstraStateMonad.m s b) -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.feq (DijkstraStateMonad.wp_of (DijkstraStateMonad.bind_m f g)) (DijkstraStateMonad.bind_wp (DijkstraStateMonad.wp_of f) (DijkstraStateMonad.wp_of *. g)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "DijkstraStateMonad.m", "FStar.Tactics.Effect.assert_by_tactic", "FStar.FunctionalExtensionality.feq", "DijkstraStateMonad.post_t", "DijkstraStateMonad.wp_of", "DijkstraStateMonad.bind_m", "DijkstraStateMonad.Ret", "DijkstraStateMonad.bind_wp", "DijkstraStateMonad.op_Star_Dot", "DijkstraStateMonad.wp_t", "Prims.unit", "FStar.Tactics.MApply.mapply", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.MApply.termable_term", "DijkstraStateMonad.eta", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.forall_intro", "FStar.Stubs.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "FStar.Pervasives.delta", "Prims.Nil", "FStar.Pervasives.assert_norm", "FStar.Pervasives.Native.Mktuple2", "Prims._assert", "Prims.eq2", "DijkstraStateMonad.wp_put", "DijkstraStateMonad.bind_wp_lem'", "FStar.FunctionalExtensionality.op_Hat_Subtraction_Greater", "FStar.FunctionalExtensionality.on", "DijkstraStateMonad.Get", "Prims.l_True", "Prims.squash", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat" ]
[ "recursion" ]
false
false
true
false
false
let rec bind_wp_lem' (#a: Type u#aa) (#b: Type u#bb) (#s: _) (f: m s a) (g: (a -> m s b)) : Lemma ((wp_of (bind_m f g)) `F.feq` (bind_wp (wp_of f) (wp_of *. g))) =
match f with | Ret x -> assert (bind_m f g == g x); assert_norm ((wp_of #a #s (Ret x)) `F.feq` (fun s0 post -> post (x, s0))); FStar.Tactics.Effect.assert_by_tactic ((wp_of (bind_m (Ret x) g)) `F.feq` (bind_wp (wp_of (Ret x)) (wp_of *. g))) (fun _ -> (); (T.norm [zeta; iota; delta]; let x = T.forall_intro () in T.mapply (quote (eta u#(max bb 1) u#1)))) | Put s k -> bind_wp_lem' k g; assert_norm ((wp_put (bind_wp (wp_of k) (wp_of *. g)) s) `F.feq` (bind_wp (wp_put (wp_of k) s) (wp_of *. g))) | Get k -> let aux (x: s) : Lemma (ensures ((wp_of (bind_m (k x) g)) `F.feq` (bind_wp (wp_of (k x)) (wp_of *. g)))) [SMTPat (k x)] = bind_wp_lem' (k x) g in assert_norm (wp_of (bind_m (Get k) g) == wp_of (Get (fun x -> bind_m (k x) g))); assert_norm (wp_of (Get (fun x -> bind_m (k x) g)) == F.on _ (fun s0 -> (wp_of (bind_m (k s0) g)) s0)); assert ((fun s0 -> (wp_of (bind_m (k s0) g)) s0) `F.feq` (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0)); assert_norm (bind_wp (wp_of (Get k)) (wp_of *. g) == bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g)); assert_norm (bind_wp (F.on _ (fun s0 -> wp_of (k s0) s0)) (wp_of *. g) == F.on _ (fun s0 -> bind_wp (wp_of (k s0)) (wp_of *. g) s0))
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.int_has_eq
[@@ FStar.Tactics.Typeclasses.tcinstance] val int_has_eq:deq int
[@@ FStar.Tactics.Typeclasses.tcinstance] val int_has_eq:deq int
instance int_has_eq : deq int = eq_instance_of_eqtype
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 29, "start_col": 0, "start_line": 29 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
FStar.Class.Eq.Raw.deq Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.eq_instance_of_eqtype", "Prims.int" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let int_has_eq:deq int =
eq_instance_of_eqtype
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.eq_instance_of_eqtype
val eq_instance_of_eqtype (#a: eqtype) : deq a
val eq_instance_of_eqtype (#a: eqtype) : deq a
let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) }
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 24, "start_col": 0, "start_line": 22 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
FStar.Class.Eq.Raw.deq a
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Class.Eq.Raw.Mkdeq", "Prims.op_Equality", "Prims.bool", "FStar.Class.Eq.Raw.deq" ]
[]
false
false
false
false
false
let eq_instance_of_eqtype (#a: eqtype) : deq a =
{ eq = (fun x y -> x = y) }
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.bool_has_eq
[@@ FStar.Tactics.Typeclasses.tcinstance] val bool_has_eq:deq bool
[@@ FStar.Tactics.Typeclasses.tcinstance] val bool_has_eq:deq bool
instance bool_has_eq : deq bool = eq_instance_of_eqtype
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
FStar.Class.Eq.Raw.deq Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.eq_instance_of_eqtype", "Prims.bool" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let bool_has_eq:deq bool =
eq_instance_of_eqtype
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.unit_has_eq
[@@ FStar.Tactics.Typeclasses.tcinstance] val unit_has_eq:deq unit
[@@ FStar.Tactics.Typeclasses.tcinstance] val unit_has_eq:deq unit
instance unit_has_eq : deq unit = eq_instance_of_eqtype
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
FStar.Class.Eq.Raw.deq Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.eq_instance_of_eqtype", "Prims.unit" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let unit_has_eq:deq unit =
eq_instance_of_eqtype
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.string_has_eq
[@@ FStar.Tactics.Typeclasses.tcinstance] val string_has_eq:deq string
[@@ FStar.Tactics.Typeclasses.tcinstance] val string_has_eq:deq string
instance string_has_eq : deq string = eq_instance_of_eqtype
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 32, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype instance unit_has_eq : deq unit = eq_instance_of_eqtype
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
FStar.Class.Eq.Raw.deq Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.eq_instance_of_eqtype", "Prims.string" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let string_has_eq:deq string =
eq_instance_of_eqtype
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.eq_option
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_option: deq 'a -> deq (option 'a)
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_option: deq 'a -> deq (option 'a)
instance eq_option (_ : deq 'a) : deq (option 'a) = { eq = (fun o1 o2 -> match o1, o2 with | None, None -> true | Some x, Some y -> eq x y | _, _ -> false); }
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 54, "start_col": 0, "start_line": 48 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype instance unit_has_eq : deq unit = eq_instance_of_eqtype instance bool_has_eq : deq bool = eq_instance_of_eqtype instance string_has_eq : deq string = eq_instance_of_eqtype let rec eqList #a (eq : a -> a -> bool) (xs ys : list a) : Tot bool = match xs, ys with | [], [] -> true | x::xs, y::ys -> eq x y && eqList eq xs ys | _, _ -> false instance eq_list (_ : deq 'a) : deq (list 'a) = { eq = eqList eq; } instance eq_pair (_ : deq 'a) (_ : deq 'b) : deq ('a * 'b) = { eq = (fun (a,b) (c,d) -> eq a c && eq b d) }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
_: FStar.Class.Eq.Raw.deq 'a -> FStar.Class.Eq.Raw.deq (FStar.Pervasives.Native.option 'a)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.deq", "FStar.Class.Eq.Raw.Mkdeq", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Class.Eq.Raw.eq", "Prims.bool" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let eq_option (_: deq 'a) : deq (option 'a) =
{ eq = (fun o1 o2 -> match o1, o2 with | None, None -> true | Some x, Some y -> eq x y | _, _ -> false) }
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.eq_list
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_list: deq 'a -> deq (list 'a)
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_list: deq 'a -> deq (list 'a)
instance eq_list (_ : deq 'a) : deq (list 'a) = { eq = eqList eq; }
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 42, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype instance unit_has_eq : deq unit = eq_instance_of_eqtype instance bool_has_eq : deq bool = eq_instance_of_eqtype instance string_has_eq : deq string = eq_instance_of_eqtype let rec eqList #a (eq : a -> a -> bool) (xs ys : list a) : Tot bool = match xs, ys with | [], [] -> true | x::xs, y::ys -> eq x y && eqList eq xs ys | _, _ -> false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
_: FStar.Class.Eq.Raw.deq 'a -> FStar.Class.Eq.Raw.deq (Prims.list 'a)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.deq", "FStar.Class.Eq.Raw.Mkdeq", "Prims.list", "FStar.Class.Eq.Raw.eqList", "FStar.Class.Eq.Raw.eq" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let eq_list (_: deq 'a) : deq (list 'a) =
{ eq = eqList eq }
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.eq_pair
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b)
[@@ FStar.Tactics.Typeclasses.tcinstance] val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b)
instance eq_pair (_ : deq 'a) (_ : deq 'b) : deq ('a * 'b) = { eq = (fun (a,b) (c,d) -> eq a c && eq b d) }
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 46, "start_col": 0, "start_line": 44 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype instance unit_has_eq : deq unit = eq_instance_of_eqtype instance bool_has_eq : deq bool = eq_instance_of_eqtype instance string_has_eq : deq string = eq_instance_of_eqtype let rec eqList #a (eq : a -> a -> bool) (xs ys : list a) : Tot bool = match xs, ys with | [], [] -> true | x::xs, y::ys -> eq x y && eqList eq xs ys | _, _ -> false instance eq_list (_ : deq 'a) : deq (list 'a) = { eq = eqList eq; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
_: FStar.Class.Eq.Raw.deq 'a -> _: FStar.Class.Eq.Raw.deq 'b -> FStar.Class.Eq.Raw.deq ('a * 'b)
Prims.Tot
[ "total" ]
[]
[ "FStar.Class.Eq.Raw.deq", "FStar.Class.Eq.Raw.Mkdeq", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.op_AmpAmp", "FStar.Class.Eq.Raw.eq", "Prims.bool" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let eq_pair (_: deq 'a) (_: deq 'b) : deq ('a * 'b) =
{ eq = (fun (a, b) (c, d) -> eq a c && eq b d) }
false
Hacl.Impl.FFDHE.Constants.fst
Hacl.Impl.FFDHE.Constants.ffdhe_p8192
val ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x}
val ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x}
let ffdhe_p8192 :x:glbuffer pub_uint8 1024ul{witnessed x S.ffdhe_p8192 /\ recallable x} = createL_global S.list_ffdhe_p8192
{ "file_name": "code/ffdhe/Hacl.Impl.FFDHE.Constants.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 31, "start_col": 0, "start_line": 30 }
module Hacl.Impl.FFDHE.Constants open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Spec.FFDHE #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let ffdhe_g2 :x:glbuffer pub_uint8 1ul{witnessed x S.ffdhe_g2 /\ recallable x} = createL_global S.list_ffdhe_g2 let ffdhe_p2048 :x:glbuffer pub_uint8 256ul{witnessed x S.ffdhe_p2048 /\ recallable x} = createL_global S.list_ffdhe_p2048 let ffdhe_p3072 :x:glbuffer pub_uint8 384ul{witnessed x S.ffdhe_p3072 /\ recallable x} = createL_global S.list_ffdhe_p3072 let ffdhe_p4096 :x:glbuffer pub_uint8 512ul{witnessed x S.ffdhe_p4096 /\ recallable x} = createL_global S.list_ffdhe_p4096 let ffdhe_p6144 :x:glbuffer pub_uint8 768ul{witnessed x S.ffdhe_p6144 /\ recallable x} = createL_global S.list_ffdhe_p6144
{ "checked_file": "/", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.FFDHE.Constants.fst" }
[ { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "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": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.FFDHE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.FFDHE", "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 } ]
{ "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" }
false
x: (c: Lib.Buffer.lbuffer_t Lib.Buffer.CONST (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB) (1024ul <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE}) {Lib.Buffer.witnessed x Spec.FFDHE.ffdhe_p8192 /\ Lib.Buffer.recallable x}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.PUB", "Spec.FFDHE.list_ffdhe_p8192", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length" ]
[]
false
false
false
false
false
let ffdhe_p8192:x: glbuffer pub_uint8 1024ul {witnessed x S.ffdhe_p8192 /\ recallable x} =
createL_global S.list_ffdhe_p8192
false
FStar.Class.Eq.Raw.fst
FStar.Class.Eq.Raw.eqList
val eqList (#a: _) (eq: (a -> a -> bool)) (xs ys: list a) : Tot bool
val eqList (#a: _) (eq: (a -> a -> bool)) (xs ys: list a) : Tot bool
let rec eqList #a (eq : a -> a -> bool) (xs ys : list a) : Tot bool = match xs, ys with | [], [] -> true | x::xs, y::ys -> eq x y && eqList eq xs ys | _, _ -> false
{ "file_name": "ulib/FStar.Class.Eq.Raw.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 38, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Class.Eq.Raw class deq a = { eq : a -> a -> bool; } let eq_instance_of_eqtype (#a:eqtype) : deq a = { eq = (fun x y -> x = y) } // FIXME: It would be easier to have a single eqtype instance, // but resolution will sometimes use for any type, even though // it should not. instance int_has_eq : deq int = eq_instance_of_eqtype instance unit_has_eq : deq unit = eq_instance_of_eqtype instance bool_has_eq : deq bool = eq_instance_of_eqtype instance string_has_eq : deq string = eq_instance_of_eqtype
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Class.Eq.Raw.fst" }
[ { "abbrev": false, "full_module": "FStar.Class.Eq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Class.Eq", "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 } ]
{ "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" }
false
eq: (_: a -> _: a -> Prims.bool) -> xs: Prims.list a -> ys: Prims.list a -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "Prims.op_AmpAmp", "FStar.Class.Eq.Raw.eqList" ]
[ "recursion" ]
false
false
false
true
false
let rec eqList #a (eq: (a -> a -> bool)) (xs: list a) (ys: list a) : Tot bool =
match xs, ys with | [], [] -> true | x :: xs, y :: ys -> eq x y && eqList eq xs ys | _, _ -> false
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.serialize_u16'
val serialize_u16':bare_serializer U16.t
val serialize_u16':bare_serializer U16.t
let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 34, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
MiniParse.Spec.Base.bare_serializer FStar.UInt16.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "FStar.UInt8.t", "FStar.Seq.Base.append", "MiniParse.Spec.Base.byte", "FStar.Seq.Base.create", "MiniParse.Spec.Base.bytes", "FStar.Pervasives.Native.tuple2", "MiniParse.Spec.Int.Aux.encode_u16" ]
[]
false
false
false
true
false
let serialize_u16':bare_serializer U16.t =
fun x -> let lo, hi = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.bounded_u16_eq
val bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool)
val bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool)
let bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool) = op_Equality
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 117, "start_col": 0, "start_line": 116 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us) let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t) let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 = if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred) let rec forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound) = if bound = 0 then () else if bound > 65536 then let x' : bounded_u16 (bound - 1) = x <: U16.t in forall_bounded_u16_elim (bound - 1) (pred_large_bound bound pred) x' else if x = 0us then () else forall_bounded_u16_elim (bound - 1) (pred_pre bound pred) (x `U16.sub` 1us)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
b: Prims.nat -> _: MiniParse.Spec.Int.bounded_u16 b -> _: MiniParse.Spec.Int.bounded_u16 b -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "MiniParse.Spec.Int.bounded_u16", "Prims.bool" ]
[]
false
false
false
false
false
let bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool) =
op_Equality
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.parse_u8
val parse_u8:parser_spec U8.t
val parse_u8:parser_spec U8.t
let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 97, "end_line": 23, "start_col": 0, "start_line": 23 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
MiniParse.Spec.Base.parser_spec FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.Combinators.make_total_constant_size_parser", "FStar.UInt8.t", "MiniParse.Spec.Base.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "MiniParse.Spec.Base.byte", "FStar.Seq.Base.index" ]
[]
false
false
false
true
false
let parse_u8:parser_spec U8.t =
make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.serialize_u8
val serialize_u8:serializer_spec parse_u8
val serialize_u8:serializer_spec parse_u8
let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 25, "start_col": 0, "start_line": 25 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
MiniParse.Spec.Base.serializer_spec MiniParse.Spec.Int.parse_u8
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.Base.Serializer", "MiniParse.Spec.Base.byte", "MiniParse.Spec.Int.parse_u8", "FStar.Seq.Base.create", "MiniParse.Spec.Base.bytes" ]
[]
false
false
false
true
false
let serialize_u8:serializer_spec parse_u8 =
Serializer (fun x -> Seq.create 1 x)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.parse_u16
val parse_u16:parser_spec U16.t
val parse_u16:parser_spec U16.t
let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 89, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
MiniParse.Spec.Base.parser_spec FStar.UInt16.t
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.Combinators.make_total_constant_size_parser", "FStar.UInt16.t", "MiniParse.Spec.Int.parse_u16_aux" ]
[]
false
false
false
true
false
let parse_u16:parser_spec U16.t =
make_total_constant_size_parser 2 U16.t parse_u16_aux
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.mk_u16
val mk_u16 (n: nat{n < 65536}) : Tot U16.t
val mk_u16 (n: nat{n < 65536}) : Tot U16.t
let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 43, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
n: Prims.nat{n < 65536} -> FStar.UInt16.t
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt16.uint_to_t", "FStar.UInt16.t" ]
[]
false
false
false
false
false
let mk_u16 (n: nat{n < 65536}) : Tot U16.t =
U16.uint_to_t n
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.parse_u16_aux
val parse_u16_aux:(f: (s: bytes{Seq.length s == 2} -> GTot U16.t){make_total_constant_size_parser_precond 2 U16.t f})
val parse_u16_aux:(f: (s: bytes{Seq.length s == 2} -> GTot U16.t){make_total_constant_size_parser_precond 2 U16.t f})
let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 28, "start_col": 0, "start_line": 27 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
f: (s: MiniParse.Spec.Base.bytes{FStar.Seq.Base.length s == 2} -> Prims.GTot FStar.UInt16.t) {MiniParse.Spec.Combinators.make_total_constant_size_parser_precond 2 FStar.UInt16.t f}
Prims.GTot
[ "sometrivial" ]
[]
[ "MiniParse.Spec.Base.bytes", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "MiniParse.Spec.Base.byte", "MiniParse.Spec.Int.Aux.decode_u16", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt8.t", "FStar.Seq.Base.index", "FStar.UInt16.t" ]
[]
false
false
false
false
false
let parse_u16_aux:(f: (s: bytes{Seq.length s == 2} -> GTot U16.t){make_total_constant_size_parser_precond 2 U16.t f}) =
fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.bounded_u16
val bounded_u16 (b: nat) : Tot eqtype
val bounded_u16 (b: nat) : Tot eqtype
let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } )
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 67, "end_line": 46, "start_col": 0, "start_line": 46 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
b: Prims.nat -> Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt16.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt16.v", "Prims.eqtype" ]
[]
false
false
false
true
false
let bounded_u16 (b: nat) : Tot eqtype =
(x: U16.t{U16.v x < b})
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.pred_pre
val pred_pre (bound: nat{bound > 0 /\ bound <= 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0
val pred_pre (bound: nat{bound > 0 /\ bound <= 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0
let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 75, "start_col": 0, "start_line": 70 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
bound: Prims.nat{bound > 0 /\ bound <= 65536} -> pred: (_: MiniParse.Spec.Int.bounded_u16 bound -> Prims.GTot Type0) -> x: MiniParse.Spec.Int.bounded_u16 (bound - 1) -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "MiniParse.Spec.Int.bounded_u16", "Prims.op_Subtraction", "FStar.UInt16.add", "FStar.UInt16.__uint_to_t" ]
[]
false
false
false
false
true
let pred_pre (bound: nat{bound > 0 /\ bound <= 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0 =
pred (x `U16.add` 1us)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.serialize_bounded_u16
val serialize_bounded_u16 (b: nat) : Tot (serializer_spec (parse_bounded_u16 b))
val serialize_bounded_u16 (b: nat) : Tot (serializer_spec (parse_bounded_u16 b))
let serialize_bounded_u16 (b: nat) : Tot (serializer_spec (parse_bounded_u16 b)) = serialize_synth (serialize_filter serialize_u16 (fun x -> U16.v x < b)) (fun x -> x <: bounded_u16 b) (fun x -> x) ()
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 130, "start_col": 0, "start_line": 125 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us) let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t) let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 = if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred) let rec forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound) = if bound = 0 then () else if bound > 65536 then let x' : bounded_u16 (bound - 1) = x <: U16.t in forall_bounded_u16_elim (bound - 1) (pred_large_bound bound pred) x' else if x = 0us then () else forall_bounded_u16_elim (bound - 1) (pred_pre bound pred) (x `U16.sub` 1us) inline_for_extraction let bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool) = op_Equality let parse_bounded_u16 (b: nat) : Tot (parser_spec (bounded_u16 b)) = parse_synth (parse_filter parse_u16 (fun x -> U16.v x < b)) (fun x -> x <: bounded_u16 b) (fun x -> x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
b: Prims.nat -> MiniParse.Spec.Base.serializer_spec (MiniParse.Spec.Int.parse_bounded_u16 b)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "MiniParse.Spec.Combinators.serialize_synth", "FStar.UInt16.t", "Prims.eq2", "Prims.bool", "Prims.op_LessThan", "FStar.UInt16.v", "MiniParse.Spec.Int.bounded_u16", "MiniParse.Spec.Combinators.parse_filter", "MiniParse.Spec.Int.parse_u16", "MiniParse.Spec.Combinators.serialize_filter", "MiniParse.Spec.Int.serialize_u16", "MiniParse.Spec.Base.serializer_spec", "MiniParse.Spec.Int.parse_bounded_u16" ]
[]
false
false
false
false
false
let serialize_bounded_u16 (b: nat) : Tot (serializer_spec (parse_bounded_u16 b)) =
serialize_synth (serialize_filter serialize_u16 (fun x -> U16.v x < b)) (fun x -> x <: bounded_u16 b) (fun x -> x) ()
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.forall_bounded_u16
val forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0
val forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0
let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 = if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 94, "start_col": 0, "start_line": 84 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us) let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
bound: Prims.nat -> pred: (_: MiniParse.Spec.Int.bounded_u16 bound -> Prims.GTot Type0) -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "MiniParse.Spec.Int.bounded_u16", "Prims.op_Equality", "Prims.int", "Prims.l_True", "Prims.bool", "Prims.op_GreaterThan", "MiniParse.Spec.Int.forall_bounded_u16", "Prims.op_Subtraction", "MiniParse.Spec.Int.pred_large_bound", "Prims.l_and", "FStar.UInt16.__uint_to_t", "MiniParse.Spec.Int.pred_pre" ]
[ "recursion" ]
false
false
false
false
true
let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 =
if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.serialize_u16
val serialize_u16:serializer_spec parse_u16
val serialize_u16:serializer_spec parse_u16
let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16'
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 38, "start_col": 0, "start_line": 38 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
MiniParse.Spec.Base.serializer_spec MiniParse.Spec.Int.parse_u16
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.Base.Serializer", "FStar.UInt16.t", "MiniParse.Spec.Int.parse_u16", "MiniParse.Spec.Int.serialize_u16'" ]
[]
false
false
false
true
false
let serialize_u16:serializer_spec parse_u16 =
Serializer serialize_u16'
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.pred_large_bound
val pred_large_bound (bound: nat{bound > 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0
val pred_large_bound (bound: nat{bound > 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0
let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 82, "start_col": 0, "start_line": 77 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
bound: Prims.nat{bound > 65536} -> pred: (_: MiniParse.Spec.Int.bounded_u16 bound -> Prims.GTot Type0) -> x: MiniParse.Spec.Int.bounded_u16 (bound - 1) -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_GreaterThan", "MiniParse.Spec.Int.bounded_u16", "Prims.op_Subtraction", "FStar.UInt16.t" ]
[]
false
false
false
false
true
let pred_large_bound (bound: nat{bound > 65536}) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 (bound - 1)) : GTot Type0 =
pred (x <: U16.t)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.forall_bounded_u16_elim
val forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound)
val forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound)
let rec forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound) = if bound = 0 then () else if bound > 65536 then let x' : bounded_u16 (bound - 1) = x <: U16.t in forall_bounded_u16_elim (bound - 1) (pred_large_bound bound pred) x' else if x = 0us then () else forall_bounded_u16_elim (bound - 1) (pred_pre bound pred) (x `U16.sub` 1us)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 79, "end_line": 113, "start_col": 0, "start_line": 96 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us) let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t) let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 = if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
bound: Prims.nat -> pred: (_: MiniParse.Spec.Int.bounded_u16 bound -> Prims.GTot Type0) -> x: MiniParse.Spec.Int.bounded_u16 bound -> FStar.Pervasives.Lemma (requires MiniParse.Spec.Int.forall_bounded_u16 bound pred) (ensures pred x) (decreases bound)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.nat", "MiniParse.Spec.Int.bounded_u16", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_GreaterThan", "MiniParse.Spec.Int.forall_bounded_u16_elim", "Prims.op_Subtraction", "MiniParse.Spec.Int.pred_large_bound", "FStar.UInt16.t", "FStar.UInt16.__uint_to_t", "MiniParse.Spec.Int.pred_pre", "FStar.UInt16.sub", "Prims.unit", "MiniParse.Spec.Int.forall_bounded_u16", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound) =
if bound = 0 then () else if bound > 65536 then let x':bounded_u16 (bound - 1) = x <: U16.t in forall_bounded_u16_elim (bound - 1) (pred_large_bound bound pred) x' else if x = 0us then () else forall_bounded_u16_elim (bound - 1) (pred_pre bound pred) (x `U16.sub` 1us)
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.map_u16_to_bounded_u16
val map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a -> Tot (squash (U16.v (f x) < bound)))) (a': Type) (bound': nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound')
val map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a -> Tot (squash (U16.v (f x) < bound)))) (a': Type) (bound': nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound')
let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y'
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 4, "end_line": 68, "start_col": 0, "start_line": 53 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
a: Type -> bound: Prims.nat -> f: (_: a -> FStar.UInt16.t) -> g: (x: a -> Prims.squash (FStar.UInt16.v (f x) < bound)) -> a': Type -> bound': Prims.nat -> u1: Prims.squash (a == a') -> u2: Prims.squash (bound == bound') -> MiniParse.Spec.Int.bounded_fun a' bound'
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt16.t", "Prims.squash", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt16.v", "Prims.eq2", "MiniParse.Spec.Int.bounded_u16", "MiniParse.Spec.Int.bounded_fun" ]
[]
false
false
false
false
false
let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a -> Tot (squash (U16.v (f x) < bound)))) (a': Type) (bound': nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') =
fun x -> [@@ inline_let ]let _ = g x in [@@ inline_let ]let y':bounded_u16 bound = f x in y'
false
MiniParse.Spec.Int.fst
MiniParse.Spec.Int.parse_bounded_u16
val parse_bounded_u16 (b: nat) : Tot (parser_spec (bounded_u16 b))
val parse_bounded_u16 (b: nat) : Tot (parser_spec (bounded_u16 b))
let parse_bounded_u16 (b: nat) : Tot (parser_spec (bounded_u16 b)) = parse_synth (parse_filter parse_u16 (fun x -> U16.v x < b)) (fun x -> x <: bounded_u16 b) (fun x -> x)
{ "file_name": "examples/miniparse/MiniParse.Spec.Int.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 123, "start_col": 0, "start_line": 119 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParse.Spec.Int include MiniParse.Spec.Combinators module U8 = FStar.UInt8 module U16 = FStar.UInt16 module Aux = MiniParse.Spec.Int.Aux let parse_u8 : parser_spec U8.t = make_total_constant_size_parser 1 U8.t (fun x -> Seq.index x 0) let serialize_u8 : serializer_spec parse_u8 = Serializer (fun x -> Seq.create 1 x) let parse_u16_aux : (f: ((s: bytes { Seq.length s == 2 } ) -> GTot U16.t) { make_total_constant_size_parser_precond 2 U16.t f } ) = fun x -> Aux.decode_u16 (Seq.index x 0, Seq.index x 1) let parse_u16 : parser_spec U16.t = make_total_constant_size_parser 2 U16.t parse_u16_aux let serialize_u16' : bare_serializer U16.t = fun x -> let (lo, hi) = Aux.encode_u16 x in Seq.append (Seq.create 1 lo) (Seq.create 1 hi) #set-options "--z3rlimit 16" let serialize_u16 : serializer_spec parse_u16 = Serializer serialize_u16' #reset-options inline_for_extraction let mk_u16 (n: nat { n < 65536 } ) : Tot U16.t = U16.uint_to_t n inline_for_extraction let bounded_u16 (b: nat) : Tot eqtype = (x: U16.t { U16.v x < b } ) inline_for_extraction let bounded_fun (a: Type) (b: nat) : Tot Type = a -> Tot (bounded_u16 b) inline_for_extraction let map_u16_to_bounded_u16 (a: Type) (bound: nat) (f: (a -> Tot U16.t)) (g: (x: a) -> Tot (squash (U16.v (f x) < bound))) (a' : Type) (bound' : nat) (u1: squash (a == a')) (u2: squash (bound == bound')) : Tot (bounded_fun a' bound') = fun x -> [@@inline_let] let _ = g x in [@@inline_let] let y' : bounded_u16 bound = f x in y' let pred_pre (bound: nat { bound > 0 /\ bound <= 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x `U16.add` 1us) let pred_large_bound (bound: nat { bound > 65536 } ) (pred: bounded_u16 bound -> GTot Type0) (x: bounded_u16 (bound - 1)) : GTot Type0 = pred (x <: U16.t) let rec forall_bounded_u16 (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) : GTot Type0 = if bound = 0 then True else if bound > 65536 then forall_bounded_u16 (bound - 1) (pred_large_bound bound pred) else pred 0us /\ forall_bounded_u16 (bound - 1) (pred_pre bound pred) let rec forall_bounded_u16_elim (bound: nat) (pred: (bounded_u16 bound -> GTot Type0)) (x: bounded_u16 bound) : Lemma (requires (forall_bounded_u16 bound pred)) (ensures (pred x)) (decreases bound) = if bound = 0 then () else if bound > 65536 then let x' : bounded_u16 (bound - 1) = x <: U16.t in forall_bounded_u16_elim (bound - 1) (pred_large_bound bound pred) x' else if x = 0us then () else forall_bounded_u16_elim (bound - 1) (pred_pre bound pred) (x `U16.sub` 1us) inline_for_extraction let bounded_u16_eq (b: nat) : Tot (bounded_u16 b -> bounded_u16 b -> Tot bool) = op_Equality
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.Int.Aux.fst.checked", "MiniParse.Spec.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParse.Spec.Int.fst" }
[ { "abbrev": true, "full_module": "MiniParse.Spec.Int.Aux", "short_module": "Aux" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "MiniParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "MiniParse.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 } ]
{ "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" }
false
b: Prims.nat -> MiniParse.Spec.Base.parser_spec (MiniParse.Spec.Int.bounded_u16 b)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "MiniParse.Spec.Combinators.parse_synth", "FStar.UInt16.t", "Prims.eq2", "Prims.bool", "Prims.op_LessThan", "FStar.UInt16.v", "MiniParse.Spec.Int.bounded_u16", "MiniParse.Spec.Combinators.parse_filter", "MiniParse.Spec.Int.parse_u16", "MiniParse.Spec.Base.parser_spec" ]
[]
false
false
false
false
false
let parse_bounded_u16 (b: nat) : Tot (parser_spec (bounded_u16 b)) =
parse_synth (parse_filter parse_u16 (fun x -> U16.v x < b)) (fun x -> x <: bounded_u16 b) (fun x -> x)
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.product
val product : l1: Prims.list a -> l2: Prims.list b -> Prims.list (a * b)
let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 31, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
l1: Prims.list a -> l2: Prims.list b -> Prims.list (a * b)
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "FStar.List.Tot.Base.concatMap", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.Mktuple2" ]
[]
false
false
false
true
false
let product #a #b (l1: list a) (l2: list b) =
List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.bind
val bind : x: Prims.squash _ -> f: (_: _ -> Prims.GTot (Prims.squash _)) -> Prims.squash _
let bind = FStar.Squash.bind_squash
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 97, "start_col": 0, "start_line": 97 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: Prims.squash _ -> f: (_: _ -> Prims.GTot (Prims.squash _)) -> Prims.squash _
Prims.Tot
[ "total" ]
[]
[ "FStar.Squash.bind_squash", "Prims.squash" ]
[]
false
false
true
false
false
let bind =
FStar.Squash.bind_squash
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.pairs_with_sum
val pairs_with_sum (n: nat) : list (prod_with_sum n)
val pairs_with_sum (n: nat) : list (prod_with_sum n)
let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 28, "start_col": 0, "start_line": 27 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
n: Prims.nat -> Prims.list (BinaryTreesEnumeration.prod_with_sum n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "BinaryTreesEnumeration.pairs_with_sum'", "Prims.list", "BinaryTreesEnumeration.prod_with_sum" ]
[]
false
false
false
false
false
let pairs_with_sum (n: nat) : list (prod_with_sum n) =
pairs_with_sum' n 0
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.return
val return : x: _ -> Prims.squash _
let return = FStar.Squash.return_squash
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 98, "start_col": 0, "start_line": 98 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: _ -> Prims.squash _
Prims.Tot
[ "total" ]
[]
[ "FStar.Squash.return_squash", "Prims.squash" ]
[]
false
false
true
true
false
let return =
FStar.Squash.return_squash
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_append
val memP_append (#a: _) (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12)))))
val memP_append (#a: _) (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12)))))
let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 135, "start_col": 0, "start_line": 131 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l ==> (exists (l12: (Prims.list a * Prims.list a)). l == FStar.Pervasives.Native.fst l12 @ x :: FStar.Pervasives.Native.snd l12))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "FStar.Classical.move_requires", "FStar.List.Tot.Base.memP", "Prims.l_Exists", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "FStar.List.Tot.Base.op_At", "FStar.Pervasives.Native.fst", "Prims.Cons", "FStar.Pervasives.Native.snd", "BinaryTreesEnumeration.memP_append_aux", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) =
FStar.Classical.move_requires (memP_append_aux x) l
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.trees_of_size
val trees_of_size (s: nat) : list (bt_with_size s)
val trees_of_size (s: nat) : list (bt_with_size s)
let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 60, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
s: Prims.nat -> Prims.list (BinaryTreesEnumeration.bt_with_size s)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.Cons", "BinaryTreesEnumeration.bt_with_size", "BinaryTreesEnumeration.Leaf", "Prims.Nil", "Prims.bool", "FStar.List.Tot.Base.concatMap", "BinaryTreesEnumeration.prod_with_sum", "Prims.op_Subtraction", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple2", "BinaryTreesEnumeration.Branch", "FStar.Pervasives.Native.Mktuple2", "BinaryTreesEnumeration.bin_tree", "BinaryTreesEnumeration.product", "BinaryTreesEnumeration.trees_of_size", "Prims.list", "BinaryTreesEnumeration.pairs_with_sum" ]
[ "recursion" ]
false
false
false
false
false
let rec trees_of_size (s: nat) : list (bt_with_size s) =
if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.concatMap_flatten_map
val concatMap_flatten_map (#a #b: _) (f: (a -> list b)) (l: _) : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l))
val concatMap_flatten_map (#a #b: _) (f: (a -> list b)) (l: _) : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l))
let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 70, "start_col": 0, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
f: (_: a -> Prims.list b) -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.concatMap f l == FStar.List.Tot.Base.flatten (FStar.List.Tot.Base.map f l) )
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "BinaryTreesEnumeration.concatMap_flatten_map", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.concatMap", "FStar.List.Tot.Base.flatten", "FStar.List.Tot.Base.map", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec concatMap_flatten_map #a #b (f: (a -> list b)) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) =
match l with | [] -> () | h :: t -> concatMap_flatten_map f t
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.pure_as_squash
val pure_as_squash (#a: Type) (#p #q: _) ($f: (x: a -> Lemma (requires (p x)) (ensures (q x)))) (x: a{p x}) : squash (q x)
val pure_as_squash (#a: Type) (#p #q: _) ($f: (x: a -> Lemma (requires (p x)) (ensures (q x)))) (x: a{p x}) : squash (q x)
let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 105, "start_col": 0, "start_line": 99 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
$f: (x: a -> FStar.Pervasives.Lemma (requires p x) (ensures q x)) -> x: a{p x} -> Prims.squash (q x)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let pure_as_squash (#a: Type) (#p #q: _) ($f: (x: a -> Lemma (requires (p x)) (ensures (q x)))) (x: a{p x}) : squash (q x) =
f x
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.flatten_app
val flatten_app (#a: _) (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2)
val flatten_app (#a: _) (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2)
let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2)
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 143, "start_col": 0, "start_line": 138 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
l1: Prims.list (Prims.list a) -> l2: Prims.list (Prims.list a) -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.flatten (l1 @ l2) == FStar.List.Tot.Base.flatten l1 @ FStar.List.Tot.Base.flatten l2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "FStar.List.Tot.Properties.append_assoc", "FStar.List.Tot.Base.flatten", "Prims.unit", "BinaryTreesEnumeration.flatten_app", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.op_At", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec flatten_app #a (l1: list (list a)) (l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) =
match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2)
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_concatMap_intro
val memP_concatMap_intro (#a #b: _) (x: a) (y: b) (f: (a -> list b)) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l))
val memP_concatMap_intro (#a #b: _) (x: a) (y: b) (f: (a -> list b)) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l))
let memP_concatMap_intro #a #b (x: a) (y: b) (f:a -> list b) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l)) = concatMap_flatten_map f l; memP_map_intro f x l; memP_flatten_intro y (f x) (List.Tot.map f l)
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 228, "start_col": 0, "start_line": 222 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2 (*> * Should this be in the stdlib? *) let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2 (*> * What's the right way to prove this? The code below is messy because… - … it repeats types all over the place. Is there a way to get a bit more inference? - … it manages a context explicitly, using calls to [arrow_to_impl] to get concrete references to proofs. These references (as well as the calls to [impl_to_arrow] and [bind_squash]) are used to construct the explicit proof that exist_elim asks for (without the [arrow_to_impl]s I can only prove [… ==> exists …], not [exists …]. What's the right way to do this? - … it lists arguments to each [memP_app] explicitly (in Coq I'd use apply, and it'd pick the right arguments by unifying with the goal). Is there a way around this? - … it's slow (multiple seconds), although the proof seems entirely explicit. *) let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) = FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let (l1, l2) = l12 in let (ls1, ls2) = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2)))))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> y: b -> f: (_: a -> Prims.list b) -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l ==> FStar.List.Tot.Base.memP y (f x) ==> FStar.List.Tot.Base.memP y (FStar.List.Tot.Base.concatMap f l))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "BinaryTreesEnumeration.memP_flatten_intro", "FStar.List.Tot.Base.map", "Prims.unit", "FStar.List.Tot.Properties.memP_map_intro", "BinaryTreesEnumeration.concatMap_flatten_map", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.concatMap", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let memP_concatMap_intro #a #b (x: a) (y: b) (f: (a -> list b)) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l)) =
concatMap_flatten_map f l; memP_map_intro f x l; memP_flatten_intro y (f x) (List.Tot.map f l)
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_append_aux
val memP_append_aux (#a: _) (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12))
val memP_append_aux (#a: _) (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12))
let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 129, "start_col": 0, "start_line": 106 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> l: Prims.list a -> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.memP x l) (ensures exists (l12: (Prims.list a * Prims.list a)). l == FStar.Pervasives.Native.fst l12 @ x :: FStar.Pervasives.Native.snd l12)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "FStar.Squash.give_proof", "Prims.squash", "BinaryTreesEnumeration.bind", "Prims.sum", "Prims.eq2", "FStar.List.Tot.Base.memP", "FStar.Squash.join_squash", "Prims._assert", "FStar.List.Tot.Base.op_At", "FStar.Pervasives.Native.fst", "Prims.Cons", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Classical.exists_elim", "BinaryTreesEnumeration.pure_as_squash", "Prims.l_or", "Prims.precedes", "Prims.l_and", "Prims.op_Equals_Equals_Equals", "Prims.l_Exists", "BinaryTreesEnumeration.memP_append_aux", "Prims.logical", "Prims.unit", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) =
let goal = exists l12. l == fst l12 @ x :: snd l12 in let x:squash goal = match l with | [] -> () | h :: t -> let pf:squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h :: fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) in FStar.Squash.give_proof x
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_app_intro_l
val memP_app_intro_l (#a x: _) (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2))
val memP_app_intro_l (#a x: _) (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2))
let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 150, "start_col": 0, "start_line": 146 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l1 ==> FStar.List.Tot.Base.memP x (l1 @ l2))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "BinaryTreesEnumeration.memP_app_intro_l", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.op_At", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec memP_app_intro_l #a x (l1: list a) (l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) =
match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_app_intro_r
val memP_app_intro_r (#a x: _) (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2))
val memP_app_intro_r (#a x: _) (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2))
let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 157, "start_col": 0, "start_line": 153 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> l1: Prims.list a -> l2: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l2 ==> FStar.List.Tot.Base.memP x (l1 @ l2))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "BinaryTreesEnumeration.memP_app_intro_r", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.op_At", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec memP_app_intro_r #a x (l1: list a) (l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) =
match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.product_complete
val product_complete (#a #b: Type) (l1: list a) (l2: list b) (x1 x2: _) : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2))
val product_complete (#a #b: Type) (l1: list a) (l2: list b) (x1 x2: _) : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2))
let product_complete (#a #b: Type) (l1: list a) (l2: list b) x1 x2 : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2)) = let x = (x1, x2) in let f2 x1 = fun x2 -> (x1, x2) in let f1 = fun x1 -> List.Tot.map (f2 x1) l2 in let l = f1 x1 in let ls = List.Tot.map f1 l1 in assert (product l1 l2 == List.Tot.concatMap f1 l1); memP_map_intro (f2 x1) x2 l2 <: Lemma (List.memP x2 l2 ==> List.memP x l); memP_map_intro f1 x1 l1 <: Lemma (List.memP x1 l1 ==> List.memP l ls); memP_concatMap_intro x1 (x1, x2) f1 l1 <: Lemma (List.memP x1 l1 ==> List.memP (x1, x2) (f1 x1) ==> List.memP (x1, x2) (List.Tot.concatMap f1 l1))
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 258, "start_col": 0, "start_line": 238 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2 (*> * Should this be in the stdlib? *) let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2 (*> * What's the right way to prove this? The code below is messy because… - … it repeats types all over the place. Is there a way to get a bit more inference? - … it manages a context explicitly, using calls to [arrow_to_impl] to get concrete references to proofs. These references (as well as the calls to [impl_to_arrow] and [bind_squash]) are used to construct the explicit proof that exist_elim asks for (without the [arrow_to_impl]s I can only prove [… ==> exists …], not [exists …]. What's the right way to do this? - … it lists arguments to each [memP_app] explicitly (in Coq I'd use apply, and it'd pick the right arguments by unifying with the goal). Is there a way around this? - … it's slow (multiple seconds), although the proof seems entirely explicit. *) let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) = FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let (l1, l2) = l12 in let (ls1, ls2) = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2))))))) let memP_concatMap_intro #a #b (x: a) (y: b) (f:a -> list b) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l)) = concatMap_flatten_map f l; memP_map_intro f x l; memP_flatten_intro y (f x) (List.Tot.map f l) (*> * This code used to include [assert]s instead of [:>] to re-state the goal. Is there a technique similar to Coq's [intro] that would allow me to only re-state the conclusions of the lemmas, instead of having to repeat redundant premises? * The let-bindings make the code more succinct, but also harder to read. How can I get rid of them without cluttering the rest of the proof with many copies of the same function? Can I infer them by unifying with the
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
l1: Prims.list a -> l2: Prims.list b -> x1: a -> x2: b -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x1 l1 ==> FStar.List.Tot.Base.memP x2 l2 ==> FStar.List.Tot.Base.memP (x1, x2) (BinaryTreesEnumeration.product l1 l2))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "BinaryTreesEnumeration.memP_concatMap_intro", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.concatMap", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.List.Tot.Properties.memP_map_intro", "Prims._assert", "Prims.eq2", "BinaryTreesEnumeration.product", "FStar.List.Tot.Base.map" ]
[]
false
false
true
false
false
let product_complete (#a: Type) (#b: Type) (l1: list a) (l2: list b) x1 x2 : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2)) =
let x = (x1, x2) in let f2 x1 = fun x2 -> (x1, x2) in let f1 = fun x1 -> List.Tot.map (f2 x1) l2 in let l = f1 x1 in let ls = List.Tot.map f1 l1 in assert (product l1 l2 == List.Tot.concatMap f1 l1); memP_map_intro (f2 x1) x2 l2 <: Lemma (List.memP x2 l2 ==> List.memP x l); memP_map_intro f1 x1 l1 <: Lemma (List.memP x1 l1 ==> List.memP l ls); memP_concatMap_intro x1 (x1, x2) f1 l1 <: Lemma (List.memP x1 l1 ==> List.memP (x1, x2) (f1 x1) ==> List.memP (x1, x2) (List.Tot.concatMap f1 l1))
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.unfold_tos
val unfold_tos (s: nat) : Lemma (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))))
val unfold_tos (s: nat) : Lemma (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))))
let unfold_tos (s: nat) : Lemma (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)))) = assert_norm (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))))
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 282, "start_col": 0, "start_line": 260 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2 (*> * Should this be in the stdlib? *) let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2 (*> * What's the right way to prove this? The code below is messy because… - … it repeats types all over the place. Is there a way to get a bit more inference? - … it manages a context explicitly, using calls to [arrow_to_impl] to get concrete references to proofs. These references (as well as the calls to [impl_to_arrow] and [bind_squash]) are used to construct the explicit proof that exist_elim asks for (without the [arrow_to_impl]s I can only prove [… ==> exists …], not [exists …]. What's the right way to do this? - … it lists arguments to each [memP_app] explicitly (in Coq I'd use apply, and it'd pick the right arguments by unifying with the goal). Is there a way around this? - … it's slow (multiple seconds), although the proof seems entirely explicit. *) let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) = FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let (l1, l2) = l12 in let (ls1, ls2) = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2))))))) let memP_concatMap_intro #a #b (x: a) (y: b) (f:a -> list b) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l)) = concatMap_flatten_map f l; memP_map_intro f x l; memP_flatten_intro y (f x) (List.Tot.map f l) (*> * This code used to include [assert]s instead of [:>] to re-state the goal. Is there a technique similar to Coq's [intro] that would allow me to only re-state the conclusions of the lemmas, instead of having to repeat redundant premises? * The let-bindings make the code more succinct, but also harder to read. How can I get rid of them without cluttering the rest of the proof with many copies of the same function? Can I infer them by unifying with the current “goal”? *) let product_complete (#a #b: Type) (l1: list a) (l2: list b) x1 x2 : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2)) = let x = (x1, x2) in let f2 x1 = fun x2 -> (x1, x2) in let f1 = fun x1 -> List.Tot.map (f2 x1) l2 in let l = f1 x1 in let ls = List.Tot.map f1 l1 in assert (product l1 l2 == List.Tot.concatMap f1 l1); memP_map_intro (f2 x1) x2 l2 <: Lemma (List.memP x2 l2 ==> List.memP x l); memP_map_intro f1 x1 l1 <: Lemma (List.memP x1 l1 ==> List.memP l ls); memP_concatMap_intro x1 (x1, x2) f1 l1 <: Lemma (List.memP x1 l1 ==> List.memP (x1, x2) (f1 x1) ==> List.memP (x1, x2) (List.Tot.concatMap f1 l1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
s: Prims.nat -> FStar.Pervasives.Lemma (ensures BinaryTreesEnumeration.trees_of_size s == (match s = 0 with | true -> [BinaryTreesEnumeration.Leaf] | _ -> FStar.List.Tot.Base.concatMap (fun _ -> (let FStar.Pervasives.Native.Mktuple2 #_ #_ s1 s2 = _ in FStar.List.Tot.Base.map (fun _ -> (let FStar.Pervasives.Native.Mktuple2 #_ #_ t1 t2 = _ in BinaryTreesEnumeration.Branch (t1, t2)) <: BinaryTreesEnumeration.bt_with_size s) (BinaryTreesEnumeration.product (BinaryTreesEnumeration.trees_of_size s1) (BinaryTreesEnumeration.trees_of_size s2))) <: Prims.list (BinaryTreesEnumeration.bt_with_size s)) (BinaryTreesEnumeration.pairs_with_sum (s - 1))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "BinaryTreesEnumeration.bt_with_size", "BinaryTreesEnumeration.trees_of_size", "Prims.op_Equality", "Prims.int", "Prims.Cons", "BinaryTreesEnumeration.Leaf", "Prims.Nil", "Prims.bool", "FStar.List.Tot.Base.concatMap", "BinaryTreesEnumeration.prod_with_sum", "Prims.op_Subtraction", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple2", "BinaryTreesEnumeration.Branch", "FStar.Pervasives.Native.Mktuple2", "BinaryTreesEnumeration.bin_tree", "BinaryTreesEnumeration.product", "BinaryTreesEnumeration.pairs_with_sum", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let unfold_tos (s: nat) : Lemma (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)))) =
assert_norm (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1))))
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.memP_flatten_intro
val memP_flatten_intro (#a: _) (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls))
val memP_flatten_intro (#a: _) (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls))
let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) = FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let (l1, l2) = l12 in let (ls1, ls2) = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2)))))))
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 220, "start_col": 0, "start_line": 173 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2 (*> * Should this be in the stdlib? *) let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2 (*> * What's the right way to prove this? The code below is messy because… - … it repeats types all over the place. Is there a way to get a bit more inference? - … it manages a context explicitly, using calls to [arrow_to_impl] to get concrete references to proofs. These references (as well as the calls to [impl_to_arrow] and [bind_squash]) are used to construct the explicit proof that exist_elim asks for (without the [arrow_to_impl]s I can only prove [… ==> exists …], not [exists …]. What's the right way to do this? - … it lists arguments to each [memP_app] explicitly (in Coq I'd use apply, and it'd pick the right arguments by unifying with the goal). Is there a way around this? - … it's slow (multiple seconds), although the proof seems entirely
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "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" }
false
x: a -> l: Prims.list a -> ls: Prims.list (Prims.list a) -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP x l ==> FStar.List.Tot.Base.memP l ls ==> FStar.List.Tot.Base.memP x (FStar.List.Tot.Base.flatten ls))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "FStar.Classical.arrow_to_impl", "FStar.List.Tot.Base.memP", "Prims.l_imp", "FStar.List.Tot.Base.flatten", "Prims.squash", "FStar.Squash.bind_squash", "Prims.l_Exists", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "FStar.List.Tot.Base.op_At", "FStar.Pervasives.Native.fst", "Prims.Cons", "FStar.Pervasives.Native.snd", "FStar.Squash.get_proof", "FStar.Classical.exists_elim", "BinaryTreesEnumeration.memP_app_intro_r", "Prims.unit", "BinaryTreesEnumeration.memP_app_intro_l", "BinaryTreesEnumeration.flatten_app", "FStar.Classical.impl_to_arrow", "BinaryTreesEnumeration.memP_append", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) =
FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let l1, l2 = l12 in let ls1, ls2 = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2)))))))
false
BinaryTreesEnumeration.fsti
BinaryTreesEnumeration.tos_complete
val tos_complete (bt0: bin_tree) : Lemma (List.memP bt0 (trees_of_size (size bt0)))
val tos_complete (bt0: bin_tree) : Lemma (List.memP bt0 (trees_of_size (size bt0)))
let rec tos_complete (bt0: bin_tree) : Lemma (List.memP bt0 (trees_of_size (size bt0))) = match bt0 with | Leaf -> () | Branch(t1, t2) -> let s = size bt0 in let s1 = size t1 in let s2 = size t2 in let trees1 = trees_of_size s1 in let trees2 = trees_of_size s2 in tos_complete t1; (* assert (List.memP t1 trees1); *) tos_complete t2; (* assert (List.memP t2 trees2); *) product_complete trees1 trees2 t1 t2; (* assert (List.memP (t1, t2) (product trees1 trees2)); *) memP_map_intro #(bt_with_size s1 * bt_with_size s2) (fun (t1, t2) -> Branch (t1, t2) <: (bt_with_size s)) (t1, t2) (product trees1 trees2); (* assert (List.memP (Branch (t1, t2)) *) (* (List.Tot.map #((t1: bin_tree{size t1 == s1}) * (t2: bin_tree{size t2 == s2})) *) (* (fun (t1, t2) -> Branch (t1, t2) <: (bt: bin_tree{size bt == s})) *) (* (product trees1 trees2))); *) pws_complete s1 s2; (*> Why do I need this intermediate assert? *) assert (List.memP (s1, s2) (pairs_with_sum (s1 + s2))); (* assert (List.memP (s1, s2) (pairs_with_sum (s - 1))); *) memP_concatMap_intro #(prod_with_sum (s - 1)) (s1, s2) (Branch (t1, t2)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)); unfold_tos s
{ "file_name": "examples/data_structures/BinaryTreesEnumeration.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 346, "start_col": 0, "start_line": 301 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinaryTreesEnumeration open FStar.List (* * AR: 11/29: hoisting it cf. recursive guards *) type prod_with_sum (n:nat) = p:(nat & nat){fst p + snd p == n} val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) let pairs_with_sum (n: nat) : list (prod_with_sum n) = pairs_with_sum' n 0 let product #a #b (l1: list a) (l2: list b) = List.Tot.concatMap (fun x1 -> List.Tot.map (fun x2 -> (x1, x2)) l2) l1 type bin_tree = | Leaf | Branch of bin_tree * bin_tree let rec size bt : nat = match bt with | Leaf -> 0 | Branch(l, r) -> 1 + size l + size r type bt_with_size (n:nat) = t:bin_tree{size t == n} (*> * Why do I need type annotations on [concatMap] and [map]? * When I reduce this definition I see that the lambda desugared to a match with 4 arguments (not 2). Why? * I had to eta-expand [Branch]; why? Is it because there's a implicit cast from [bintree] to [bt: bin_tree{size bt == s}]? If so, why is it not enough to add a coercion [Branch <: _ -> bt: bin_tree{size bt == s}]? *) let rec trees_of_size (s: nat) : list (bt_with_size s) = if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #((bt_with_size s1) * (bt_with_size s2)) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)) val pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) (*> Should this be in the standard library? *) let rec concatMap_flatten_map #a #b (f:a -> list b) l : Lemma (List.Tot.concatMap f l == List.Tot.flatten (List.Tot.map f l)) = match l with | [] -> () | h :: t -> concatMap_flatten_map f t (** This is Coq's [in_split] *) (*> * Should this be in the stdlib? * I see why [assert false] doesn't work in the [[]] branch of the match (there's no contradiction unless the implication is taken into account)? Is there a lightweight way to make it explicit that we're proving [False ==> …] in that branch? I'm thinking of an equivalent of Coq's [intro; exfalso; assumption]. * Is it worth writing it with two exists instead of a single exist on a pair? * Why do I need anything from 'classical'? Is it because memP uses a classical [or]? * Why is [or_elim]'s 2nd argument implicit? * Does F* do induction automatically? I expected I'd have to supply [memP_append x t] explicitly to [exist_elim]. If I wanted to do that, would I have to use [get_proof] + [bind_squash]? *) (* NS: June 07, 2017 The previous "proof" here was relying on a bug revealed by issue #1071 It had unresolved unification variables in a recursive function, so the proof wasn't actually complete. So, this is a revised proof ... still in an overly explicit, rather unsatisfactory style. This version may answer some of the questions above. *) (* These utilities are better moved to the squash library *) let bind = FStar.Squash.bind_squash let return = FStar.Squash.return_squash let pure_as_squash (#a:Type) (#p:_) (#q:_) ($f:(x:a -> Lemma (requires (p x)) (ensures (q x)))) (x:a{p x}) : squash (q x) = f x let rec memP_append_aux #a (x: a) (l: list a) : Lemma (requires (List.memP x l)) (ensures (exists (l12: (list a * list a)). l == fst l12 @ x :: snd l12)) = let goal = exists l12. l == fst l12 @ x :: snd l12 in let x : squash goal = match l with | [] -> () | h :: t -> let pf : squash (x == h \/ List.memP x t) = () in p <-- FStar.Squash.join_squash pf ; match p with | Prims.Left x_eq_h -> let l12 = [], t in assert (l == (fst l12) @ (x :: snd l12)) //trigger | Prims.Right mem_x_t -> FStar.Classical.exists_elim goal (pure_as_squash (memP_append_aux x) t) (fun l12' -> let l12 = h::fst l12', snd l12' in assert (l == (fst l12) @ (x :: snd l12))) //trigger in FStar.Squash.give_proof x let memP_append #a (x: a) (l: list a) : Lemma (ensures (List.memP x l ==> (exists (l12: (list a * list a)). l == (fst l12) @ (x :: (snd l12))))) = FStar.Classical.move_requires (memP_append_aux x) l (*> * Should this be in the stdlib? *) let rec flatten_app #a (l1 l2: list (list a)) : Lemma (flatten (l1 @ l2) == flatten l1 @ flatten l2) = match l1 with | [] -> () | h :: t -> flatten_app t l2; append_assoc h (flatten t) (flatten l2) (*> * Should this be in the stdlib? *) let rec memP_app_intro_l #a x (l1 l2: list a) : Lemma (memP x l1 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_l x t l2 (*> * Should this be in the stdlib? *) let rec memP_app_intro_r #a x (l1 l2: list a) : Lemma (memP x l2 ==> memP x (l1 @ l2)) = match l1 with | [] -> () | h :: t -> memP_app_intro_r x t l2 (*> * What's the right way to prove this? The code below is messy because… - … it repeats types all over the place. Is there a way to get a bit more inference? - … it manages a context explicitly, using calls to [arrow_to_impl] to get concrete references to proofs. These references (as well as the calls to [impl_to_arrow] and [bind_squash]) are used to construct the explicit proof that exist_elim asks for (without the [arrow_to_impl]s I can only prove [… ==> exists …], not [exists …]. What's the right way to do this? - … it lists arguments to each [memP_app] explicitly (in Coq I'd use apply, and it'd pick the right arguments by unifying with the goal). Is there a way around this? - … it's slow (multiple seconds), although the proof seems entirely explicit. *) let memP_flatten_intro #a (x: a) (l: list a) (ls: list (list a)) : Lemma (List.memP x l ==> List.memP l ls ==> List.memP x (List.Tot.flatten ls)) = FStar.Classical.arrow_to_impl #(List.memP x l) #(List.memP l ls ==> List.memP x (List.Tot.flatten ls)) (fun memP_x_l_proof -> FStar.Classical.arrow_to_impl #(List.memP l ls) #(List.memP x (List.Tot.flatten ls)) (fun memP_l_ls_proof -> memP_append x l; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP x l ==> (exists l12. l == (fst l12) @ (x :: (snd l12))))) (fun memP_x_l_split -> let l_split_pr = FStar.Classical.impl_to_arrow #(List.memP x l) #(exists l12. l == (fst l12) @ (x :: (snd l12))) memP_x_l_split memP_x_l_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun l12 -> l == (fst l12) @ (x :: (snd l12))) l_split_pr (fun l12 -> memP_append l ls; FStar.Squash.bind_squash (FStar.Squash.get_proof (List.memP l ls ==> (exists ls12. ls == (fst ls12) @ (l :: (snd ls12))))) (fun memP_l_ls_split -> let ls_split_pr = FStar.Classical.impl_to_arrow #(List.memP l ls) #(exists ls12. ls == (fst ls12) @ (l :: (snd ls12))) memP_l_ls_split memP_l_ls_proof in FStar.Classical.exists_elim (List.memP x (List.Tot.flatten ls)) #_ #(fun ls12 -> ls == (fst ls12) @ (l :: (snd ls12))) ls_split_pr (fun ls12 -> let (l1, l2) = l12 in let (ls1, ls2) = ls12 in flatten_app ls1 (l :: ls2); memP_app_intro_r x (flatten ls1) ((l1 @ x :: l2) @ flatten ls2); memP_app_intro_l x (l1 @ x :: l2) (flatten ls2); memP_app_intro_r x l1 (x :: l2))))))) let memP_concatMap_intro #a #b (x: a) (y: b) (f:a -> list b) (l: list a) : Lemma (List.memP x l ==> List.memP y (f x) ==> List.memP y (List.Tot.concatMap f l)) = concatMap_flatten_map f l; memP_map_intro f x l; memP_flatten_intro y (f x) (List.Tot.map f l) (*> * This code used to include [assert]s instead of [:>] to re-state the goal. Is there a technique similar to Coq's [intro] that would allow me to only re-state the conclusions of the lemmas, instead of having to repeat redundant premises? * The let-bindings make the code more succinct, but also harder to read. How can I get rid of them without cluttering the rest of the proof with many copies of the same function? Can I infer them by unifying with the current “goal”? *) let product_complete (#a #b: Type) (l1: list a) (l2: list b) x1 x2 : Lemma (List.memP x1 l1 ==> List.memP x2 l2 ==> List.memP (x1, x2) (product #a l1 l2)) = let x = (x1, x2) in let f2 x1 = fun x2 -> (x1, x2) in let f1 = fun x1 -> List.Tot.map (f2 x1) l2 in let l = f1 x1 in let ls = List.Tot.map f1 l1 in assert (product l1 l2 == List.Tot.concatMap f1 l1); memP_map_intro (f2 x1) x2 l2 <: Lemma (List.memP x2 l2 ==> List.memP x l); memP_map_intro f1 x1 l1 <: Lemma (List.memP x1 l1 ==> List.memP l ls); memP_concatMap_intro x1 (x1, x2) f1 l1 <: Lemma (List.memP x1 l1 ==> List.memP (x1, x2) (f1 x1) ==> List.memP (x1, x2) (List.Tot.concatMap f1 l1)) let unfold_tos (s: nat) : Lemma (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)))) = assert_norm (trees_of_size s == (if s = 0 then [Leaf] else List.Tot.concatMap #(prod_with_sum (s - 1)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)))) (*> The error message if I omit this isn't the best. Could the resource exhaustion be detected and reported? *) #set-options "--z3rlimit 40 --initial_fuel 1 --max_fuel 1" (*> I ran into a few problems while writing this proof: - I had trouble supplying the right arguments for each lemma: In Coq I can just use [apply] and the arguments are inferred using unification. Is there something similar in F*? - Just seeing the lemma calls made it hard to remember which facts were available at each point in the proof, so I wrote [assert]s to get visual feedback. In previous proofs I used [<:] to write these annotations, but here I had to use explicit [assert]s ([<:] and [assert_norm] broke type inference). The problem is that these asserts are rather costly (they make the proof slower). Is there a way around this? - The proof does require one intermediate assert (see below) which just seems to be a restatement of the result of a call to a lemma. Is there a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "BinaryTreesEnumeration.fsti" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
bt0: BinaryTreesEnumeration.bin_tree -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.memP bt0 (BinaryTreesEnumeration.trees_of_size (BinaryTreesEnumeration.size bt0)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "BinaryTreesEnumeration.bin_tree", "BinaryTreesEnumeration.unfold_tos", "Prims.unit", "BinaryTreesEnumeration.memP_concatMap_intro", "BinaryTreesEnumeration.prod_with_sum", "Prims.op_Subtraction", "BinaryTreesEnumeration.bt_with_size", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "BinaryTreesEnumeration.Branch", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple2", "BinaryTreesEnumeration.product", "BinaryTreesEnumeration.trees_of_size", "Prims.list", "BinaryTreesEnumeration.pairs_with_sum", "Prims._assert", "FStar.List.Tot.Base.memP", "Prims.op_Addition", "BinaryTreesEnumeration.pws_complete", "FStar.List.Tot.Properties.memP_map_intro", "BinaryTreesEnumeration.product_complete", "BinaryTreesEnumeration.tos_complete", "BinaryTreesEnumeration.size", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec tos_complete (bt0: bin_tree) : Lemma (List.memP bt0 (trees_of_size (size bt0))) =
match bt0 with | Leaf -> () | Branch (t1, t2) -> let s = size bt0 in let s1 = size t1 in let s2 = size t2 in let trees1 = trees_of_size s1 in let trees2 = trees_of_size s2 in tos_complete t1; tos_complete t2; product_complete trees1 trees2 t1 t2; memP_map_intro #(bt_with_size s1 * bt_with_size s2) (fun (t1, t2) -> Branch (t1, t2) <: (bt_with_size s)) (t1, t2) (product trees1 trees2); pws_complete s1 s2; assert (List.memP (s1, s2) (pairs_with_sum (s1 + s2))); memP_concatMap_intro #(prod_with_sum (s - 1)) (s1, s2) (Branch (t1, t2)) (fun (s1, s2) -> List.Tot.map #(bt_with_size s1 * bt_with_size s2) #(bt_with_size s) (fun (t1, t2) -> Branch (t1, t2)) (product (trees_of_size s1) (trees_of_size s2))) (pairs_with_sum (s - 1)); unfold_tos s
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_code_Move
val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code
val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code
let va_code_Move dst src = (Ins (S.Move dst src))
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 13, "start_col": 0, "start_line": 12 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr -> Vale.PPC64LE.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Semantics_s.Move", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Move dst src =
(Ins (S.Move dst src))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_codegen_success_LoadImm64
val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
let va_codegen_success_LoadImm64 dst src = (va_ttrue ())
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 46, "start_col": 0, "start_line": 45 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Decls.va_ttrue", "Vale.PPC64LE.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_LoadImm64 dst src =
(va_ttrue ())
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_code_LoadImm64
val va_code_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_code
val va_code_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_code
let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src))
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 42, "start_col": 0, "start_line": 41 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Semantics_s.LoadImm64", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_LoadImm64 dst src =
(Ins (S.LoadImm64 dst src))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_codegen_success_Move
val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool
val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_Move dst src = (va_ttrue ())
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 17, "start_col": 0, "start_line": 16 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr -> Vale.PPC64LE.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Decls.va_ttrue", "Vale.PPC64LE.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Move dst src =
(va_ttrue ())
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_code_LoadImmShl64
val va_code_LoadImmShl64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_code
val va_code_LoadImmShl64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_code
let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src))
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 71, "start_col": 0, "start_line": 70 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Semantics_s.LoadImmShl64", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_LoadImmShl64 dst src =
(Ins (S.LoadImmShl64 dst src))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_codegen_success_LoadImmShl64
val va_codegen_success_LoadImmShl64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
val va_codegen_success_LoadImmShl64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ())
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 75, "start_col": 0, "start_line": 74 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Decls.va_ttrue", "Vale.PPC64LE.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_LoadImmShl64 dst src =
(va_ttrue ())
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_code_Add
val va_code_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Tot va_code
val va_code_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Tot va_code
let va_code_Add dst src1 src2 = (Ins (S.Add dst src1 src2))
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 129, "start_col": 0, "start_line": 128 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa [@ "opaque_to_smt"] let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddLa dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddLa va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddLa) (va_code_AddLa dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddLa dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddLa dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddLa dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddLa (va_code_AddLa dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Add
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Decls.va_operand_reg_opr -> Vale.PPC64LE.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Semantics_s.Add", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Add dst src1 src2 =
(Ins (S.Add dst src1 src2))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_code_AddLa
val va_code_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_code
val va_code_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_code
let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2))
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 100, "start_col": 0, "start_line": 99 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Semantics_s.AddLa", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_AddLa dst src1 src2 =
(Ins (S.AddLa dst src1 src2))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_codegen_success_Add
val va_codegen_success_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Tot va_pbool
val va_codegen_success_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_Add dst src1 src2 = (va_ttrue ())
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 133, "start_col": 0, "start_line": 132 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa [@ "opaque_to_smt"] let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddLa dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddLa va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddLa) (va_code_AddLa dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddLa dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddLa dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddLa dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddLa (va_code_AddLa dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Add [@ "opaque_to_smt"] let va_code_Add dst src1 src2 = (Ins (S.Add dst src1 src2))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Decls.va_operand_reg_opr -> Vale.PPC64LE.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Decls.va_ttrue", "Vale.PPC64LE.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_codegen_success_AddLa
val va_codegen_success_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_pbool
val va_codegen_success_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_pbool
let va_codegen_success_AddLa dst src1 src2 = (va_ttrue ())
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 104, "start_col": 0, "start_line": 103 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa [@ "opaque_to_smt"] let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Machine_s.simm16 -> Vale.PPC64LE.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Machine_s.simm16", "Vale.PPC64LE.Decls.va_ttrue", "Vale.PPC64LE.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_AddLa dst src1 src2 =
(va_ttrue ())
false
Hacl.Impl.Box.fst
Hacl.Impl.Box.box_open_detached_afternm
val box_open_detached_afternm: mlen:size_t -> m:lbuffer uint8 mlen -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ eq_or_disjoint m c /\ disjoint tag m /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
val box_open_detached_afternm: mlen:size_t -> m:lbuffer uint8 mlen -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ eq_or_disjoint m c /\ disjoint tag m /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
let box_open_detached_afternm mlen m k n c tag = secretbox_open_detached mlen m k n c tag
{ "file_name": "code/nacl-box/Hacl.Impl.Box.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 123, "start_col": 0, "start_line": 122 }
module Hacl.Impl.Box open FStar.HyperStack.All open FStar.HyperStack open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.SecretBox module ST = FStar.HyperStack.ST module Spec = Spec.Box module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" val box_beforenm: k:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> Stack size_t (requires fun h -> live h k /\ live h pk /\ live h sk /\ disjoint k pk /\ disjoint k sk) (ensures fun h0 r h1 -> modifies (loc k) h0 h1 /\ (let key = Spec.box_beforenm (as_seq h0 pk) (as_seq h0 sk) in match r with | 0ul -> Some? key /\ as_seq h1 k == Some?.v key | _ -> None? key)) [@CInline] let box_beforenm k pk sk = push_frame(); let n0 = create 16ul (u8 0) in let r = Hacl.Curve25519_51.ecdh k sk pk in let res = if r then ( Hacl.Salsa20.hsalsa20 k k n0; 0ul) else 0xfffffffful in pop_frame(); res val box_detached_afternm: mlen:size_t -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c |+| loc tag) h0 h1 /\ r == 0ul /\ (as_seq h1 tag, as_seq h1 c) == Spec.box_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) [@CInline] let box_detached_afternm mlen c tag k n m = secretbox_detached mlen c tag k n m; 0ul #set-options "--z3rlimit 100" val box_detached: mlen:size_t -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> sk:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h sk /\ live h pk /\ live h n /\ live h tag /\ disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c |+| loc tag) h0 h1 /\ (let tag_cipher = Spec.box_detached (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in match r with | 0ul -> Some? tag_cipher /\ (let (tag_s, cipher_s) = Some?.v tag_cipher in (as_seq h1 tag, as_seq h1 c) == (tag_s, cipher_s)) | _ -> None? tag_cipher)) [@CInline] let box_detached mlen c tag sk pk n m = push_frame(); let k = create 32ul (u8 0) in let r = box_beforenm k pk sk in let res = if r =. size 0 then box_detached_afternm mlen c tag k n m else 0xfffffffful in pop_frame (); res val box_open_detached_afternm: mlen:size_t -> m:lbuffer uint8 mlen -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ eq_or_disjoint m c /\ disjoint tag m /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
{ "checked_file": "/", "dependencies": [ "Spec.Box.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Salsa20.fst.checked", "Hacl.Impl.SecretBox.fst.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Box.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Box", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SecretBox", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "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": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mlen: Lib.IntTypes.size_t -> m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul -> c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen -> tag: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.SecretBox.secretbox_open_detached" ]
[]
false
true
false
false
false
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
false