effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val collect_app_ln' (args: list argv) (t: term) : Tot (term * list argv) (decreases t) | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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) | 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) = | false | null | false | match inspect_ln_unascribe t with
| Tv_App l r -> collect_app_ln' (r :: args) l
| _ -> (t, args) | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total",
""
] | [
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.inspect_ln_unascribe",
"FStar.Reflection.V1.Derived.collect_app_ln'",
"Prims.Cons",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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 *) | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val collect_app_ln' (args: list argv) (t: term) : Tot (term * list argv) (decreases t) | [
"recursion"
] | FStar.Reflection.V1.Derived.collect_app_ln' | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | args: Prims.list FStar.Reflection.V1.Data.argv -> t: FStar.Reflection.Types.term
-> Prims.Tot (FStar.Reflection.Types.term * Prims.list FStar.Reflection.V1.Data.argv) | {
"end_col": 20,
"end_line": 67,
"start_col": 4,
"start_line": 64
} |
Prims.Tot | val is_name_imp (nm: name) (t: term) : bool | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | false | 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 | val is_name_imp (nm: name) (t: term) : bool
let rec is_name_imp (nm: name) (t: term) : bool = | false | null | false | 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 | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.Reflection.Types.name",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.inspect_ln_unascribe",
"FStar.Reflection.Types.fv",
"Prims.op_Equality",
"FStar.Reflection.V1.Builtins.inspect_fv",
"Prims.bool",
"FStar.Reflection.V1.Data.universes",
"FStar.Reflection.V1.Derived.is_name_imp",
"FStar.Reflection.V1.Data.term_view"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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.
*) | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_name_imp (nm: name) (t: term) : bool | [
"recursion"
] | FStar.Reflection.V1.Derived.is_name_imp | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | nm: FStar.Reflection.Types.name -> t: FStar.Reflection.Types.term -> Prims.bool | {
"end_col": 16,
"end_line": 244,
"start_col": 10,
"start_line": 236
} |
Prims.Tot | val collect_abs' (bs: list binder) (t: term) : Tot (list binder * term) (decreases t) | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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) | 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) = | false | null | false | match inspect_ln_unascribe t with
| Tv_Abs b t' -> collect_abs' (b :: bs) t'
| _ -> (bs, t) | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total",
""
] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.inspect_ln_unascribe",
"FStar.Reflection.V1.Derived.collect_abs'",
"Prims.Cons",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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 | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val collect_abs' (bs: list binder) (t: term) : Tot (list binder * term) (decreases t) | [
"recursion"
] | FStar.Reflection.V1.Derived.collect_abs' | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> t: FStar.Reflection.Types.term
-> Prims.Tot (Prims.list FStar.Reflection.Types.binder * FStar.Reflection.Types.term) | {
"end_col": 18,
"end_line": 115,
"start_col": 4,
"start_line": 112
} |
Prims.Tot | val is_any_fvar (t: term) (nms: list string) : bool | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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 | val is_any_fvar (t: term) (nms: list string) : bool
let rec is_any_fvar (t: term) (nms: list string) : bool = | false | null | false | match nms with
| [] -> false
| v :: vs -> is_fvar t v || is_any_fvar t vs | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.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"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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. *) | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_any_fvar (t: term) (nms: list string) : bool | [
"recursion"
] | FStar.Reflection.V1.Derived.is_any_fvar | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> nms: Prims.list Prims.string -> Prims.bool | {
"end_col": 46,
"end_line": 208,
"start_col": 4,
"start_line": 206
} |
Prims.Tot | val head (t: term) : term | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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 | val head (t: term) : term
let rec head (t: term) : term = | false | null | false | 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 | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Builtins.inspect_ln",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.match_returns_ascription",
"Prims.list",
"FStar.Reflection.V1.Data.branch",
"FStar.Reflection.V1.Derived.head",
"Prims.bool",
"FStar.Reflection.Types.bv",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.Types.comp",
"Prims.nat",
"FStar.Reflection.Types.ctx_uvar_and_subst",
"FStar.Reflection.V1.Data.vconst",
"FStar.Reflection.Types.universe",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Data.universes"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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] | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val head (t: term) : term | [
"recursion"
] | FStar.Reflection.V1.Derived.head | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> FStar.Reflection.Types.term | {
"end_col": 20,
"end_line": 193,
"start_col": 4,
"start_line": 175
} |
Prims.Tot | val mktuple_n (ts: list term {List.Tot.Base.length ts <= 8}) : term | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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 -> 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 | 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 = | false | null | false | 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 | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.Types.term",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.List.Tot.Base.length",
"FStar.Reflection.V1.Builtins.pack_ln",
"FStar.Reflection.V1.Data.Tv_Const",
"FStar.Reflection.V1.Data.C_Unit",
"Prims.int",
"FStar.Reflection.V1.Derived.mk_e_app",
"FStar.Reflection.V1.Data.Tv_FVar",
"FStar.Reflection.V1.Builtins.pack_fv",
"FStar.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"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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) | false | false | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mktuple_n (ts: list term {List.Tot.Base.length ts <= 8}) : term | [] | FStar.Reflection.V1.Derived.mktuple_n | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ts: Prims.list FStar.Reflection.Types.term {FStar.List.Tot.Base.length ts <= 8}
-> FStar.Reflection.Types.term | {
"end_col": 14,
"end_line": 155,
"start_col": 4,
"start_line": 142
} |
Prims.Tot | val destruct_tuple (t: term) : option (list term) | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | 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 | val destruct_tuple (t: term) : option (list term)
let destruct_tuple (t: term) : option (list term) = | false | null | false | 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": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.V1.Builtins.inspect_ln",
"FStar.Reflection.Types.fv",
"FStar.List.Tot.Base.mem",
"Prims.string",
"FStar.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.Reflection.V1.Data.aqualv",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Derived.collect_app_ln"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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 | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val destruct_tuple (t: term) : option (list term) | [] | FStar.Reflection.V1.Derived.destruct_tuple | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term
-> FStar.Pervasives.Native.option (Prims.list FStar.Reflection.Types.term) | {
"end_col": 15,
"end_line": 169,
"start_col": 52,
"start_line": 157
} |
Prims.Tot | val maybe_unsquash_term (t: term) : term | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | false | let maybe_unsquash_term (t : term) : term =
match unsquash_term t with
| Some t' -> t'
| None -> t | val maybe_unsquash_term (t: term) : term
let maybe_unsquash_term (t: term) : term = | false | null | false | match unsquash_term t with
| Some t' -> t'
| None -> t | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.unsquash_term"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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
[t] is not a squash. *) | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val maybe_unsquash_term (t: term) : term | [] | FStar.Reflection.V1.Derived.maybe_unsquash_term | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> FStar.Reflection.Types.term | {
"end_col": 15,
"end_line": 262,
"start_col": 4,
"start_line": 260
} |
Prims.Tot | val mkpair (t1 t2: term) : term | [
{
"abbrev": false,
"full_module": "FStar.VConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Order",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.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
}
] | false | let mkpair (t1 t2 : term) : term =
mktuple_n [t1;t2] | val mkpair (t1 t2: term) : term
let mkpair (t1 t2: term) : term = | false | null | false | mktuple_n [t1; t2] | {
"checked_file": "FStar.Reflection.V1.Derived.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.VConfig.fsti.checked",
"FStar.Reflection.V1.Data.fsti.checked",
"FStar.Reflection.V1.Builtins.fsti.checked",
"FStar.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"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.mktuple_n",
"Prims.Cons",
"Prims.Nil"
] | [] | (*
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.Reflection.Types
open FStar.Reflection.Const
open FStar.Reflection.V1.Builtins
open FStar.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 | false | true | FStar.Reflection.V1.Derived.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mkpair (t1 t2: term) : term | [] | FStar.Reflection.V1.Derived.mkpair | {
"file_name": "ulib/FStar.Reflection.V1.Derived.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t1: FStar.Reflection.Types.term -> t2: FStar.Reflection.Types.term -> FStar.Reflection.Types.term | {
"end_col": 21,
"end_line": 172,
"start_col": 4,
"start_line": 172
} |
FStar.Tactics.Effect.Tac | val simp_filter_propositions (e: env) (steps: list norm_step) (pl: list proposition)
: Tac (list proposition) | [
{
"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
}
] | 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) | 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) = | true | null | false | List.flatten (map (simp_filter_proposition e steps) pl) | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.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"
] | [] | 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) : | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simp_filter_propositions (e: env) (steps: list norm_step) (pl: list proposition)
: Tac (list proposition) | [] | FStar.InteractiveHelpers.Propositions.simp_filter_propositions | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.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) | {
"end_col": 57,
"end_line": 59,
"start_col": 2,
"start_line": 59
} |
FStar.Tactics.Effect.Tac | val simp_filter_assertions (e: env) (steps: list norm_step) (a: assertions) : Tac assertions | [
{
"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
}
] | 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 | 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 = | true | null | false | let pres = simp_filter_propositions e steps a.pres in
let posts = simp_filter_propositions e steps a.posts in
mk_assertions pres posts | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.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"
] | [] | 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) | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simp_filter_assertions (e: env) (steps: list norm_step) (a: assertions) : Tac assertions | [] | FStar.InteractiveHelpers.Propositions.simp_filter_assertions | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.Reflection.Types.env ->
steps: Prims.list FStar.Pervasives.norm_step ->
a: FStar.InteractiveHelpers.Propositions.assertions
-> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.Propositions.assertions | {
"end_col": 26,
"end_line": 65,
"start_col": 18,
"start_line": 62
} |
FStar.Tactics.Effect.Tac | [
{
"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
}
] | false | let term_eq = FStar.Tactics.term_eq_old | let term_eq = | true | null | false | FStar.Tactics.term_eq_old | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.Tactics.V1.Builtins.term_eq_old"
] | [] | module FStar.InteractiveHelpers.Propositions
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val term_eq : _: FStar.Reflection.Types.term -> _: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac Prims.bool | [] | FStar.InteractiveHelpers.Propositions.term_eq | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Reflection.Types.term -> _: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 39,
"end_line": 9,
"start_col": 14,
"start_line": 9
} |
|
Prims.Tot | [
{
"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
}
] | false | let simpl_norm_steps = [primops; simplify; iota] | let simpl_norm_steps = | false | null | false | [primops; simplify; iota] | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [
"total"
] | [
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.primops",
"FStar.Pervasives.simplify",
"FStar.Pervasives.iota",
"Prims.Nil"
] | [] | 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 | false | true | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simpl_norm_steps : Prims.list FStar.Pervasives.norm_step | [] | FStar.InteractiveHelpers.Propositions.simpl_norm_steps | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.list FStar.Pervasives.norm_step | {
"end_col": 48,
"end_line": 41,
"start_col": 23,
"start_line": 41
} |
|
FStar.Tactics.Effect.Tac | val proposition_to_string : proposition -> Tac string | [
{
"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
}
] | false | let proposition_to_string p = term_to_string p | val proposition_to_string : proposition -> Tac string
let proposition_to_string p = | true | null | false | term_to_string p | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.InteractiveHelpers.Propositions.proposition",
"FStar.Tactics.V1.Builtins.term_to_string",
"Prims.string"
] | [] | 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 | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val proposition_to_string : proposition -> Tac string | [] | FStar.InteractiveHelpers.Propositions.proposition_to_string | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 46,
"end_line": 26,
"start_col": 30,
"start_line": 26
} |
FStar.Tactics.Effect.Tac | val is_trivial_proposition : proposition -> Tac bool | [
{
"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
}
] | false | let is_trivial_proposition p =
term_eq (`Prims.l_True) p | val is_trivial_proposition : proposition -> Tac bool
let is_trivial_proposition p = | true | null | false | term_eq (`Prims.l_True) p | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.InteractiveHelpers.Propositions.proposition",
"FStar.InteractiveHelpers.Propositions.term_eq",
"Prims.bool"
] | [] | 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 | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_trivial_proposition : proposition -> Tac bool | [] | FStar.InteractiveHelpers.Propositions.is_trivial_proposition | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: FStar.InteractiveHelpers.Propositions.proposition -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 27,
"end_line": 48,
"start_col": 2,
"start_line": 48
} |
FStar.Tactics.Effect.Tac | val simp_filter_proposition (e: env) (steps: list norm_step) (p: proposition)
: Tac (list proposition) | [
{
"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
}
] | 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 trivial, filter *)
if term_eq (`Prims.l_True) prop1 then []
else [prop1] | 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) = | true | null | false | let prop1 = norm_term_env e steps p in
if term_eq (`Prims.l_True) prop1 then [] else [prop1] | {
"checked_file": "FStar.InteractiveHelpers.Propositions.fst.checked",
"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"
} | [] | [
"FStar.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.Reflection.Types.term",
"FStar.Tactics.V1.Builtins.norm_term_env"
] | [] | 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 | false | false | FStar.InteractiveHelpers.Propositions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simp_filter_proposition (e: env) (steps: list norm_step) (p: proposition)
: Tac (list proposition) | [] | FStar.InteractiveHelpers.Propositions.simp_filter_proposition | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Propositions.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
e: FStar.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) | {
"end_col": 14,
"end_line": 55,
"start_col": 26,
"start_line": 51
} |
Prims.Tot | [
{
"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
}
] | false | let heaplet_id = n:nat{n < 16} | let heaplet_id = | false | null | false | n: nat{n < 16} | {
"checked_file": "Vale.Arch.HeapImpl.fsti.checked",
"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"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan"
] | [] | 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.
*) | false | true | Vale.Arch.HeapImpl.fsti | {
"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"
} | null | val heaplet_id : Type0 | [] | Vale.Arch.HeapImpl.heaplet_id | {
"file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 16,
"start_col": 17,
"start_line": 16
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let vale_heaplets = Map16.map16 vale_heap | let vale_heaplets = | false | null | false | Map16.map16 vale_heap | {
"checked_file": "Vale.Arch.HeapImpl.fsti.checked",
"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"
} | [
"total"
] | [
"Vale.Lib.Map16.map16",
"Vale.Arch.HeapImpl.vale_heap"
] | [] | 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;
} | false | true | Vale.Arch.HeapImpl.fsti | {
"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"
} | null | val vale_heaplets : Type | [] | Vale.Arch.HeapImpl.vale_heaplets | {
"file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type | {
"end_col": 41,
"end_line": 39,
"start_col": 20,
"start_line": 39
} |
|
Prims.Tot | val full_heap_taint (vfh: vale_full_heap) : memTaint_t | [
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Heap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let full_heap_taint (vfh:vale_full_heap) : memTaint_t =
vfh.vf_layout.vl_taint | val full_heap_taint (vfh: vale_full_heap) : memTaint_t
let full_heap_taint (vfh: vale_full_heap) : memTaint_t = | false | null | false | vfh.vf_layout.vl_taint | {
"checked_file": "Vale.Arch.HeapImpl.fsti.checked",
"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"
} | [
"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"
] | [] | 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;
} | false | true | Vale.Arch.HeapImpl.fsti | {
"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"
} | null | val full_heap_taint (vfh: vale_full_heap) : memTaint_t | [] | Vale.Arch.HeapImpl.full_heap_taint | {
"file_name": "vale/code/arch/Vale.Arch.HeapImpl.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vfh: Vale.Arch.HeapImpl.vale_full_heap -> Vale.Arch.HeapTypes_s.memTaint_t | {
"end_col": 24,
"end_line": 48,
"start_col": 2,
"start_line": 48
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_list: deq 'a -> deq (list 'a) | [
{
"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
}
] | false | instance eq_list (_ : deq 'a) : deq (list 'a) = {
eq = eqList eq;
} | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_list: deq 'a -> deq (list 'a)
[@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_list (_: deq 'a) : deq (list 'a) = | false | null | false | { eq = eqList eq } | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"FStar.Class.Eq.Raw.deq",
"FStar.Class.Eq.Raw.Mkdeq",
"Prims.list",
"FStar.Class.Eq.Raw.eqList",
"FStar.Class.Eq.Raw.eq"
] | [] | (*
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 | false | false | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_list: deq 'a -> deq (list 'a) | [] | FStar.Class.Eq.Raw.eq_list | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Class.Eq.Raw.deq 'a -> FStar.Class.Eq.Raw.deq (Prims.list 'a) | {
"end_col": 17,
"end_line": 41,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val unit_has_eq:deq unit | [
{
"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
}
] | false | instance unit_has_eq : deq unit = eq_instance_of_eqtype | [@@ FStar.Tactics.Typeclasses.tcinstance]
val unit_has_eq:deq unit
[@@ FStar.Tactics.Typeclasses.tcinstance]
let unit_has_eq:deq unit = | false | null | false | eq_instance_of_eqtype | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"FStar.Class.Eq.Raw.eq_instance_of_eqtype",
"Prims.unit"
] | [] | (*
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. | false | true | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val unit_has_eq:deq unit | [] | FStar.Class.Eq.Raw.unit_has_eq | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Class.Eq.Raw.deq Prims.unit | {
"end_col": 55,
"end_line": 30,
"start_col": 34,
"start_line": 30
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val int_has_eq:deq int | [
{
"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
}
] | false | instance int_has_eq : deq int = eq_instance_of_eqtype | [@@ FStar.Tactics.Typeclasses.tcinstance]
val int_has_eq:deq int
[@@ FStar.Tactics.Typeclasses.tcinstance]
let int_has_eq:deq int = | false | null | false | eq_instance_of_eqtype | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"FStar.Class.Eq.Raw.eq_instance_of_eqtype",
"Prims.int"
] | [] | (*
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 | false | true | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val int_has_eq:deq int | [] | FStar.Class.Eq.Raw.int_has_eq | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Class.Eq.Raw.deq Prims.int | {
"end_col": 53,
"end_line": 29,
"start_col": 32,
"start_line": 29
} |
Prims.Tot | val eq_instance_of_eqtype (#a: eqtype) : deq a | [
{
"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
}
] | false | let eq_instance_of_eqtype (#a:eqtype) : deq a = {
eq = (fun x y -> x = y)
} | val eq_instance_of_eqtype (#a: eqtype) : deq a
let eq_instance_of_eqtype (#a: eqtype) : deq a = | false | null | false | { eq = (fun x y -> x = y) } | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.Class.Eq.Raw.Mkdeq",
"Prims.op_Equality",
"Prims.bool",
"FStar.Class.Eq.Raw.deq"
] | [] | (*
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;
} | false | false | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq_instance_of_eqtype (#a: eqtype) : deq a | [] | FStar.Class.Eq.Raw.eq_instance_of_eqtype | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Class.Eq.Raw.deq a | {
"end_col": 25,
"end_line": 23,
"start_col": 2,
"start_line": 23
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bool_has_eq:deq bool | [
{
"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
}
] | false | instance bool_has_eq : deq bool = eq_instance_of_eqtype | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bool_has_eq:deq bool
[@@ FStar.Tactics.Typeclasses.tcinstance]
let bool_has_eq:deq bool = | false | null | false | eq_instance_of_eqtype | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"FStar.Class.Eq.Raw.eq_instance_of_eqtype",
"Prims.bool"
] | [] | (*
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 | false | true | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bool_has_eq:deq bool | [] | FStar.Class.Eq.Raw.bool_has_eq | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Class.Eq.Raw.deq Prims.bool | {
"end_col": 55,
"end_line": 31,
"start_col": 34,
"start_line": 31
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val string_has_eq:deq string | [
{
"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
}
] | false | instance string_has_eq : deq string = eq_instance_of_eqtype | [@@ FStar.Tactics.Typeclasses.tcinstance]
val string_has_eq:deq string
[@@ FStar.Tactics.Typeclasses.tcinstance]
let string_has_eq:deq string = | false | null | false | eq_instance_of_eqtype | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"FStar.Class.Eq.Raw.eq_instance_of_eqtype",
"Prims.string"
] | [] | (*
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 | false | true | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val string_has_eq:deq string | [] | FStar.Class.Eq.Raw.string_has_eq | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Class.Eq.Raw.deq Prims.string | {
"end_col": 59,
"end_line": 32,
"start_col": 38,
"start_line": 32
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b) | [
{
"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
}
] | false | instance eq_pair (_ : deq 'a) (_ : deq 'b) : deq ('a * 'b) = {
eq = (fun (a,b) (c,d) -> eq a c && eq b d)
} | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b)
[@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_pair (_: deq 'a) (_: deq 'b) : deq ('a * 'b) = | false | null | false | { eq = (fun (a, b) (c, d) -> eq a c && eq b d) } | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"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"
] | [] | (*
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;
} | false | false | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b) | [] | FStar.Class.Eq.Raw.eq_pair | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Class.Eq.Raw.deq 'a -> _: FStar.Class.Eq.Raw.deq 'b -> FStar.Class.Eq.Raw.deq ('a * 'b) | {
"end_col": 44,
"end_line": 45,
"start_col": 2,
"start_line": 45
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_option: deq 'a -> deq (option 'a) | [
{
"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
}
] | false | 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);
} | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_option: deq 'a -> deq (option 'a)
[@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_option (_: deq 'a) : deq (option 'a) = | false | null | false | {
eq
=
(fun o1 o2 ->
match o1, o2 with
| None, None -> true
| Some x, Some y -> eq x y
| _, _ -> false)
} | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"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"
] | [] | (*
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)
} | false | false | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_option: deq 'a -> deq (option 'a) | [] | FStar.Class.Eq.Raw.eq_option | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Class.Eq.Raw.deq 'a -> FStar.Class.Eq.Raw.deq (FStar.Pervasives.Native.option 'a) | {
"end_col": 21,
"end_line": 53,
"start_col": 2,
"start_line": 49
} |
Prims.Tot | val eqList (#a: _) (eq: (a -> a -> bool)) (xs ys: list a) : Tot bool | [
{
"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
}
] | false | 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 | val eqList (#a: _) (eq: (a -> a -> bool)) (xs ys: list a) : Tot bool
let rec eqList #a (eq: (a -> a -> bool)) (xs: list a) (ys: list a) : Tot bool = | false | null | false | match xs, ys with
| [], [] -> true
| x :: xs, y :: ys -> eq x y && eqList eq xs ys
| _, _ -> false | {
"checked_file": "FStar.Class.Eq.Raw.fst.checked",
"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"
} | [
"total"
] | [
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_AmpAmp",
"FStar.Class.Eq.Raw.eqList"
] | [] | (*
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 | false | false | FStar.Class.Eq.Raw.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eqList (#a: _) (eq: (a -> a -> bool)) (xs ys: list a) : Tot bool | [
"recursion"
] | FStar.Class.Eq.Raw.eqList | {
"file_name": "ulib/FStar.Class.Eq.Raw.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | eq: (_: a -> _: a -> Prims.bool) -> xs: Prims.list a -> ys: Prims.list a -> Prims.bool | {
"end_col": 17,
"end_line": 38,
"start_col": 2,
"start_line": 35
} |
FStar.HyperStack.ST.ST | val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init | val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
let createL_mglobal #a init = | true | null | false | B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Prims.list",
"LowStar.Monotonic.Buffer.mgcmalloc_of_list",
"LowStar.Buffer.trivial_preorder",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.lmbuffer",
"FStar.Pervasives.normalize_term",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Prims.l_and",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Lib.Buffer.buffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init)) | [] | Lib.Buffer.createL_mglobal | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | init: Prims.list a -> FStar.HyperStack.ST.ST (Lib.Buffer.buffer a) | {
"end_col": 60,
"end_line": 67,
"start_col": 2,
"start_line": 67
} |
FStar.HyperStack.ST.Stack | val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl | val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_nospec #h0 #a #len n buf impl = | true | null | false | let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Lib.Buffer.modifies1",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1) | [] | Lib.Buffer.loop_nospec | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Lib.IntTypes.size_t ->
buf: Lib.Buffer.lbuffer a len ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 158,
"start_col": 40,
"start_line": 156
} |
FStar.HyperStack.ST.Stack | val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a)) | val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
let recall #t #a #len b = | true | null | false | match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"LowStar.Monotonic.Buffer.recall",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"Prims.unit",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = () | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b) | [] | Lib.Buffer.recall | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer_t t a len -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 48,
"end_line": 53,
"start_col": 2,
"start_line": 50
} |
FStar.HyperStack.ST.Stack | val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1) | val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
let upd #a #len b i v = | true | null | false | let h0 = ST.get () in
B.upd (b <: buffer a) i v;
let h1 = ST.get () in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Prims.op_LessThan",
"Prims._assert",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Prims.unit",
"LowStar.Monotonic.Buffer.modifies",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.upd",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x) | [] | Lib.Buffer.upd | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer a len -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v len} -> x: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 33,
"end_line": 45,
"start_col": 23,
"start_line": 40
} |
FStar.HyperStack.ST.Stack | val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl | val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl = | true | null | false | let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Lib.Buffer.modifies2",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Lib.Buffer.modifies",
"Lib.Buffer.union",
"Lib.Buffer.loc",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1) | [] | Lib.Buffer.loop_nospec2 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Lib.IntTypes.size_t ->
buf1: Lib.Buffer.lbuffer a1 len1 ->
buf2: Lib.Buffer.lbuffer a2 len2 ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 162,
"start_col": 59,
"start_line": 160
} |
FStar.HyperStack.ST.Stack | val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n | val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
let sub #t #a #len b start n = | true | null | false | match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Buffer.sub",
"Lib.Buffer.buffer",
"FStar.Ghost.hide",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"LowStar.ImmutableBuffer.isub",
"Lib.Buffer.ibuffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"LowStar.ConstBuffer.sub",
"Lib.Buffer.cbuffer",
"LowStar.ConstBuffer.const_buffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = () | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n) | [] | Lib.Buffer.sub | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer_t t a len ->
start: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.v len}
-> FStar.HyperStack.ST.Stack (Lib.Buffer.lbuffer_t t a n) | {
"end_col": 44,
"end_line": 32,
"start_col": 2,
"start_line": 29
} |
FStar.HyperStack.ST.Stack | val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl | val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl = | true | null | false | let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Lib.Buffer.modifies3",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Lib.Buffer.modifies",
"Lib.Buffer.union",
"Lib.Buffer.loc",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1) | [] | Lib.Buffer.loop_nospec3 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Lib.IntTypes.size_t ->
buf1: Lib.Buffer.lbuffer a1 len1 ->
buf2: Lib.Buffer.lbuffer a2 len2 ->
buf3: Lib.Buffer.lbuffer a3 len3 ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 166,
"start_col": 74,
"start_line": 164
} |
FStar.HyperStack.ST.StackInline | val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create #a clen init =
B.alloca init (normalize_term clen) | val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
let create #a clen init = | true | null | false | B.alloca init (normalize_term clen) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"LowStar.Buffer.alloca",
"FStar.Pervasives.normalize_term",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"Lib.Buffer.lbuffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a)) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init)) | [] | Lib.Buffer.create | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_t -> init: a -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer a len) | {
"end_col": 37,
"end_line": 56,
"start_col": 2,
"start_line": 56
} |
FStar.HyperStack.ST.Stack | val salloc_nospec:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl | val salloc_nospec:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1)
let salloc_nospec #a #res h len x footprint impl = | true | null | false | salloc1 #a #res h len x footprint (fun _ _ -> True) impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Ghost.erased",
"LowStar.Monotonic.Buffer.loc",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.l_not",
"FStar.Monotonic.HyperStack.live_region",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.live",
"FStar.Seq.Base.seq",
"LowStar.Monotonic.Buffer.as_seq",
"Lib.Sequence.create",
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_all_regions_from",
"FStar.Ghost.reveal",
"Lib.Buffer.salloc1",
"Prims.l_True"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val salloc_nospec:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1) | [] | Lib.Buffer.salloc_nospec | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
len: Lib.IntTypes.size_t{0 < Lib.IntTypes.v len} ->
x: a ->
footprint: FStar.Ghost.erased LowStar.Monotonic.Buffer.loc ->
impl: (b: Lib.Buffer.lbuffer a len -> FStar.HyperStack.ST.Stack res)
-> FStar.HyperStack.ST.Stack res | {
"end_col": 58,
"end_line": 217,
"start_col": 2,
"start_line": 217
} |
FStar.HyperStack.ST.Stack | val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i | val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
let index #t #a #len b i = | true | null | false | match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer_t",
"Prims.op_LessThan",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.index",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i)) | [] | Lib.Buffer.index | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer_t t a len -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v len}
-> FStar.HyperStack.ST.Stack a | {
"end_col": 40,
"end_line": 38,
"start_col": 2,
"start_line": 35
} |
FStar.HyperStack.ST.ST | val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s) | val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
let recall_contents #a #len b s = | true | null | false | B.recall_p (CB.to_ibuffer b) (cpred s) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.glbuffer",
"Lib.Sequence.lseq",
"LowStar.Monotonic.Buffer.recall_p",
"LowStar.ImmutableBuffer.immutable_preorder",
"LowStar.ConstBuffer.to_ibuffer",
"Lib.Buffer.cpred",
"Prims.unit"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s) | [] | Lib.Buffer.recall_contents | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.glbuffer a len -> s: Lib.Sequence.lseq a (Lib.IntTypes.v len)
-> FStar.HyperStack.ST.ST Prims.unit | {
"end_col": 40,
"end_line": 70,
"start_col": 2,
"start_line": 70
} |
FStar.HyperStack.ST.Stack | val salloc1:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b : buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h /\
(forall (h1 h2 h3:mem) (r:res).
(B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2) ==> spec r h3))
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl | val salloc1:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b : buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h /\
(forall (h1 h2 h3:mem) (r:res).
(B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2) ==> spec r h3))
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1)
let salloc1 #a #res h len x footprint spec impl = | true | null | false | salloc1_with_inv #a
#res
h
len
x
footprint
spec
(fun h1 h2 h3 (r: res) ->
assert (spec r h2);
assert (spec r h3))
impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Ghost.erased",
"LowStar.Monotonic.Buffer.loc",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.l_not",
"FStar.Monotonic.HyperStack.live_region",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.live",
"FStar.Seq.Base.seq",
"LowStar.Monotonic.Buffer.as_seq",
"Lib.Sequence.create",
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_all_regions_from",
"FStar.Ghost.reveal",
"Lib.Buffer.salloc1_with_inv",
"Prims._assert",
"Prims.unit"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val salloc1:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b : buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h /\
(forall (h1 h2 h3:mem) (r:res).
(B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2) ==> spec r h3))
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1) | [] | Lib.Buffer.salloc1 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
len: Lib.IntTypes.size_t{0 < Lib.IntTypes.v len} ->
x: a ->
footprint: FStar.Ghost.erased LowStar.Monotonic.Buffer.loc ->
spec: (_: res -> _: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0) ->
impl: (b: Lib.Buffer.lbuffer a len -> FStar.HyperStack.ST.Stack res)
-> FStar.HyperStack.ST.Stack res | {
"end_col": 8,
"end_line": 213,
"start_col": 2,
"start_line": 211
} |
FStar.HyperStack.ST.StackInline | val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let createL #a init =
B.alloca_of_list init | val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
let createL #a init = | true | null | false | B.alloca_of_list init | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Prims.list",
"FStar.Pervasives.normalize",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.max_size_t",
"LowStar.Buffer.alloca_of_list",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"Lib.IntTypes.size_nat"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init)) | [] | Lib.Buffer.createL | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
init:
Prims.list a
{FStar.Pervasives.normalize (FStar.List.Tot.Base.length init <= Lib.IntTypes.max_size_t)}
-> FStar.HyperStack.ST.StackInline
(Lib.Buffer.lbuffer a
(Lib.IntTypes.size (FStar.Pervasives.normalize_term (FStar.List.Tot.Base.length init)))) | {
"end_col": 23,
"end_line": 61,
"start_col": 2,
"start_line": 61
} |
FStar.HyperStack.ST.Stack | val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1)
let loop_refl h0 n a_spec refl footprint spec impl = | true | null | false | let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"FStar.Ghost.erased",
"LowStar.Monotonic.Buffer.loc",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Lib.Buffer.loop_refl_inv",
"FStar.Ghost.reveal",
"Prims.op_Addition",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1) | [] | Lib.Buffer.loop_refl | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
a_spec: Type ->
refl: (_: FStar.Monotonic.HyperStack.mem -> Prims.GTot a_spec) ->
footprint: FStar.Ghost.erased LowStar.Monotonic.Buffer.loc ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} -> _: a_spec -> a_spec)) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 180,
"start_col": 52,
"start_line": 178
} |
FStar.HyperStack.ST.Stack | val salloc1_with_inv:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> spec_inv:(h1:mem -> h2:mem -> h3:mem -> r:res -> Lemma
(requires
B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2)
(ensures spec r h3))
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r | val salloc1_with_inv:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> spec_inv:(h1:mem -> h2:mem -> h3:mem -> r:res -> Lemma
(requires
B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2)
(ensures spec r h3))
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1)
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl = | true | null | false | let h0 = ST.get () in
push_frame ();
let h1 = ST.get () in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get () in
let r = impl b in
let h3 = ST.get () in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get () in
pop_frame ();
let h5 = ST.get () in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Ghost.erased",
"LowStar.Monotonic.Buffer.loc",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_all_regions_from",
"FStar.Monotonic.HyperStack.get_tip",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc_region_only",
"Prims.l_not",
"FStar.Monotonic.HyperStack.live_region",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Lib.Buffer.lbuffer",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.live",
"FStar.Seq.Base.seq",
"LowStar.Monotonic.Buffer.as_seq",
"Lib.Sequence.create",
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"LowStar.Monotonic.Buffer.popped_modifies",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.pop_frame",
"Lib.Memzero0.memzero",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"LowStar.Monotonic.Buffer.fresh_frame_modifies",
"FStar.HyperStack.ST.push_frame"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0" | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val salloc1_with_inv:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> spec_inv:(h1:mem -> h2:mem -> h3:mem -> r:res -> Lemma
(requires
B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2)
(ensures spec r h3))
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1) | [] | Lib.Buffer.salloc1_with_inv | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
len: Lib.IntTypes.size_t{0 < Lib.IntTypes.v len} ->
x: a ->
footprint: FStar.Ghost.erased LowStar.Monotonic.Buffer.loc ->
spec: (_: res -> _: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0) ->
spec_inv:
(
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem ->
h3: FStar.Monotonic.HyperStack.mem ->
r: res
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.modifies LowStar.Monotonic.Buffer.loc_none h h1 /\
LowStar.Monotonic.Buffer.modifies (LowStar.Monotonic.Buffer.loc_union (LowStar.Monotonic.Buffer.loc_all_regions_from
false
(FStar.Monotonic.HyperStack.get_tip h1))
(FStar.Ghost.reveal footprint))
h1
h2 /\
LowStar.Monotonic.Buffer.modifies (LowStar.Monotonic.Buffer.loc_region_only false
(FStar.Monotonic.HyperStack.get_tip h1))
h2
h3 /\
~(FStar.Monotonic.HyperStack.live_region h (FStar.Monotonic.HyperStack.get_tip h1)) /\
spec r h2) (ensures spec r h3)) ->
impl: (b: Lib.Buffer.lbuffer a len -> FStar.HyperStack.ST.Stack res)
-> FStar.HyperStack.ST.Stack res | {
"end_col": 3,
"end_line": 207,
"start_col": 67,
"start_line": 192
} |
FStar.HyperStack.ST.ST | val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init) | val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
let createL_global #a init = | true | null | false | CB.of_ibuffer (IB.igcmalloc_of_list #a root init) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Prims.list",
"FStar.Pervasives.normalize",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.max_size_t",
"LowStar.ConstBuffer.of_ibuffer",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"LowStar.ImmutableBuffer.ibuffer",
"LowStar.ImmutableBuffer.igcmalloc_of_list",
"FStar.Monotonic.HyperHeap.root",
"LowStar.ImmutableBuffer.libuffer",
"Prims.nat",
"FStar.Seq.Properties.seq_of_list",
"Prims.l_and",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.ImmutableBuffer.immutable_preorder",
"LowStar.Monotonic.Buffer.recallable"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init)) | [] | Lib.Buffer.createL_global | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
init:
Prims.list a
{FStar.Pervasives.normalize (FStar.List.Tot.Base.length init <= Lib.IntTypes.max_size_t)}
-> FStar.HyperStack.ST.ST
(Lib.Buffer.glbuffer a
(Lib.IntTypes.size (FStar.Pervasives.normalize_term (FStar.List.Tot.Base.length init)))) | {
"end_col": 51,
"end_line": 64,
"start_col": 2,
"start_line": 64
} |
FStar.HyperStack.ST.Stack | val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1)
let loop h0 n a_spec refl footprint spec impl = | true | null | false | let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.loc",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.unit",
"Lib.Buffer.loop_inv",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1) | [] | Lib.Buffer.loop | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
a_spec: (i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} -> Type) ->
refl:
(_: FStar.Monotonic.HyperStack.mem -> i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n}
-> Prims.GTot (a_spec i)) ->
footprint:
(i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} -> Prims.GTot LowStar.Monotonic.Buffer.loc) ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} -> _: a_spec i -> a_spec (i + 1))) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 176,
"start_col": 47,
"start_line": 174
} |
FStar.HyperStack.ST.Stack | val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w | val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w = | true | null | false | Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.Sequence.lseq",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Prims.int",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Bang",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Math.Lemmas.lemma_mult_le_right"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | [] | Lib.Buffer.loopi_blocks_f | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inpLen: Lib.IntTypes.size_t ->
inp: Lib.Buffer.lbuffer a inpLen ->
spec_f:
(
i: Prims.nat{i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize) ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
f:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a blocksize ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
nb: Lib.IntTypes.size_t{Lib.IntTypes.v nb == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb} ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 13,
"end_line": 255,
"start_col": 2,
"start_line": 250
} |
FStar.HyperStack.ST.Stack | val loop1:
#b:Type
-> #blen:size_t
-> h0:mem
-> n:size_t
-> write:lbuffer b blen
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop1_inv h0 n b blen write spec (v i))
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v n)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl | val loop1:
#b:Type
-> #blen:size_t
-> h0:mem
-> n:size_t
-> write:lbuffer b blen
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop1_inv h0 n b blen write spec (v i))
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v n))
let loop1 #b #blen h0 n acc spec impl = | true | null | false | let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Prims.unit",
"Lib.Buffer.loop1_inv",
"Prims.op_Addition",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop1:
#b:Type
-> #blen:size_t
-> h0:mem
-> n:size_t
-> write:lbuffer b blen
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop1_inv h0 n b blen write spec (v i))
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v n)) | [] | Lib.Buffer.loop1 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
write: Lib.Buffer.lbuffer b blen ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen))) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 184,
"start_col": 39,
"start_line": 182
} |
FStar.HyperStack.ST.Stack | val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len))) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len | val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
let memset #a #blen b init len = | true | null | false | B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.fill",
"FStar.Seq.Base.seq",
"Prims.l_True",
"Prims.logical",
"Prims.unit"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len)) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len))) | [] | Lib.Buffer.memset | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer a blen ->
w: a ->
len: Lib.IntTypes.size_t{Lib.IntTypes.v len <= Lib.IntTypes.v blen}
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 60,
"end_line": 92,
"start_col": 2,
"start_line": 92
} |
FStar.HyperStack.ST.Stack | val mapT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a -> Tot b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map f (as_seq h0 i)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x) | val mapT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a -> Tot b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map f (as_seq h0 i))
let mapT #t #a #b clen out f inp = | true | null | false | let h0 = ST.get () in
[@@ inline_let ]let spec h = Seq.map_inner f (as_seq h inp) in
fill h0
clen
out
spec
(fun i ->
let x = inp.(i) in
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.fill",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Lib.Buffer.lemma_eq_disjoint",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Access",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.Sequence.map_inner",
"Lib.Buffer.as_seq"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mapT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a -> Tot b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map f (as_seq h0 i)) | [] | Lib.Buffer.mapT | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer b clen ->
f: (_: a -> b) ->
i: Lib.Buffer.lbuffer_t t a clen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 9,
"end_line": 526,
"start_col": 34,
"start_line": 518
} |
FStar.HyperStack.ST.Stack | val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w | val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w = | true | null | false | assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Lib.Sequence.lseq",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Prims.int",
"Prims.op_Division",
"Prims.op_LessThan",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Bang",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Addition"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | false | false | Lib.Buffer.fst | {
"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": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w)) | [] | Lib.Buffer.loop_blocks_f | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inpLen: Lib.IntTypes.size_t ->
inp: Lib.Buffer.lbuffer a inpLen ->
spec_f:
(
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize) ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
f:
(inp: Lib.Buffer.lbuffer a blocksize -> w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
nb: Lib.IntTypes.size_t{Lib.IntTypes.v nb == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb} ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 11,
"end_line": 339,
"start_col": 2,
"start_line": 337
} |
FStar.HyperStack.ST.Stack | val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf) | val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
let update_sub_f #a #len h0 buf start n spec f = | true | null | false | let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Prims.unit",
"Prims.eq2",
"Prims.l_and",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.Buffer.as_seq",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.gsub",
"Lib.Sequence.lemma_update_sub",
"LowStar.Monotonic.Buffer.modifies_buffer_elim",
"LowStar.Buffer.trivial_preorder",
"LowStar.Buffer.gsub",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Subtraction_Bang",
"FStar.UInt32.__uint_to_t",
"Prims._assert",
"Prims.int",
"Prims.op_Subtraction",
"FStar.HyperStack.ST.get",
"Lib.Buffer.sub"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src)) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0)) | [] | Lib.Buffer.update_sub_f | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
buf: Lib.Buffer.lbuffer a len ->
start: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.v len} ->
spec: (_: FStar.Monotonic.HyperStack.mem -> Prims.GTot (Lib.Sequence.lseq a (Lib.IntTypes.v n))) ->
f: (_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 85,
"end_line": 134,
"start_col": 48,
"start_line": 126
} |
FStar.HyperStack.ST.Stack | val loop2:
#b0:Type
-> #blen0:size_t
-> #b1:Type
-> #blen1:size_t
-> h0:mem
-> n:size_t
-> write0:lbuffer b0 blen0
-> write1:lbuffer b1 blen1
-> spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i))
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v n)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl | val loop2:
#b0:Type
-> #blen0:size_t
-> #b1:Type
-> #blen1:size_t
-> h0:mem
-> n:size_t
-> write0:lbuffer b0 blen0
-> write1:lbuffer b1 blen1
-> spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i))
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v n))
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl = | true | null | false | let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.lseq",
"Prims.unit",
"Lib.Buffer.loop2_inv",
"Prims.op_Addition",
"Lib.Loops.for",
"Lib.IntTypes.size",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop2:
#b0:Type
-> #blen0:size_t
-> #b1:Type
-> #blen1:size_t
-> h0:mem
-> n:size_t
-> write0:lbuffer b0 blen0
-> write1:lbuffer b1 blen1
-> spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i))
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v n)) | [] | Lib.Buffer.loop2 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
write0: Lib.Buffer.lbuffer b0 blen0 ->
write1: Lib.Buffer.lbuffer b1 blen1 ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} ->
_:
(Lib.Sequence.lseq b0 (Lib.IntTypes.v blen0) *
Lib.Sequence.lseq b1 (Lib.IntTypes.v blen1))
-> Lib.Sequence.lseq b0 (Lib.IntTypes.v blen0) *
Lib.Sequence.lseq b1 (Lib.IntTypes.v blen1))) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 35,
"end_line": 188,
"start_col": 58,
"start_line": 186
} |
FStar.HyperStack.ST.Stack | val loopi_blocks_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 -> modifies1 write h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w | val loopi_blocks_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 -> modifies1 write h0 h1)
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w = | true | null | false | let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w (fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Dot",
"Lib.Buffer.loop_nospec",
"Lib.Buffer.loopi_blocks_f_nospec",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Percent_Dot",
"Lib.IntTypes.op_Slash_Dot"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w | false | false | Lib.Buffer.fst | {
"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": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loopi_blocks_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 -> modifies1 write h0 h1) | [] | Lib.Buffer.loopi_blocks_nospec | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inpLen: Lib.IntTypes.size_t ->
inp: Lib.Buffer.lbuffer a inpLen ->
f:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a blocksize ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
l:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
len:
Lib.IntTypes.size_t
{Lib.IntTypes.v len == Lib.IntTypes.v inpLen % Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a len ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
write: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 17,
"end_line": 306,
"start_col": 57,
"start_line": 299
} |
FStar.HyperStack.ST.Stack | val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl | val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_range_nospec #h0 #a #len start n buf impl = | true | null | false | let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.unit",
"Lib.Buffer.modifies1",
"Lib.Loops.for",
"Lib.IntTypes.op_Plus_Dot",
"Prims.nat",
"Lib.IntTypes.add_mod",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1) | [] | Lib.Buffer.loop_range_nospec | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
start: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.max_size_t} ->
buf: Lib.Buffer.lbuffer a len ->
impl:
(
i:
Lib.IntTypes.size_t
{ Lib.IntTypes.v start <= Lib.IntTypes.v i /\
Lib.IntTypes.v i < Lib.IntTypes.v start + Lib.IntTypes.v n }
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 43,
"end_line": 170,
"start_col": 52,
"start_line": 168
} |
FStar.HyperStack.ST.Stack | val mapi:
#a:Type
-> #b:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer b clen
-> spec_f:(mem -> GTot (i:size_nat{i < v clen} -> a -> b))
-> f:(i:size_t{v i < v clen} -> x:a -> Stack b
(requires fun h -> modifies1 o h0 h)
(ensures fun h y h1 -> h == h1 /\ y == spec_f h0 (v i) x))
-> i:lbuffer a clen ->
Stack unit
(requires fun h -> h == h0 /\ live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h _ h1 ->
modifies1 o h h1 /\
as_seq h1 o == Seq.mapi (spec_f h0) (as_seq h i)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mapi #a #b h0 clen out spec_f f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi) | val mapi:
#a:Type
-> #b:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer b clen
-> spec_f:(mem -> GTot (i:size_nat{i < v clen} -> a -> b))
-> f:(i:size_t{v i < v clen} -> x:a -> Stack b
(requires fun h -> modifies1 o h0 h)
(ensures fun h y h1 -> h == h1 /\ y == spec_f h0 (v i) x))
-> i:lbuffer a clen ->
Stack unit
(requires fun h -> h == h0 /\ live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h _ h1 ->
modifies1 o h h1 /\
as_seq h1 o == Seq.mapi (spec_f h0) (as_seq h i))
let mapi #a #b h0 clen out spec_f f inp = | true | null | false | let h0 = ST.get () in
fill h0
clen
out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in
f i xi) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.modifies1",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.fill",
"Lib.Sequence.mapi_inner",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Buffer.op_Array_Access",
"Prims.unit",
"Lib.Buffer.lemma_eq_disjoint",
"FStar.HyperStack.ST.get"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i))
let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mapi:
#a:Type
-> #b:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer b clen
-> spec_f:(mem -> GTot (i:size_nat{i < v clen} -> a -> b))
-> f:(i:size_t{v i < v clen} -> x:a -> Stack b
(requires fun h -> modifies1 o h0 h)
(ensures fun h y h1 -> h == h1 /\ y == spec_f h0 (v i) x))
-> i:lbuffer a clen ->
Stack unit
(requires fun h -> h == h0 /\ live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h _ h1 ->
modifies1 o h h1 /\
as_seq h1 o == Seq.mapi (spec_f h0) (as_seq h i)) | [] | Lib.Buffer.mapi | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer b clen ->
spec_f:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v clen} -> _: a -> b)) ->
f:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v clen} -> x: a
-> FStar.HyperStack.ST.Stack b) ->
i: Lib.Buffer.lbuffer a clen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 33,
"end_line": 556,
"start_col": 41,
"start_line": 549
} |
FStar.HyperStack.ST.Stack | val mapiT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(i:size_t{v i < v clen} -> x:a -> b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.mapi (fun i -> f (size i)) (as_seq h0 i)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi) | val mapiT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(i:size_t{v i < v clen} -> x:a -> b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.mapi (fun i -> f (size i)) (as_seq h0 i))
let mapiT #t #a #b clen out f inp = | true | null | false | let h0 = ST.get () in
fill h0
clen
out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in
f i xi) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.fill",
"FStar.Monotonic.HyperStack.mem",
"Lib.Sequence.mapi_inner",
"Prims.nat",
"Lib.IntTypes.size",
"Lib.Buffer.as_seq",
"Lib.IntTypes.size_nat",
"Lib.Buffer.op_Array_Access",
"Prims.unit",
"Lib.Buffer.lemma_eq_disjoint",
"FStar.HyperStack.ST.get"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i)) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mapiT:
#t:buftype
-> #a:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(i:size_t{v i < v clen} -> x:a -> b)
-> i:lbuffer_t t a clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ eq_or_disjoint o i)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.mapi (fun i -> f (size i)) (as_seq h0 i)) | [] | Lib.Buffer.mapiT | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer b clen ->
f: (i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v clen} -> x: a -> b) ->
i: Lib.Buffer.lbuffer_t t a clen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 33,
"end_line": 547,
"start_col": 35,
"start_line": 540
} |
FStar.HyperStack.ST.Stack | val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len)) | val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
let copy #t #a #len o i = | true | null | false | match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.Buffer.lbuffer_t",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Prims.op_Subtraction",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.l_or",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.slice",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.BufferOps.blit",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"FStar.UInt32.__uint_to_t",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i) | [] | Lib.Buffer.copy | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Lib.Buffer.lbuffer a len -> i: Lib.Buffer.lbuffer_t t a len
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 83,
"end_line": 89,
"start_col": 2,
"start_line": 74
} |
FStar.HyperStack.ST.Stack | val create8: #a:Type0 -> st:lbuffer a 8ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create8 #a st v0 v1 v2 v3 v4 v5 v6 v7 =
let h0 = ST.get () in
st.(0ul) <- v0;
st.(1ul) <- v1;
st.(2ul) <- v2;
st.(3ul) <- v3;
st.(4ul) <- v4;
st.(5ul) <- v5;
st.(6ul) <- v6;
st.(7ul) <- v7;
let h1 = ST.get () in
assert (Seq.equal (as_seq h1 st) (Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7)) | val create8: #a:Type0 -> st:lbuffer a 8ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7)
let create8 #a st v0 v1 v2 v3 v4 v5 v6 v7 = | true | null | false | let h0 = ST.get () in
st.(0ul) <- v0;
st.(1ul) <- v1;
st.(2ul) <- v2;
st.(3ul) <- v3;
st.(4ul) <- v4;
st.(5ul) <- v5;
st.(6ul) <- v6;
st.(7ul) <- v7;
let h1 = ST.get () in
assert (Seq.equal (as_seq h1 st) (Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Prims._assert",
"Lib.Sequence.equal",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.create8",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i))
let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
let mapi #a #b h0 clen out spec_f f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
#reset-options "--z3rlimit 500 --max_fuel 2"
let map_blocks_multi #t #a h0 bs nb inp output spec_f impl_f =
Math.Lemmas.multiple_division_lemma (v nb) (v bs);
[@inline_let]
let refl h (i:nat{i <= v nb}) : GTot (Seq.map_blocks_a a (v bs) (v nb) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v nb);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v nb}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0) in
let h0 = ST.get () in
loop h0 nb (Seq.map_blocks_a a (v bs) (v nb)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v nb) (Seq.map_blocks_a a (v bs) (v nb))
(Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v nb);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
val div_mul_le: b:pos -> a:nat -> Lemma
((a / b) * b <= a)
let div_mul_le b a = ()
#reset-options "--z3rlimit 400 --fuel 0 --ifuel 0"
let size_gt_0_neq_0 (x: size_t): Lemma (requires v x > 0) (ensures v x <> 0) = ()
let map_blocks #t #a h0 len blocksize inp output spec_f spec_l impl_f impl_l =
div_mul_le (v blocksize) (v len);
size_gt_0_neq_0 blocksize;
let nb = len /. blocksize in
let rem = len %. blocksize in
let blen = nb *! blocksize in
Math.Lemmas.lemma_div_mod (v len) (v blocksize);
Math.Lemmas.multiple_division_lemma (v nb) (v blocksize);
Math.Lemmas.swap_mul (v len / v blocksize) (v blocksize);
Math.Lemmas.multiply_fractions (v len) (v blocksize);
let ib = sub inp 0ul blen in
let ob = sub output 0ul blen in
let il = sub inp blen rem in
let ol = sub inp blen rem in
map_blocks_multi #t #a h0 blocksize nb ib ob spec_f impl_f;
if rem >. 0ul then
(impl_l nb;
let h1 = ST.get() in
FStar.Seq.lemma_split (as_seq h1 output) (v nb * v blocksize))
else ()
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create8: #a:Type0 -> st:lbuffer a 8ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7) | [] | Lib.Buffer.create8 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | st: Lib.Buffer.lbuffer a 8ul -> v0: a -> v1: a -> v2: a -> v3: a -> v4: a -> v5: a -> v6: a -> v7: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 73,
"end_line": 626,
"start_col": 43,
"start_line": 615
} |
FStar.HyperStack.ST.Stack | val map2T:
#t1:buftype
-> #t2:buftype
-> #a1:Type
-> #a2:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a1 -> a2 -> Tot b)
-> i1:lbuffer_t t1 a1 clen
-> i2:lbuffer_t t2 a2 clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i1 /\ live h0 i2 /\
eq_or_disjoint o i1 /\ eq_or_disjoint o i2)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map2 f (as_seq h0 i1) (as_seq h0 i2)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i)) | val map2T:
#t1:buftype
-> #t2:buftype
-> #a1:Type
-> #a2:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a1 -> a2 -> Tot b)
-> i1:lbuffer_t t1 a1 clen
-> i2:lbuffer_t t2 a2 clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i1 /\ live h0 i2 /\
eq_or_disjoint o i1 /\ eq_or_disjoint o i2)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map2 f (as_seq h0 i1) (as_seq h0 i2))
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 = | true | null | false | let h0 = ST.get () in
[@@ inline_let ]let spec (h: mem) =
Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2)
in
fill h0
clen
out
spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.fill",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.op_Array_Access",
"Prims.unit",
"Lib.Buffer.lemma_eq_disjoint",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.Sequence.map2_inner",
"Lib.Buffer.as_seq"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map2T:
#t1:buftype
-> #t2:buftype
-> #a1:Type
-> #a2:Type
-> #b:Type
-> clen:size_t
-> o:lbuffer b clen
-> f:(a1 -> a2 -> Tot b)
-> i1:lbuffer_t t1 a1 clen
-> i2:lbuffer_t t2 a2 clen ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i1 /\ live h0 i2 /\
eq_or_disjoint o i1 /\ eq_or_disjoint o i2)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.map2 f (as_seq h0 i1) (as_seq h0 i2)) | [] | Lib.Buffer.map2T | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer b clen ->
f: (_: a1 -> _: a2 -> b) ->
i1: Lib.Buffer.lbuffer_t t1 a1 clen ->
i2: Lib.Buffer.lbuffer_t t2 a2 clen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 26,
"end_line": 538,
"start_col": 51,
"start_line": 529
} |
FStar.HyperStack.ST.Stack | val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s) | val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
let concat2 #a #t0 #t1 len0 s0 len1 s1 s = | true | null | false | let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Sequence.lemma_concat2",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Lib.Sequence.sub",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub",
"Lib.IntTypes.size"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1)) | [] | Lib.Buffer.concat2 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len0: Lib.IntTypes.size_t ->
s0: Lib.Buffer.lbuffer_t t0 a len0 ->
len1: Lib.IntTypes.size_t{Lib.IntTypes.v len0 + Lib.IntTypes.v len1 <= Lib.IntTypes.max_size_t} ->
s1: Lib.Buffer.lbuffer_t t1 a len1 ->
s: Lib.Buffer.lbuffer a (len0 +! len1)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 81,
"end_line": 142,
"start_col": 42,
"start_line": 136
} |
FStar.HyperStack.ST.Stack | val loopi_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(i:nat{i == v inpLen / v blocksize}
-> len:size_nat{len == v inpLen % v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v i) (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeati_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w | val loopi_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(i:nat{i == v inpLen / v blocksize}
-> len:size_nat{len == v inpLen % v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v i) (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeati_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write))
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w = | true | null | false | let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@@ inline_let ]let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b
#blen
h0
nb
w
spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.Sequence.lseq",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.size_nat",
"Prims.op_Modulus",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies1",
"Lib.Buffer.as_seq",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Bang",
"Lib.Buffer.loop1",
"Lib.Buffer.loopi_blocks_f",
"Lib.LoopCombinators.unfold_repeati",
"FStar.HyperStack.ST.get",
"Lib.Sequence.repeati_blocks_f",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Percent_Dot",
"Lib.IntTypes.op_Slash_Dot"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w | false | false | Lib.Buffer.fst | {
"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": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loopi_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(i:nat{i == v inpLen / v blocksize}
-> len:size_nat{len == v inpLen % v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v i) (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeati_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write)) | [] | Lib.Buffer.loopi_blocks | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inpLen: Lib.IntTypes.size_t ->
inp: Lib.Buffer.lbuffer a inpLen ->
spec_f:
(
i: Prims.nat{i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize) ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
spec_l:
(
i: Prims.nat{i == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
len: Lib.IntTypes.size_nat{len == Lib.IntTypes.v inpLen % Lib.IntTypes.v blocksize} ->
s: Lib.Sequence.lseq a len ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
f:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a blocksize ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
l:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
len:
Lib.IntTypes.size_t
{Lib.IntTypes.v len == Lib.IntTypes.v inpLen % Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a len ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
write: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 17,
"end_line": 297,
"start_col": 64,
"start_line": 286
} |
FStar.HyperStack.ST.Stack | val fillT:
#a:Type
-> clen:size_t
-> o:lbuffer a clen
-> spec_f:(i:size_nat{i < v clen} -> a)
-> f:(i:size_t{v i < v clen} -> r:a{r == spec_f (size_v i)}) ->
Stack unit
(requires fun h0 -> live h0 o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.createi #a (v clen) spec_f) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
) | val fillT:
#a:Type
-> clen:size_t
-> o:lbuffer a clen
-> spec_f:(i:size_nat{i < v clen} -> a)
-> f:(i:size_t{v i < v clen} -> r:a{r == spec_f (size_v i)}) ->
Stack unit
(requires fun h0 -> live h0 o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.createi #a (v clen) spec_f)
let fillT #a clen o spec_f f = | true | null | false | let open Seq in
let h0 = ST.get () in
[@@ inline_let ]let a_spec = createi_a a (v clen) spec_f in
[@@ inline_let ]let refl h i = sub (as_seq h o) 0 i in
[@@ inline_let ]let footprint i = loc o in
[@@ inline_let ]let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0
clen
a_spec
refl
footprint
spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Lib.IntTypes.size_v",
"Lib.Buffer.loop",
"FStar.Seq.Properties.lemma_split",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"Lib.LoopCombinators.unfold_repeat_gen",
"Lib.Sequence.eq_intro",
"FStar.List.Tot.Base.length",
"Prims.Nil",
"Lib.Sequence.of_list",
"Prims.nat",
"Lib.Sequence.createi_a",
"Prims.op_Addition",
"Prims.l_imp",
"Lib.Sequence.createi_pred",
"Lib.Sequence.createi_step",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"LowStar.Monotonic.Buffer.loc",
"Lib.Buffer.loc",
"Lib.Sequence.lseq",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.l_Forall",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fillT:
#a:Type
-> clen:size_t
-> o:lbuffer a clen
-> spec_f:(i:size_nat{i < v clen} -> a)
-> f:(i:size_t{v i < v clen} -> r:a{r == spec_f (size_v i)}) ->
Stack unit
(requires fun h0 -> live h0 o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.createi #a (v clen) spec_f) | [] | Lib.Buffer.fillT | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer a clen ->
spec_f: (i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v clen} -> a) ->
f:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v clen}
-> r: a{r == spec_f (Lib.IntTypes.size_v i)})
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 462,
"start_col": 2,
"start_line": 445
} |
FStar.HyperStack.ST.Stack | val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w | val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w = | true | null | false | assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Prims.int",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Star_Bang",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Addition"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0" | false | false | Lib.Buffer.fst | {
"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": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1) | [] | Lib.Buffer.loopi_blocks_f_nospec | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inpLen: Lib.IntTypes.size_t ->
inp: Lib.Buffer.lbuffer a inpLen ->
f:
(
i:
Lib.IntTypes.size_t
{Lib.IntTypes.v i < Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a blocksize ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
nb: Lib.IntTypes.size_t{Lib.IntTypes.v nb == Lib.IntTypes.v inpLen / Lib.IntTypes.v blocksize} ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb} ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 13,
"end_line": 284,
"start_col": 2,
"start_line": 282
} |
FStar.HyperStack.ST.Stack | val loop_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t
-> rem:size_t { v n_blocks * v blocksize + v rem < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks +! rem) { v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(len:size_nat{len < v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> l:(len:size_t{v len < v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w | val loop_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t
-> rem:size_t { v n_blocks * v blocksize + v rem < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks +! rem) { v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(len:size_nat{len < v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> l:(len:size_t{v len < v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write))
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w = | true | null | false | [@@ inline_let ]let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b
#blen
h0
nb
w
spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"Prims.eq2",
"Prims.int",
"Prims.op_Division",
"Lib.Buffer.length",
"Lib.Buffer.MUT",
"Lib.Sequence.lseq",
"Lib.IntTypes.size_nat",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies1",
"Lib.Buffer.as_seq",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.Buffer.loop1",
"Lib.Buffer.loop_blocks_f",
"Lib.LoopCombinators.unfold_repeati",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Lib.Sequence.repeat_blocks_f"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t
-> rem:size_t { v n_blocks * v blocksize + v rem < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks +! rem) { v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(len:size_nat{len < v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> l:(len:size_t{v len < v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write)) | [] | Lib.Buffer.loop_blocks | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
n_blocks: Lib.IntTypes.size_t ->
rem:
Lib.IntTypes.size_t
{Lib.IntTypes.v n_blocks * Lib.IntTypes.v blocksize + Lib.IntTypes.v rem < Prims.pow2 32} ->
inp:
Lib.Buffer.lbuffer a (blocksize *! n_blocks +! rem)
{Lib.IntTypes.v n_blocks == Lib.Buffer.length inp / Lib.IntTypes.v blocksize} ->
spec_f:
(
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize) ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
spec_l:
(
len: Lib.IntTypes.size_nat{len < Lib.IntTypes.v blocksize} ->
s: Lib.Sequence.lseq a len ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
f:
(inp: Lib.Buffer.lbuffer a blocksize -> w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
l:
(
len: Lib.IntTypes.size_t{Lib.IntTypes.v len < Lib.IntTypes.v blocksize} ->
inp: Lib.Buffer.lbuffer a len ->
w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
write: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 361,
"start_col": 2,
"start_line": 353
} |
FStar.HyperStack.ST.Stack | val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s) | val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s = | true | null | false | let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0)
(as_seq h0 s0)
(v len1)
(as_seq h0 s1)
(v len2)
(as_seq h0 s2)
(as_seq h2 s) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Sequence.lemma_concat3",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Lib.Sequence.sub",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub",
"Lib.IntTypes.size"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s) | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2)) | [] | Lib.Buffer.concat3 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len0: Lib.IntTypes.size_t ->
s0: Lib.Buffer.lbuffer_t t0 a len0 ->
len1: Lib.IntTypes.size_t{Lib.IntTypes.v len0 + Lib.IntTypes.v len1 <= Lib.IntTypes.max_size_t} ->
s1: Lib.Buffer.lbuffer_t t1 a len1 ->
len2:
Lib.IntTypes.size_t
{Lib.IntTypes.v len0 + Lib.IntTypes.v len1 + Lib.IntTypes.v len2 <= Lib.IntTypes.max_size_t} ->
s2: Lib.Buffer.lbuffer_t t2 a len2 ->
s: Lib.Buffer.lbuffer a (len0 +! len1 +! len2)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 105,
"end_line": 154,
"start_col": 54,
"start_line": 144
} |
FStar.HyperStack.ST.Stack | val create16: #a:Type0 -> st:lbuffer a 16ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a
-> v8:a -> v9:a -> v10:a -> v11:a
-> v12:a -> v13:a -> v14:a -> v15:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create16 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create16 #w st v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 =
let h0 = ST.get () in
st.(0ul) <- v0;
st.(1ul) <- v1;
st.(2ul) <- v2;
st.(3ul) <- v3;
st.(4ul) <- v4;
st.(5ul) <- v5;
st.(6ul) <- v6;
st.(7ul) <- v7;
st.(8ul) <- v8;
st.(9ul) <- v9;
st.(10ul) <- v10;
st.(11ul) <- v11;
st.(12ul) <- v12;
st.(13ul) <- v13;
st.(14ul) <- v14;
st.(15ul) <- v15;
let h1 = ST.get () in
assert (Seq.equal (as_seq h1 st) (Seq.create16 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15)) | val create16: #a:Type0 -> st:lbuffer a 16ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a
-> v8:a -> v9:a -> v10:a -> v11:a
-> v12:a -> v13:a -> v14:a -> v15:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create16 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15)
let create16 #w st v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 = | true | null | false | let h0 = ST.get () in
st.(0ul) <- v0;
st.(1ul) <- v1;
st.(2ul) <- v2;
st.(3ul) <- v3;
st.(4ul) <- v4;
st.(5ul) <- v5;
st.(6ul) <- v6;
st.(7ul) <- v7;
st.(8ul) <- v8;
st.(9ul) <- v9;
st.(10ul) <- v10;
st.(11ul) <- v11;
st.(12ul) <- v12;
st.(13ul) <- v13;
st.(14ul) <- v14;
st.(15ul) <- v15;
let h1 = ST.get () in
assert (Seq.equal (as_seq h1 st)
(Seq.create16 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Prims._assert",
"Lib.Sequence.equal",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.create16",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i))
let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
let mapi #a #b h0 clen out spec_f f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
#reset-options "--z3rlimit 500 --max_fuel 2"
let map_blocks_multi #t #a h0 bs nb inp output spec_f impl_f =
Math.Lemmas.multiple_division_lemma (v nb) (v bs);
[@inline_let]
let refl h (i:nat{i <= v nb}) : GTot (Seq.map_blocks_a a (v bs) (v nb) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v nb);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v nb}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0) in
let h0 = ST.get () in
loop h0 nb (Seq.map_blocks_a a (v bs) (v nb)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v nb) (Seq.map_blocks_a a (v bs) (v nb))
(Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v nb);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
val div_mul_le: b:pos -> a:nat -> Lemma
((a / b) * b <= a)
let div_mul_le b a = ()
#reset-options "--z3rlimit 400 --fuel 0 --ifuel 0"
let size_gt_0_neq_0 (x: size_t): Lemma (requires v x > 0) (ensures v x <> 0) = ()
let map_blocks #t #a h0 len blocksize inp output spec_f spec_l impl_f impl_l =
div_mul_le (v blocksize) (v len);
size_gt_0_neq_0 blocksize;
let nb = len /. blocksize in
let rem = len %. blocksize in
let blen = nb *! blocksize in
Math.Lemmas.lemma_div_mod (v len) (v blocksize);
Math.Lemmas.multiple_division_lemma (v nb) (v blocksize);
Math.Lemmas.swap_mul (v len / v blocksize) (v blocksize);
Math.Lemmas.multiply_fractions (v len) (v blocksize);
let ib = sub inp 0ul blen in
let ob = sub output 0ul blen in
let il = sub inp blen rem in
let ol = sub inp blen rem in
map_blocks_multi #t #a h0 blocksize nb ib ob spec_f impl_f;
if rem >. 0ul then
(impl_l nb;
let h1 = ST.get() in
FStar.Seq.lemma_split (as_seq h1 output) (v nb * v blocksize))
else ()
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let create8 #a st v0 v1 v2 v3 v4 v5 v6 v7 =
let h0 = ST.get () in
st.(0ul) <- v0;
st.(1ul) <- v1;
st.(2ul) <- v2;
st.(3ul) <- v3;
st.(4ul) <- v4;
st.(5ul) <- v5;
st.(6ul) <- v6;
st.(7ul) <- v7;
let h1 = ST.get () in
assert (Seq.equal (as_seq h1 st) (Seq.create8 v0 v1 v2 v3 v4 v5 v6 v7)) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create16: #a:Type0 -> st:lbuffer a 16ul
-> v0:a -> v1:a -> v2:a -> v3:a
-> v4:a -> v5:a -> v6:a -> v7:a
-> v8:a -> v9:a -> v10:a -> v11:a
-> v12:a -> v13:a -> v14:a -> v15:a ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == Seq.create16 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15) | [] | Lib.Buffer.create16 | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
st: Lib.Buffer.lbuffer a 16ul ->
v0: a ->
v1: a ->
v2: a ->
v3: a ->
v4: a ->
v5: a ->
v6: a ->
v7: a ->
v8: a ->
v9: a ->
v10: a ->
v11: a ->
v12: a ->
v13: a ->
v14: a ->
v15: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 104,
"end_line": 647,
"start_col": 74,
"start_line": 628
} |
FStar.HyperStack.ST.Stack | val loop_blocks_multi:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t { v n_blocks * v blocksize < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks) {v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks_multi #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f (as_seq h0 write)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w) | val loop_blocks_multi:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t { v n_blocks * v blocksize < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks) {v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks_multi #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f (as_seq h0 write))
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w = | true | null | false | [@@ inline_let ]let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b
#blen
h0
nb
w
spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Star_Bang",
"Prims.eq2",
"Prims.int",
"Prims.op_Division",
"Lib.Buffer.length",
"Lib.Buffer.MUT",
"Lib.Sequence.lseq",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies1",
"Lib.Buffer.as_seq",
"Lib.Buffer.loop1",
"Lib.Buffer.loop_blocks_f",
"Lib.LoopCombinators.unfold_repeati",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Lib.Sequence.repeat_blocks_f"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_blocks_multi:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t { v n_blocks * v blocksize < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks) {v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks_multi #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f (as_seq h0 write)) | [] | Lib.Buffer.loop_blocks_multi | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
n_blocks:
Lib.IntTypes.size_t{Lib.IntTypes.v n_blocks * Lib.IntTypes.v blocksize < Prims.pow2 32} ->
inp:
Lib.Buffer.lbuffer a (blocksize *! n_blocks)
{Lib.IntTypes.v n_blocks == Lib.Buffer.length inp / Lib.IntTypes.v blocksize} ->
spec_f:
(
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize) ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen)) ->
f:
(inp: Lib.Buffer.lbuffer a blocksize -> w: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit) ->
write: Lib.Buffer.lbuffer b blen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 66,
"end_line": 350,
"start_col": 2,
"start_line": 344
} |
FStar.HyperStack.ST.Stack | val fill_blocks:
#t:Type0
-> h0:mem
-> len:size_t
-> n:size_t{v n * v len <= max_size_t}
-> output:lbuffer t (n *! len)
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot
(l:B.loc{B.loc_disjoint l (loc output) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}))
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq t (v len)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
(v i + 1) * v len <= max_size_t /\
modifies (footprint (v i) |+| loc (gsub output 0ul (i *! len))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! len) len in
let s, b = spec h0 (v i) (refl h1 (v i)) in
footprint (v i + 1) `B.loc_includes` footprint (v i) /\
B.modifies (B.loc_union (footprint (v i + 1)) (loc block)) h1 h2 /\
refl h2 (v i + 1) == s /\ as_seq h2 block == b))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 ->
B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1 /\
(let s, o = Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0) in
refl h1 (v n) == s /\
as_seq #_ #t h1 output == o)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1) | val fill_blocks:
#t:Type0
-> h0:mem
-> len:size_t
-> n:size_t{v n * v len <= max_size_t}
-> output:lbuffer t (n *! len)
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot
(l:B.loc{B.loc_disjoint l (loc output) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}))
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq t (v len)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
(v i + 1) * v len <= max_size_t /\
modifies (footprint (v i) |+| loc (gsub output 0ul (i *! len))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! len) len in
let s, b = spec h0 (v i) (refl h1 (v i)) in
footprint (v i + 1) `B.loc_includes` footprint (v i) /\
B.modifies (B.loc_union (footprint (v i + 1)) (loc block)) h1 h2 /\
refl h2 (v i + 1) == s /\ as_seq h2 block == b))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 ->
B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1 /\
(let s, o = Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0) in
refl h1 (v n) == s /\
as_seq #_ #t h1 output == o))
let fill_blocks #t h0 len n output a_spec refl footprint spec impl = | true | null | false | [@@ inline_let ]let refl' h (i: nat{i <= v n})
: GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@@ inline_let ]let footprint' i =
B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len)))
in
[@@ inline_let ]let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0) in
let h0 = ST.get () in
loop h0
n
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
refl'
footprint'
spec'
(fun i ->
Loop.unfold_repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0)
(v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get () in
impl i;
let h = ST.get () in
assert (modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1))
(loc (gsub output 0ul (i *! len +! len)))
(footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1))
(loc (gsub output 0ul (i *! len +! len)))
(loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1))
(loc (gsub output 0ul (i *! len +! len))))
(footprint (v i + 1))
(loc block);
assert (B.loc_includes (B.loc_union (footprint (v i + 1))
(loc (gsub output 0ul (i *! len +! len))))
(B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split (as_seq h (gsub output (size 0) (i *! len +! len))) (v i * v len));
assert (Seq.equal (as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get () in
assert (refl' h1 (v n) ==
Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert (B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert (B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
assert (B.loc_includes (B.loc_union (footprint (v n)) (loc output))
(B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert (B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size_nat",
"LowStar.Monotonic.Buffer.loc",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.address_liveness_insensitive_locs",
"Prims.op_LessThan",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Prims.unit",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Lib.Buffer.lbuffer_t",
"Prims._assert",
"LowStar.Monotonic.Buffer.loc_includes_union_l",
"Lib.Sequence.generate_blocks_a",
"Lib.LoopCombinators.repeat_gen",
"Lib.Sequence.generate_blocks_inner",
"FStar.HyperStack.ST.get",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"Lib.Sequence.seq",
"Prims.int",
"Lib.Sequence.length",
"Lib.Sequence.generate_blocks",
"Lib.Sequence.equal",
"Lib.IntTypes.size",
"FStar.Seq.Base.empty",
"Lib.Buffer.loop",
"FStar.Seq.Properties.lemma_split",
"Lib.IntTypes.op_Plus_Bang",
"LowStar.Monotonic.Buffer.loc_includes_union_r",
"Lib.Buffer.sub",
"Lib.LoopCombinators.unfold_repeat_gen",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fill_blocks:
#t:Type0
-> h0:mem
-> len:size_t
-> n:size_t{v n * v len <= max_size_t}
-> output:lbuffer t (n *! len)
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot
(l:B.loc{B.loc_disjoint l (loc output) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}))
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq t (v len)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
(v i + 1) * v len <= max_size_t /\
modifies (footprint (v i) |+| loc (gsub output 0ul (i *! len))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! len) len in
let s, b = spec h0 (v i) (refl h1 (v i)) in
footprint (v i + 1) `B.loc_includes` footprint (v i) /\
B.modifies (B.loc_union (footprint (v i + 1)) (loc block)) h1 h2 /\
refl h2 (v i + 1) == s /\ as_seq h2 block == b))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 ->
B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1 /\
(let s, o = Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0) in
refl h1 (v n) == s /\
as_seq #_ #t h1 output == o)) | [] | Lib.Buffer.fill_blocks | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
len: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v n * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
output: Lib.Buffer.lbuffer t (n *! len) ->
a_spec: (i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} -> Type) ->
refl:
(_: FStar.Monotonic.HyperStack.mem -> i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n}
-> Prims.GTot (a_spec i)) ->
footprint:
(i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n}
-> Prims.GTot
(l:
LowStar.Monotonic.Buffer.loc
{ LowStar.Monotonic.Buffer.loc_disjoint l (Lib.Buffer.loc output) /\
LowStar.Monotonic.Buffer.loc_includes LowStar.Monotonic.Buffer.address_liveness_insensitive_locs
l })) ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} -> _: a_spec i
-> a_spec (i + 1) * Lib.Sequence.lseq t (Lib.IntTypes.v len))) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 71,
"end_line": 412,
"start_col": 2,
"start_line": 365
} |
FStar.Pervasives.Lemma | val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n))) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0) | val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 = | false | null | true | let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [
"lemma"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.Buffer.lbuffer_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Monotonic.HyperStack.mem",
"Prims._assert",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Buffer.as_seq",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.Buffer.gsub",
"Lib.Sequence.index",
"Prims.unit",
"Prims.l_imp",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Lib.Sequence.equal",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"FStar.UInt32.__uint_to_t"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n))) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n))) | [] | Lib.Buffer.lemma_eq_disjoint | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
clen1: Lib.IntTypes.size_t ->
clen2: Lib.IntTypes.size_t ->
b1: Lib.Buffer.lbuffer a1 clen1 ->
b2: Lib.Buffer.lbuffer_t t2 a2 clen2 ->
n:
Lib.IntTypes.size_t
{Lib.IntTypes.v n < Lib.IntTypes.v clen2 /\ Lib.IntTypes.v n < Lib.IntTypes.v clen1} ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
Lib.Buffer.live h0 b1 /\ Lib.Buffer.live h0 b2 /\ Lib.Buffer.eq_or_disjoint b1 b2 /\
Lib.Buffer.modifies1 (Lib.Buffer.gsub b1 0ul n) h0 h1)
(ensures
(let b2s = Lib.Buffer.gsub b2 n (clen2 -! n) in
Lib.Buffer.as_seq h0 b2s == Lib.Buffer.as_seq h1 b2s /\
Lib.Sequence.index (Lib.Buffer.as_seq h0 b2) (Lib.IntTypes.v n) ==
Lib.Sequence.index (Lib.Buffer.as_seq h1 b2) (Lib.IntTypes.v n))) | {
"end_col": 93,
"end_line": 512,
"start_col": 61,
"start_line": 506
} |
FStar.HyperStack.ST.Stack | val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src)) | val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub #t #a #len dst start n src = | true | null | false | match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul
(dst <: buffer a)
(size_to_UInt32 start)
(size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k: nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro (as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul
(dst <: buffer a)
(size_to_UInt32 start)
(size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k: nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro (as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul
(dst <: buffer a)
(size_to_UInt32 start)
(size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k: nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro (as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer_t",
"FStar.Seq.Base.lemma_eq_intro",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.update_sub",
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"Prims.nat",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Buffer.bget",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.BufferOps.blit",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"FStar.UInt32.__uint_to_t",
"Lib.RawIntTypes.size_to_UInt32",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0" | false | false | Lib.Buffer.fst | {
"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": 350,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src)) | [] | Lib.Buffer.update_sub | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Lib.Buffer.lbuffer a len ->
start: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.v len} ->
src: Lib.Buffer.lbuffer_t t a n
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 84,
"end_line": 124,
"start_col": 2,
"start_line": 97
} |
FStar.HyperStack.ST.Stack | val fill:
#a:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer a clen
-> spec:(mem -> GTot(i:size_nat{i < v clen} -> a))
-> impl:(i:size_t{v i < v clen} -> Stack a
(requires fun h -> modifies1 (gsub o 0ul i) h0 h)
(ensures fun h r h' -> h == h' /\
r == spec h0 (v i)))
-> Stack unit
(requires fun h -> h == h0 /\ live h0 o)
(ensures fun h _ h' ->
modifies1 o h h' /\
as_seq h' o == Seq.createi #a (v clen) (spec h0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
) | val fill:
#a:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer a clen
-> spec:(mem -> GTot(i:size_nat{i < v clen} -> a))
-> impl:(i:size_t{v i < v clen} -> Stack a
(requires fun h -> modifies1 (gsub o 0ul i) h0 h)
(ensures fun h r h' -> h == h' /\
r == spec h0 (v i)))
-> Stack unit
(requires fun h -> h == h0 /\ live h0 o)
(ensures fun h _ h' ->
modifies1 o h h' /\
as_seq h' o == Seq.createi #a (v clen) (spec h0))
let fill #a h0 clen out spec impl = | true | null | false | let h0 = ST.get () in
[@@ inline_let ]let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@@ inline_let ]let refl h i = Seq.sub (as_seq h out) 0 i in
[@@ inline_let ]let footprint (i: size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@@ inline_let ]let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0
clen
a_spec
refl
footprint
spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get () in
let x = impl i in
os.(i) <- x;
let h' = ST.get () in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.modifies1",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.loop",
"Prims._assert",
"Lib.Sequence.equal",
"Prims.op_Addition",
"Prims.unit",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.LoopCombinators.unfold_repeat_gen",
"Lib.Sequence.eq_intro",
"FStar.List.Tot.Base.length",
"Prims.Nil",
"Lib.Sequence.of_list",
"Prims.nat",
"Lib.Sequence.createi_a",
"Prims.l_imp",
"Lib.Sequence.createi_pred",
"Lib.Sequence.createi_step",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"LowStar.Monotonic.Buffer.loc",
"Lib.Buffer.loc",
"Lib.IntTypes.size",
"Lib.Sequence.lseq",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Lib.Buffer.as_seq",
"Prims.l_Forall",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
) | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fill:
#a:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer a clen
-> spec:(mem -> GTot(i:size_nat{i < v clen} -> a))
-> impl:(i:size_t{v i < v clen} -> Stack a
(requires fun h -> modifies1 (gsub o 0ul i) h0 h)
(ensures fun h r h' -> h == h' /\
r == spec h0 (v i)))
-> Stack unit
(requires fun h -> h == h0 /\ live h0 o)
(ensures fun h _ h' ->
modifies1 o h h' /\
as_seq h' o == Seq.createi #a (v clen) (spec h0)) | [] | Lib.Buffer.fill | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
clen: Lib.IntTypes.size_t ->
o: Lib.Buffer.lbuffer a clen ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v clen} -> a)) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v clen} -> FStar.HyperStack.ST.Stack a
)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 3,
"end_line": 484,
"start_col": 35,
"start_line": 464
} |
FStar.HyperStack.ST.Stack | val map_blocks_multi:
#t:buftype
-> #a:Type0
-> h0: mem
-> blocksize:size_t{v blocksize > 0}
-> nb:size_t{v nb * v blocksize <= max_size_t}
-> inp:lbuffer_t t a (nb *! blocksize)
-> output:lbuffer a (nb *! blocksize)
-> spec_f:(mem -> GTot (i:nat{i < v nb} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> impl_f:(i:size_t{v i < v nb} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v nb);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks_multi (v blocksize) (v nb) (v nb) (as_seq h0 inp) (spec_f h0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_blocks_multi #t #a h0 bs nb inp output spec_f impl_f =
Math.Lemmas.multiple_division_lemma (v nb) (v bs);
[@inline_let]
let refl h (i:nat{i <= v nb}) : GTot (Seq.map_blocks_a a (v bs) (v nb) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v nb);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v nb}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0) in
let h0 = ST.get () in
loop h0 nb (Seq.map_blocks_a a (v bs) (v nb)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v nb) (Seq.map_blocks_a a (v bs) (v nb))
(Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v nb);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
) | val map_blocks_multi:
#t:buftype
-> #a:Type0
-> h0: mem
-> blocksize:size_t{v blocksize > 0}
-> nb:size_t{v nb * v blocksize <= max_size_t}
-> inp:lbuffer_t t a (nb *! blocksize)
-> output:lbuffer a (nb *! blocksize)
-> spec_f:(mem -> GTot (i:nat{i < v nb} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> impl_f:(i:size_t{v i < v nb} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v nb);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks_multi (v blocksize) (v nb) (v nb) (as_seq h0 inp) (spec_f h0))
let map_blocks_multi #t #a h0 bs nb inp output spec_f impl_f = | true | null | false | Math.Lemmas.multiple_division_lemma (v nb) (v bs);
[@@ inline_let ]let refl h (i: nat{i <= v nb}) : GTot (Seq.map_blocks_a a (v bs) (v nb) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v nb);
as_seq h (gsub output (size 0) (size i *! bs))
in
[@@ inline_let ]let footprint (i: nat{i <= v nb}) = loc (gsub output 0ul (size i *! bs)) in
[@@ inline_let ]let spec h0 = Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0) in
let h0 = ST.get () in
loop h0
nb
(Seq.map_blocks_a a (v bs) (v nb))
refl
footprint
spec
(fun i ->
Loop.unfold_repeat_gen (v nb)
(Seq.map_blocks_a a (v bs) (v nb))
(Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0))
(refl h0 0)
(v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v nb);
let block = sub output (i *! bs) bs in
let h0_ = ST.get () in
impl_f i;
let h = ST.get () in
FStar.Seq.lemma_split (as_seq h (gsub output (size 0) (i *! bs +! bs))) (v i * v bs)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.op_Star_Bang",
"Lib.Buffer.lbuffer",
"Prims.nat",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Prims.unit",
"Prims.l_and",
"Prims.op_Addition",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.Math.Lemmas.lemma_mult_le_right",
"LowStar.Monotonic.Buffer.modifies",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Lib.Buffer.loop",
"Lib.Sequence.map_blocks_a",
"FStar.Seq.Properties.lemma_split",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.size",
"FStar.HyperStack.ST.get",
"Lib.Buffer.sub",
"Lib.LoopCombinators.unfold_repeat_gen",
"Lib.Sequence.map_blocks_f",
"LowStar.Monotonic.Buffer.loc",
"FStar.Math.Lemmas.multiple_division_lemma"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i))
let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
let mapi #a #b h0 clen out spec_f f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
#reset-options "--z3rlimit 500 --max_fuel 2" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_blocks_multi:
#t:buftype
-> #a:Type0
-> h0: mem
-> blocksize:size_t{v blocksize > 0}
-> nb:size_t{v nb * v blocksize <= max_size_t}
-> inp:lbuffer_t t a (nb *! blocksize)
-> output:lbuffer a (nb *! blocksize)
-> spec_f:(mem -> GTot (i:nat{i < v nb} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> impl_f:(i:size_t{v i < v nb} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v nb);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks_multi (v blocksize) (v nb) (v nb) (as_seq h0 inp) (spec_f h0)) | [] | Lib.Buffer.map_blocks_multi | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
nb: Lib.IntTypes.size_t{Lib.IntTypes.v nb * Lib.IntTypes.v blocksize <= Lib.IntTypes.max_size_t} ->
inp: Lib.Buffer.lbuffer_t t a (nb *! blocksize) ->
output: Lib.Buffer.lbuffer a (nb *! blocksize) ->
spec_f:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Prims.nat{i < Lib.IntTypes.v nb} ->
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize)
-> Lib.Sequence.lseq a (Lib.IntTypes.v blocksize))) ->
impl_f:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v nb}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 3,
"end_line": 582,
"start_col": 2,
"start_line": 560
} |
FStar.HyperStack.ST.Stack | val fill_blocks_simple:
#t:Type0
-> h0:mem
-> bs:size_t{v bs > 0}
-> n:size_t{v bs * v n <= max_size_t}
-> output:lbuffer t (bs *! n)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq t (v bs)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v n);
(v i + 1) * v bs <= max_size_t /\
modifies (loc (gsub output 0ul (i *! bs))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! bs) bs in
let ob = spec h0 (v i) in
B.modifies (loc block) h1 h2 /\
as_seq h2 block == ob))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq #_ #t h1 output == Sequence.generate_blocks_simple (v bs) (v n) (v n) (spec h0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
) | val fill_blocks_simple:
#t:Type0
-> h0:mem
-> bs:size_t{v bs > 0}
-> n:size_t{v bs * v n <= max_size_t}
-> output:lbuffer t (bs *! n)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq t (v bs)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v n);
(v i + 1) * v bs <= max_size_t /\
modifies (loc (gsub output 0ul (i *! bs))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! bs) bs in
let ob = spec h0 (v i) in
B.modifies (loc block) h1 h2 /\
as_seq h2 block == ob))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq #_ #t h1 output == Sequence.generate_blocks_simple (v bs) (v n) (v n) (spec h0))
let fill_blocks_simple #a h0 bs n output spec_f impl_f = | true | null | false | [@@ inline_let ]let refl h (i: nat{i <= v n})
: GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs))
in
[@@ inline_let ]let footprint (i: nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@@ inline_let ]let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0
n
(Sequence.generate_blocks_simple_a a (v bs) (v n))
refl
footprint
spec
(fun i ->
Loop.unfold_repeat_gen (v n)
(Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0))
(refl h0 0)
(v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get () in
impl_f i;
let h = ST.get () in
FStar.Seq.lemma_split (as_seq h (gsub output (size 0) (i *! bs +! bs))) (v i * v bs)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Prims.unit",
"Prims.l_and",
"Prims.op_Addition",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.Math.Lemmas.lemma_mult_le_right",
"LowStar.Monotonic.Buffer.modifies",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.loop",
"Lib.Sequence.generate_blocks_simple_a",
"FStar.Seq.Properties.lemma_split",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.size",
"FStar.HyperStack.ST.get",
"Lib.Buffer.sub",
"Prims._assert",
"Lib.IntTypes.maxint",
"Lib.LoopCombinators.unfold_repeat_gen",
"Lib.Sequence.generate_blocks_simple_f",
"Prims.nat",
"LowStar.Monotonic.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1" | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fill_blocks_simple:
#t:Type0
-> h0:mem
-> bs:size_t{v bs > 0}
-> n:size_t{v bs * v n <= max_size_t}
-> output:lbuffer t (bs *! n)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq t (v bs)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v n);
(v i + 1) * v bs <= max_size_t /\
modifies (loc (gsub output 0ul (i *! bs))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! bs) bs in
let ob = spec h0 (v i) in
B.modifies (loc block) h1 h2 /\
as_seq h2 block == ob))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq #_ #t h1 output == Sequence.generate_blocks_simple (v bs) (v n) (v n) (spec h0)) | [] | Lib.Buffer.fill_blocks_simple | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
bs: Lib.IntTypes.size_t{Lib.IntTypes.v bs > 0} ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v bs * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t} ->
output: Lib.Buffer.lbuffer t (bs *! n) ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n}
-> Lib.Sequence.lseq t (Lib.IntTypes.v bs))) ->
impl:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 3,
"end_line": 442,
"start_col": 2,
"start_line": 418
} |
FStar.HyperStack.ST.Stack | val map_blocks:
#t:buftype
-> #a:Type0
-> h0: mem
-> len:size_t
-> blocksize:size_t{v blocksize > 0}
-> inp:lbuffer_t t a len
-> output:lbuffer a len
-> spec_f:(mem -> GTot (i:nat{i < v len / v blocksize} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> spec_l:(mem -> GTot (i:nat{i == v len / v blocksize} -> llen:size_nat{llen < v blocksize} -> Seq.lseq a llen -> Seq.lseq a llen))
-> impl_f:(i:size_t{v i < v len / v blocksize} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v len / v blocksize);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> impl_l:(i:size_t{v i == v len / v blocksize} -> Stack unit
(requires fun h1 ->
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) (len %. blocksize) in
let oblock = gsub output (i *! blocksize) (len %. blocksize) in
let ob = spec_l h0 (v i) (v len % v blocksize) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks (v blocksize) (as_seq h0 inp) (spec_f h0) (spec_l h0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_blocks #t #a h0 len blocksize inp output spec_f spec_l impl_f impl_l =
div_mul_le (v blocksize) (v len);
size_gt_0_neq_0 blocksize;
let nb = len /. blocksize in
let rem = len %. blocksize in
let blen = nb *! blocksize in
Math.Lemmas.lemma_div_mod (v len) (v blocksize);
Math.Lemmas.multiple_division_lemma (v nb) (v blocksize);
Math.Lemmas.swap_mul (v len / v blocksize) (v blocksize);
Math.Lemmas.multiply_fractions (v len) (v blocksize);
let ib = sub inp 0ul blen in
let ob = sub output 0ul blen in
let il = sub inp blen rem in
let ol = sub inp blen rem in
map_blocks_multi #t #a h0 blocksize nb ib ob spec_f impl_f;
if rem >. 0ul then
(impl_l nb;
let h1 = ST.get() in
FStar.Seq.lemma_split (as_seq h1 output) (v nb * v blocksize))
else () | val map_blocks:
#t:buftype
-> #a:Type0
-> h0: mem
-> len:size_t
-> blocksize:size_t{v blocksize > 0}
-> inp:lbuffer_t t a len
-> output:lbuffer a len
-> spec_f:(mem -> GTot (i:nat{i < v len / v blocksize} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> spec_l:(mem -> GTot (i:nat{i == v len / v blocksize} -> llen:size_nat{llen < v blocksize} -> Seq.lseq a llen -> Seq.lseq a llen))
-> impl_f:(i:size_t{v i < v len / v blocksize} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v len / v blocksize);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> impl_l:(i:size_t{v i == v len / v blocksize} -> Stack unit
(requires fun h1 ->
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) (len %. blocksize) in
let oblock = gsub output (i *! blocksize) (len %. blocksize) in
let ob = spec_l h0 (v i) (v len % v blocksize) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks (v blocksize) (as_seq h0 inp) (spec_f h0) (spec_l h0))
let map_blocks #t #a h0 len blocksize inp output spec_f spec_l impl_f impl_l = | true | null | false | div_mul_le (v blocksize) (v len);
size_gt_0_neq_0 blocksize;
let nb = len /. blocksize in
let rem = len %. blocksize in
let blen = nb *! blocksize in
Math.Lemmas.lemma_div_mod (v len) (v blocksize);
Math.Lemmas.multiple_division_lemma (v nb) (v blocksize);
Math.Lemmas.swap_mul (v len / v blocksize) (v blocksize);
Math.Lemmas.multiply_fractions (v len) (v blocksize);
let ib = sub inp 0ul blen in
let ob = sub output 0ul blen in
let il = sub inp blen rem in
let ol = sub inp blen rem in
map_blocks_multi #t #a h0 blocksize nb ib ob spec_f impl_f;
if rem >. 0ul
then
(impl_l nb;
let h1 = ST.get () in
FStar.Seq.lemma_split (as_seq h1 output) (v nb * v blocksize)) | {
"checked_file": "Lib.Buffer.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.Memzero0.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Lib.Buffer.fst"
} | [] | [
"Lib.Buffer.buftype",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.lbuffer",
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.Sequence.lseq",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.size_nat",
"Prims.unit",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Lib.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Star_Bang",
"FStar.Math.Lemmas.lemma_mult_le_right",
"LowStar.Monotonic.Buffer.modifies",
"Lib.Buffer.as_seq",
"Lib.Sequence.seq",
"Prims.l_or",
"FStar.Seq.Base.length",
"Lib.IntTypes.op_Percent_Dot",
"Prims.op_Modulus",
"Lib.IntTypes.mod",
"Lib.IntTypes.op_Greater_Dot",
"FStar.Seq.Properties.lemma_split",
"FStar.HyperStack.ST.get",
"Prims.bool",
"Lib.Buffer.map_blocks_multi",
"Lib.Buffer.sub",
"FStar.Math.Lemmas.multiply_fractions",
"FStar.Math.Lemmas.swap_mul",
"FStar.Math.Lemmas.multiple_division_lemma",
"FStar.Math.Lemmas.lemma_div_mod",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Slash_Dot",
"Lib.Buffer.size_gt_0_neq_0",
"Lib.Buffer.div_mul_le"
] | [] | module Lib.Buffer
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
friend Lib.Sequence
friend Lib.LoopCombinators
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
#reset-options "--z3rlimit 350 --max_fuel 0 --max_ifuel 0"
let modifies_includes l1 l2 h0 h1 = ()
let modifies_trans l1 l2 h0 h1 h2 = ()
let live_sub #t #a #len b start n h = ()
let modifies_sub #t #a #len b start n h0 h1 = ()
let as_seq_gsub #t #a #len h b start n = ()
let sub #t #a #len b start n =
match t with
| MUT -> B.sub (b <: buffer a) start n
| IMMUT -> IB.isub (b <: ibuffer a) start n
| CONST -> CB.sub (b <: cbuffer a) start n
let index #t #a #len b i =
match t with
| MUT -> B.index (b <: buffer a) i
| IMMUT -> IB.index (b <: ibuffer a) i
| CONST -> CB.index (b <: cbuffer a) i
let upd #a #len b i v =
let h0 = ST.get() in
B.upd (b <: buffer a) i v;
let h1 = ST.get() in
assert (B.modifies (loc b) h0 h1);
assert (modifies (loc b) h0 h1)
let bget_as_seq #t #a #len h b i = ()
let recall #t #a #len b =
match t with
| IMMUT -> B.recall (b <: ibuffer a)
| MUT -> B.recall (b <: buffer a)
| CONST -> B.recall (CB.cast (b <: cbuffer a))
let create #a clen init =
B.alloca init (normalize_term clen)
#set-options "--max_fuel 1"
let createL #a init =
B.alloca_of_list init
let createL_global #a init =
CB.of_ibuffer (IB.igcmalloc_of_list #a root init)
let createL_mglobal #a init =
B.mgcmalloc_of_list #a FStar.Monotonic.HyperHeap.root init
let recall_contents #a #len b s =
B.recall_p (CB.to_ibuffer b) (cpred s)
(* JP: why triplicate the code? would it not extract if we just cast i to a monotonic buffer?! *)
let copy #t #a #len o i =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: buffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (i <: ibuffer a) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (i <: cbuffer a)) 0ul (o <: buffer a) 0ul len;
let h1 = ST.get () in
assert (Seq.slice (as_seq h1 o) 0 (v len) == Seq.slice (as_seq h0 i) 0 (v len))
let memset #a #blen b init len =
B.fill #a #(fun _ _ -> True) #(fun _ _ -> True) b init len
#set-options "--max_fuel 0"
let update_sub #t #a #len dst start n src =
match t with
| MUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: buffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| IMMUT ->
let h0 = ST.get () in
LowStar.BufferOps.blit (src <: ibuffer a)
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
| CONST ->
let h0 = ST.get () in
LowStar.BufferOps.blit (CB.cast (src <: cbuffer a))
0ul (dst <: buffer a) (size_to_UInt32 start) (size_to_UInt32 n);
let h1 = ST.get () in
assert (forall (k:nat{k < v n}). bget h1 dst (v start + k) == bget h0 src k);
FStar.Seq.lemma_eq_intro
(as_seq h1 dst)
(Seq.update_sub #a #(v len) (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
let update_sub_f #a #len h0 buf start n spec f =
let tmp = sub buf start n in
let h0 = ST.get () in
f ();
let h1 = ST.get () in
assert (v (len -! (start +! n)) == v len - v (start +! n));
B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1;
B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1;
Sequence.lemma_update_sub (as_seq h0 buf) (v start) (v n) (spec h0) (as_seq h1 buf)
let concat2 #a #t0 #t1 len0 s0 len1 s1 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
Seq.lemma_concat2 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (as_seq h1 s)
let concat3 #a #t0 #t1 #t2 len0 s0 len1 s1 len2 s2 s =
let h0 = ST.get () in
update_sub s (size 0) len0 s0;
update_sub s len0 len1 s1;
let h1 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h1 s) 0 (v len0)) (as_seq h0 s0);
update_sub s (len0 +! len1) len2 s2;
let h2 = ST.get () in
Seq.eq_intro (Seq.sub (as_seq h2 s) 0 (v len0)) (as_seq h0 s0);
Seq.eq_intro (Seq.sub (as_seq h2 s) (v len0) (v len1)) (as_seq h0 s1);
Seq.lemma_concat3 (v len0) (as_seq h0 s0) (v len1) (as_seq h0 s1) (v len2) (as_seq h0 s2) (as_seq h2 s)
let loop_nospec #h0 #a #len n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec2 #h0 #a1 #a2 #len1 #len2 n buf1 buf2 impl =
let inv h1 j = modifies (union (loc buf1) (loc buf2)) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_nospec3 #h0 #a1 #a2 #a3 #len1 #len2 #len3 n buf1 buf2 buf3 impl =
let inv h1 j = modifies (union (loc buf3) (union (loc buf1) (loc buf2))) h0 h1 in
Lib.Loops.for (size 0) n inv impl
let loop_range_nospec #h0 #a #len start n buf impl =
let inv h1 j = modifies (loc buf) h0 h1 in
Lib.Loops.for start (start +. n) inv impl
#set-options "--max_fuel 1"
let loop h0 n a_spec refl footprint spec impl =
let inv h i = loop_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop_refl h0 n a_spec refl footprint spec impl =
let inv h i = loop_refl_inv h0 n a_spec refl footprint spec i h in
Lib.Loops.for (size 0) n inv impl
let loop1 #b #blen h0 n acc spec impl =
let inv h i = loop1_inv h0 n b blen acc spec i h in
Lib.Loops.for (size 0) n inv impl
let loop2 #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec impl =
let inv h i = loop2_inv #b0 #blen0 #b1 #blen1 h0 n acc0 acc1 spec i h in
Lib.Loops.for (size 0) n inv impl
#set-options "--max_fuel 0"
let salloc1_with_inv #a #res h len x footprint spec spec_inv impl =
let h0 = ST.get() in
push_frame();
let h1 = ST.get() in
B.fresh_frame_modifies h0 h1;
let b = B.alloca x len in
let h2 = ST.get() in
let r = impl b in
let h3 = ST.get() in
Lib.Memzero0.memzero #a b len;
let h4 = ST.get() in
pop_frame();
let h5 = ST.get() in
B.popped_modifies h4 h5;
spec_inv h2 h3 h5 r;
r
inline_for_extraction
let salloc1 #a #res h len x footprint spec impl =
salloc1_with_inv #a #res h len x footprint spec
(fun h1 h2 h3 (r:res) -> assert (spec r h2); assert (spec r h3))
impl
inline_for_extraction
let salloc_nospec #a #res h len x footprint impl =
salloc1 #a #res h len x footprint (fun _ _ -> True) impl
inline_for_extraction
val loopi_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeati_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v nb);
assert ((v i + 1) * v bs == v i * v bs + v bs);
assert (v i * v bs + v bs <= v nb * v bs);
assert (v nb * v bs <= v inpLen);
let block = sub inp (i *! bs) bs in
f i block w
inline_for_extraction
val loopi_blocks_f_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 -> modifies (loc w) h0 h1)
#set-options "--z3rlimit 300 --max_fuel 0"
let loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f i block w
let loopi_blocks #a #b #blen bs inpLen inp spec_f spec_l f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
[@ inline_let]
let spec_fh h0 = Seq.repeati_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loopi_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l nb rem last w
let loopi_blocks_nospec #a #b #blen bs inpLen inp f l w =
let nb = inpLen /. bs in
let rem = inpLen %. bs in
let h0 = ST.get () in
loop_nospec #h0 #b #blen nb w
(fun i -> loopi_blocks_f_nospec #a #b #blen bs inpLen inp f nb i w);
let last = sub inp (nb *. bs) rem in
l nb rem last w
inline_for_extraction
val loop_blocks_f:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> nb:size_t{v nb == v inpLen / v blocksize}
-> i:size_t{v i < v nb}
-> w:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies (loc w) h0 h1 /\
as_seq h1 w ==
Sequence.repeat_blocks_f (v blocksize) (as_seq h0 inp) spec_f (v nb) (v i) (as_seq h0 w))
let loop_blocks_f #a #b #blen bs inpLen inp spec_f f nb i w =
assert ((v i + 1) * v bs <= v nb * v bs);
let block = sub inp (i *! bs) bs in
f block w
#set-options "--z3rlimit 400 --fuel 1"
let loop_blocks_multi #a #b #blen bs nb inp spec_f f w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb) inp spec_f f nb i w)
let loop_blocks #a #b #blen bs nb rem inp spec_f spec_l f l w =
[@ inline_let]
let spec_fh h0 = Seq.repeat_blocks_f (v bs) (as_seq h0 inp) spec_f (v nb) in
let h0 = ST.get () in
loop1 #b #blen h0 nb w spec_fh
(fun i ->
Loop.unfold_repeati (v nb) (spec_fh h0) (as_seq h0 w) (v i);
loop_blocks_f #a #b #blen bs (bs *! nb +! rem) inp spec_f f nb i w);
let last = sub inp (nb *! bs) rem in
l rem last w
let fill_blocks #t h0 len n output a_spec refl footprint spec impl =
[@inline_let]
let refl' h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_a t (v len) (v n) a_spec i) =
refl h i, as_seq h (gsub output (size 0) (size i *! len))
in
[@inline_let]
let footprint' i = B.loc_union (footprint i) (loc (gsub output 0ul (size i *! len))) in
[@inline_let]
let spec' h0 = Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)
in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_a t (v len) (v n) a_spec) refl' footprint' spec'
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0)) (refl' h0 0) (v i);
assert ((v i + 1) * v len == v i * v len + v len);
assert (v i * v len <= max_size_t);
let block = sub output (i *! len) len in
let h0_ = ST.get() in
impl i;
let h = ST.get() in
assert(modifies (B.loc_union (footprint (v i + 1)) (loc block)) h0_ h);
assert ((v i + 1) * v len == v i * v len + v len);
assert (B.loc_includes (loc (gsub output 0ul (i *! len +! len))) (loc block));
assert (B.loc_includes (footprint' (v i + 1)) (loc (gsub output 0ul (i *! len +! len))));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (footprint (v i + 1));
B.loc_includes_union_l (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len))) (loc block);
B.loc_includes_union_r (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (footprint (v i + 1)) (loc block);
assert(B.loc_includes (B.loc_union (footprint (v i + 1)) (loc (gsub output 0ul (i *! len +! len)))) (B.loc_union (footprint (v i + 1)) (loc block)));
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! len +! len)))
(v i * v len)
);
assert (Seq.equal
(as_seq h0 (gsub output (size 0) (size 0 *! len))) FStar.Seq.empty);
norm_spec [delta_only [`%Seq.generate_blocks]]
(Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0));
let h1 = ST.get() in
assert(refl' h1 (v n) == Loop.repeat_gen (v n)
(Sequence.generate_blocks_a t (v len) (v n) a_spec)
(Sequence.generate_blocks_inner t (v len) (v n) a_spec (spec h0))
(refl' h0 0));
assert(B.loc_includes (loc output) (loc (gsub output 0ul (n *! len))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))) h0 h1);
B.loc_includes_union_l (footprint (v n)) (loc output) (footprint (v n));
B.loc_includes_union_l (footprint (v n)) (loc output) (loc (gsub output 0ul (n *! len)));
//B.loc_includes_union_r (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (gsub output 0ul (n *! len)));
assert(B.loc_includes (B.loc_union (footprint (v n)) (loc output)) (B.loc_union (footprint (v n)) (loc (gsub output 0ul (n *! len)))));
assert(B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1)
#restart-solver
#reset-options "--z3rlimit 300 --max_fuel 1"
let fill_blocks_simple #a h0 bs n output spec_f impl_f =
[@inline_let]
let refl h (i:nat{i <= v n}) : GTot (Sequence.generate_blocks_simple_a a (v bs) (v n) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v n);
assert (v (size i *! bs) <= v n * v bs);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v n}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0) in
let h0 = ST.get () in
loop h0 n (Sequence.generate_blocks_simple_a a (v bs) (v n)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v n) (Sequence.generate_blocks_simple_a a (v bs) (v n))
(Sequence.generate_blocks_simple_f #a (v bs) (v n) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v n);
assert (v i * v bs <= maxint U32);
assert (v (i *! bs) + v bs <= v n * v bs);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
let fillT #a clen o spec_f f =
let open Seq in
let h0 = ST.get () in
[@inline_let]
let a_spec = createi_a a (v clen) spec_f in
[@inline_let]
let refl h i = sub (as_seq h o) 0 i in
[@inline_let]
let footprint i = loc o in
[@inline_let]
let spec h = createi_step a (v clen) spec_f in
eq_intro (of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
o.(i) <- f i;
let h' = ST.get () in
FStar.Seq.lemma_split (as_seq h' o) (v i)
)
let fill #a h0 clen out spec impl =
let h0 = ST.get() in
[@inline_let]
let a_spec = Seq.createi_a a (v clen) (spec h0) in
[@inline_let]
let refl h i = Seq.sub (as_seq h out) 0 i in
[@inline_let]
let footprint (i:size_nat{i <= v clen}) = loc (gsub out 0ul (size i)) in
[@inline_let]
let spec h = Seq.createi_step a (v clen) (spec h0) in
Seq.eq_intro (Seq.of_list []) (refl h0 0);
loop h0 clen a_spec refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v clen) a_spec (spec h0) (refl h0 0) (v i);
let os = sub out 0ul (i +! 1ul) in
let h = ST.get() in
let x = impl i in
os.(i) <- x;
let h' = ST.get() in
assert (Seq.equal (refl h' (v i + 1)) (spec h0 (v i) (refl h (v i))))
)
inline_for_extraction
val lemma_eq_disjoint:
#t2:buftype
-> #a1:Type
-> #a2:Type
-> clen1:size_t
-> clen2:size_t
-> b1:lbuffer a1 clen1
-> b2:lbuffer_t t2 a2 clen2
-> n: size_t{v n < v clen2 /\ v n < v clen1}
-> h0: mem
-> h1: mem
-> Lemma
(requires (live h0 b1 /\ live h0 b2 /\ eq_or_disjoint b1 b2 /\
modifies1 #a1 (gsub b1 0ul n) h0 h1))
(ensures (let b2s = gsub b2 n (clen2 -! n) in
as_seq h0 b2s == as_seq h1 b2s /\
Seq.index (as_seq h0 b2) (v n) ==
Seq.index (as_seq h1 b2) (v n)))
let lemma_eq_disjoint #t2 #a1 #a2 clen1 clen2 b1 b2 n h0 h1 =
let b1s = gsub b1 0ul n in
let b2s = gsub b2 0ul n in
assert (modifies (loc b1s) h0 h1);
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2));
assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s));
assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0)
#set-options "--z3rlimit 50 --max_fuel 0"
inline_for_extraction
let mapT #t #a #b clen out f inp =
let h0 = ST.get () in
[@inline_let]
let spec h = Seq.map_inner f (as_seq h inp) in
fill h0 clen out spec
(fun i -> let x = inp.(i) in
let h1 = ST.get() in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
f x)
inline_for_extraction
let map2T #t1 #t2 #a1 #a2 #b clen out f inp1 inp2 =
let h0 = ST.get () in
[@inline_let]
let spec (h:mem) = Seq.map2_inner #a1 #a2 #b #(v clen) f (as_seq h inp1) (as_seq h inp2) in
fill h0 clen out spec
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t1 clen clen out inp1 i h0 h1;
lemma_eq_disjoint #t2 clen clen out inp2 i h0 h1;
f inp1.(i) inp2.(i))
let mapiT #t #a #b clen out f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (fun i -> f (size i)) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint #t clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
let mapi #a #b h0 clen out spec_f f inp =
let h0 = ST.get () in
fill h0 clen out
(fun h -> Seq.mapi_inner (spec_f h0) (as_seq h inp))
(fun i ->
let h1 = ST.get () in
lemma_eq_disjoint clen clen out inp i h0 h1;
let xi = inp.(i) in f i xi)
#reset-options "--z3rlimit 500 --max_fuel 2"
let map_blocks_multi #t #a h0 bs nb inp output spec_f impl_f =
Math.Lemmas.multiple_division_lemma (v nb) (v bs);
[@inline_let]
let refl h (i:nat{i <= v nb}) : GTot (Seq.map_blocks_a a (v bs) (v nb) i) =
FStar.Math.Lemmas.lemma_mult_le_right (v bs) i (v nb);
as_seq h (gsub output (size 0) (size i *! bs)) in
[@inline_let]
let footprint (i:nat{i <= v nb}) = loc (gsub output 0ul (size i *! bs)) in
[@inline_let]
let spec h0 = Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0) in
let h0 = ST.get () in
loop h0 nb (Seq.map_blocks_a a (v bs) (v nb)) refl footprint spec
(fun i ->
Loop.unfold_repeat_gen (v nb) (Seq.map_blocks_a a (v bs) (v nb))
(Seq.map_blocks_f #a (v bs) (v nb) (as_seq h0 inp) (spec_f h0)) (refl h0 0) (v i);
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i + 1) (v nb);
let block = sub output (i *! bs) bs in
let h0_ = ST.get() in
impl_f i;
let h = ST.get() in
FStar.Seq.lemma_split
(as_seq h (gsub output (size 0) (i *! bs +! bs)))
(v i * v bs)
)
val div_mul_le: b:pos -> a:nat -> Lemma
((a / b) * b <= a)
let div_mul_le b a = ()
#reset-options "--z3rlimit 400 --fuel 0 --ifuel 0"
let size_gt_0_neq_0 (x: size_t): Lemma (requires v x > 0) (ensures v x <> 0) = () | false | false | Lib.Buffer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_blocks:
#t:buftype
-> #a:Type0
-> h0: mem
-> len:size_t
-> blocksize:size_t{v blocksize > 0}
-> inp:lbuffer_t t a len
-> output:lbuffer a len
-> spec_f:(mem -> GTot (i:nat{i < v len / v blocksize} -> Seq.lseq a (v blocksize) -> Seq.lseq a (v blocksize)))
-> spec_l:(mem -> GTot (i:nat{i == v len / v blocksize} -> llen:size_nat{llen < v blocksize} -> Seq.lseq a llen -> Seq.lseq a llen))
-> impl_f:(i:size_t{v i < v len / v blocksize} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v blocksize) (v i) (v len / v blocksize);
(v i + 1) * v blocksize <= max_size_t /\
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) blocksize in
let oblock = gsub output (i *! blocksize) blocksize in
let ob = spec_f h0 (v i) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> impl_l:(i:size_t{v i == v len / v blocksize} -> Stack unit
(requires fun h1 ->
modifies (loc (gsub output 0ul (i *! blocksize))) h0 h1)
(ensures fun h1 _ h2 ->
let iblock = gsub inp (i *! blocksize) (len %. blocksize) in
let oblock = gsub output (i *! blocksize) (len %. blocksize) in
let ob = spec_l h0 (v i) (v len % v blocksize) (as_seq h1 iblock) in
B.modifies (loc oblock) h1 h2 /\
as_seq h2 oblock == ob))
-> Stack unit
(requires fun h -> h0 == h /\ live h output /\ live h inp /\ eq_or_disjoint inp output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq h1 output == Seq.map_blocks (v blocksize) (as_seq h0 inp) (spec_f h0) (spec_l h0)) | [] | Lib.Buffer.map_blocks | {
"file_name": "lib/Lib.Buffer.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
len: Lib.IntTypes.size_t ->
blocksize: Lib.IntTypes.size_t{Lib.IntTypes.v blocksize > 0} ->
inp: Lib.Buffer.lbuffer_t t a len ->
output: Lib.Buffer.lbuffer a len ->
spec_f:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Prims.nat{i < Lib.IntTypes.v len / Lib.IntTypes.v blocksize} ->
_: Lib.Sequence.lseq a (Lib.IntTypes.v blocksize)
-> Lib.Sequence.lseq a (Lib.IntTypes.v blocksize))) ->
spec_l:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Prims.nat{i == Lib.IntTypes.v len / Lib.IntTypes.v blocksize} ->
llen: Lib.IntTypes.size_nat{llen < Lib.IntTypes.v blocksize} ->
_: Lib.Sequence.lseq a llen
-> Lib.Sequence.lseq a llen)) ->
impl_f:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v len / Lib.IntTypes.v blocksize}
-> FStar.HyperStack.ST.Stack Prims.unit) ->
impl_l:
(i: Lib.IntTypes.size_t{Lib.IntTypes.v i == Lib.IntTypes.v len / Lib.IntTypes.v blocksize}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 9,
"end_line": 611,
"start_col": 2,
"start_line": 593
} |
FStar.HyperStack.ST.Stack | 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)) | [
{
"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
}
] | false | let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag | 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 = | true | null | false | secretbox_open_detached mlen m k n c tag | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.SecretBox.secretbox_open_detached"
] | [] | 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))
[@CInline] | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | 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)) | [] | Hacl.Impl.Box.box_open_detached_afternm | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 42,
"end_line": 123,
"start_col": 2,
"start_line": 123
} |
FStar.HyperStack.ST.Stack | 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)) | [
{
"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
}
] | false | let box_detached_afternm mlen c tag k n m =
secretbox_detached mlen c tag k n m;
0ul | 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))
let box_detached_afternm mlen c tag k n m = | true | null | false | secretbox_detached mlen c tag k n m;
0ul | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Impl.SecretBox.secretbox_detached"
] | [] | 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] | false | false | Hacl.Impl.Box.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | 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)) | [] | Hacl.Impl.Box.box_detached_afternm | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
tag: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 67,
"start_col": 2,
"start_line": 66
} |
FStar.HyperStack.ST.Stack | val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher)) | [
{
"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
}
] | false | let box_easy mlen c sk pk n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached mlen cip tag sk pk n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res | val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher))
let box_easy mlen c sk pk n m = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached mlen cip tag sk pk n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Plus_Bang",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Seq.Properties.lemma_split",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.int_t",
"Hacl.Impl.Box.box_detached",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | 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))
[@CInline]
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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))
[@CInline]
let box_open_detached mlen m pk sk n c tag =
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_open_detached_afternm mlen m k n c tag
else 0xfffffffful in
pop_frame();
res
val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
[@CInline]
let box_easy_afternm mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached_afternm mlen cip tag k n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res
val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher)) | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher)) | [] | Hacl.Impl.Box.box_easy | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul) ->
sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 204,
"start_col": 31,
"start_line": 198
} |
FStar.HyperStack.ST.Stack | val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [
{
"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
}
] | false | let box_easy_afternm mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached_afternm mlen cip tag k n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res | val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let box_easy_afternm mlen c k n m = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached_afternm mlen cip tag k n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Plus_Bang",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Seq.Properties.lemma_split",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.int_t",
"Hacl.Impl.Box.box_detached_afternm",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | 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))
[@CInline]
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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))
[@CInline]
let box_open_detached mlen m pk sk n c tag =
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_open_detached_afternm mlen m k n c tag
else 0xfffffffful in
pop_frame();
res
val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [] | Hacl.Impl.Box.box_easy_afternm | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul) ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 177,
"start_col": 35,
"start_line": 171
} |
FStar.HyperStack.ST.Stack | val box_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [
{
"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
}
] | false | let box_open_easy mlen m pk sk n c =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
box_open_detached mlen m pk sk n cip tag | val box_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let box_open_easy mlen m pk sk n c = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
box_open_detached mlen m pk sk n cip tag | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Impl.Box.box_open_detached",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | 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))
[@CInline]
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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))
[@CInline]
let box_open_detached mlen m pk sk n c tag =
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_open_detached_afternm mlen m k n c tag
else 0xfffffffful in
pop_frame();
res
val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
[@CInline]
let box_easy_afternm mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached_afternm mlen cip tag k n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res
val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher))
[@CInline]
let box_easy mlen c sk pk n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached mlen cip tag sk pk n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res
val box_open_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
[@CInline]
let box_open_easy_afternm mlen m k n c =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
box_open_detached_afternm mlen m k n cip tag
val box_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | val box_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [] | Hacl.Impl.Box.box_open_easy | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul)
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 42,
"end_line": 251,
"start_col": 36,
"start_line": 248
} |
FStar.HyperStack.ST.Stack | val box_open_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [
{
"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
}
] | false | let box_open_easy_afternm mlen m k n c =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
box_open_detached_afternm mlen m k n cip tag | val box_open_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let box_open_easy_afternm mlen m k n c = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
box_open_detached_afternm mlen m k n cip tag | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Impl.Box.box_open_detached_afternm",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | 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))
[@CInline]
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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))
[@CInline]
let box_open_detached mlen m pk sk n c tag =
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_open_detached_afternm mlen m k n c tag
else 0xfffffffful in
pop_frame();
res
val box_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
[@CInline]
let box_easy_afternm mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached_afternm mlen cip tag k n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res
val box_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 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 pk /\ live h sk /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\
(let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in
match r with
| 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher
| _ -> None? cipher))
[@CInline]
let box_easy mlen c sk pk n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
let res = box_detached mlen cip tag sk pk n m in
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16;
res
val box_open_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | val box_open_easy_afternm:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint m n /\ disjoint c n)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [] | Hacl.Impl.Box.box_open_easy_afternm | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_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 +! 16ul)
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 46,
"end_line": 227,
"start_col": 40,
"start_line": 224
} |
FStar.HyperStack.ST.Stack | 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)) | [
{
"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
}
] | false | 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_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))
let box_beforenm k pk sk = | true | null | false | 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 | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Salsa20.hsalsa20",
"Prims.bool",
"Hacl.Curve25519_51.ecdh",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | 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] | false | false | Hacl.Impl.Box.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | 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)) | [] | Hacl.Impl.Box.box_beforenm | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 46,
"start_col": 2,
"start_line": 36
} |
FStar.HyperStack.ST.Stack | val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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)) | [
{
"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
}
] | false | let box_open_detached mlen m pk sk n c tag =
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_open_detached_afternm mlen m k n c tag
else 0xfffffffful in
pop_frame();
res | val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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 mlen m pk sk n c tag = | true | null | false | 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_open_detached_afternm mlen m k n c tag else 0xfffffffful in
pop_frame ();
res | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.size",
"Hacl.Impl.Box.box_open_detached_afternm",
"Prims.bool",
"Hacl.Impl.Box.box_beforenm",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | 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))
[@CInline]
let box_open_detached_afternm mlen m k n c tag =
secretbox_open_detached mlen m k n c tag
val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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))
[@CInline] | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | val box_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> pk:lbuffer uint8 32ul
-> sk: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 pk /\ live h sk /\ 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 (as_seq h0 pk) (as_seq h0 sk) (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)) | [] | Hacl.Impl.Box.box_open_detached | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
sk: 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 | {
"end_col": 5,
"end_line": 154,
"start_col": 2,
"start_line": 146
} |
FStar.HyperStack.ST.Stack | 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)) | [
{
"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
}
] | false | 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_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))
let box_detached mlen c tag sk pk n m = | true | null | false | 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 | {
"checked_file": "Hacl.Impl.Box.fst.checked",
"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"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.size",
"Hacl.Impl.Box.box_detached_afternm",
"Prims.bool",
"Hacl.Impl.Box.box_beforenm",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | 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] | false | false | Hacl.Impl.Box.fst | {
"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"
} | null | 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)) | [] | Hacl.Impl.Box.box_detached | {
"file_name": "code/nacl-box/Hacl.Impl.Box.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
tag: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul ->
sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 101,
"start_col": 2,
"start_line": 93
} |
Prims.Tot | val va_code_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr ->
Tot va_code | [
{
"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
}
] | false | let va_code_Add dst src1 src2 =
(Ins (S.Add dst src1 src2)) | 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 = | false | null | false | (Ins (S.Add dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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"
] | [] | 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"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_Add : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr ->
Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_Add | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 29,
"end_line": 129,
"start_col": 2,
"start_line": 129
} |
Prims.Tot | val va_code_AddExtendedOV : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_code | [
{
"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
}
] | false | let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2)) | val va_code_AddExtendedOV : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_code
let va_code_AddExtendedOV dst src1 src2 = | false | null | false | (Ins (S.AddExtendedOV dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.AddExtendedOV",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_AddExtendedOV : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_AddExtendedOV | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 39,
"end_line": 306,
"start_col": 2,
"start_line": 306
} |
Prims.Tot | val va_codegen_success_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 ->
Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_AddLa dst src1 src2 =
(va_ttrue ()) | 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 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.simm16",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_AddLa : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 ->
Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_AddLa | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 104,
"start_col": 2,
"start_line": 104
} |
Prims.Tot | val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code | [
{
"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
}
] | false | let va_code_Move dst src =
(Ins (S.Move dst src)) | val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code
let va_code_Move dst src = | false | null | false | (Ins (S.Move dst src)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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"
] | [] | 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"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_Move | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_code | {
"end_col": 24,
"end_line": 13,
"start_col": 2,
"start_line": 13
} |
Prims.Tot | val va_code_MulLow64 : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | [
{
"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
}
] | false | let va_code_MulLow64 dst src1 src2 =
(Ins (S.MulLow64 dst src1 src2)) | val va_code_MulLow64 : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code
let va_code_MulLow64 dst src1 src2 = | false | null | false | (Ins (S.MulLow64 dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.MulLow64",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"]
let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtendedOV dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1
src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub
[@ "opaque_to_smt"]
let va_code_Sub dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Sub dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub 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)
//--
//-- SubWrap
[@ "opaque_to_smt"]
let va_code_SubWrap dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap 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)
//--
//-- SubImm
[@ "opaque_to_smt"]
let va_code_SubImm dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm 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)
//--
//-- SubImmWrap
[@ "opaque_to_smt"]
let va_code_SubImmWrap dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImmWrap) (va_code_SubImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImmWrap (va_code_SubImmWrap 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)
//--
//-- MulLow64
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_MulLow64 : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_MulLow64 | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 34,
"end_line": 453,
"start_col": 2,
"start_line": 453
} |
Prims.Tot | val va_code_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot
va_code | [
{
"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
}
] | false | let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2)) | val va_code_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot
va_code
let va_code_AddImmWrap dst src1 src2 = | false | null | false | (Ins (S.AddImm dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.AddImm",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot
va_code | [] | Vale.PPC64LE.InsBasic.va_code_AddImmWrap | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 32,
"end_line": 216,
"start_col": 2,
"start_line": 216
} |
Prims.Tot | val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_Move dst src =
(va_ttrue ()) | 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 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_Move | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Decls.va_operand_reg_opr
-> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 15,
"end_line": 17,
"start_col": 2,
"start_line": 17
} |
Prims.Tot | val va_codegen_success_AddWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ()) | val va_codegen_success_AddWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_AddWrap dst src1 src2 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_AddWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_AddWrap | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 162,
"start_col": 2,
"start_line": 162
} |
Prims.Tot | val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_LoadImm64 dst src =
(va_ttrue ()) | val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
let va_codegen_success_LoadImm64 dst src = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.simm16",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_LoadImm64 | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src: Vale.PPC64LE.Machine_s.simm16
-> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 15,
"end_line": 46,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | val va_code_AddImm : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_code | [
{
"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
}
] | false | let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2)) | val va_code_AddImm : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_code
let va_code_AddImm dst src1 src2 = | false | null | false | (Ins (S.AddImm dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.AddImm",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_AddImm : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:simm16 -> Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_AddImm | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 32,
"end_line": 187,
"start_col": 2,
"start_line": 187
} |
Prims.Tot | val va_codegen_success_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:simm16 -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ()) | val va_codegen_success_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:simm16 -> Tot va_pbool
let va_codegen_success_AddImmWrap dst src1 src2 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.simm16",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_AddImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:simm16 -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_AddImmWrap | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 220,
"start_col": 2,
"start_line": 220
} |
Prims.Tot | val va_codegen_success_Sub : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_Sub dst src1 src2 =
(va_ttrue ()) | val va_codegen_success_Sub : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_Sub dst src1 src2 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"]
let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtendedOV dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1
src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub
[@ "opaque_to_smt"]
let va_code_Sub dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_Sub : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_Sub | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 341,
"start_col": 2,
"start_line": 341
} |
Prims.Tot | val va_code_SubImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:nsimm16 -> Tot
va_code | [
{
"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
}
] | false | let va_code_SubImmWrap dst src1 src2 =
(Ins (S.SubImm dst src1 src2)) | val va_code_SubImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:nsimm16 -> Tot
va_code
let va_code_SubImmWrap dst src1 src2 = | false | null | false | (Ins (S.SubImm dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.nsimm16",
"Vale.PPC64LE.Machine_s.Ins",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.PPC64LE.Semantics_s.SubImm",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"]
let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtendedOV dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1
src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub
[@ "opaque_to_smt"]
let va_code_Sub dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Sub dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub 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)
//--
//-- SubWrap
[@ "opaque_to_smt"]
let va_code_SubWrap dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap 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)
//--
//-- SubImm
[@ "opaque_to_smt"]
let va_code_SubImm dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm 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)
//--
//-- SubImmWrap
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_SubImmWrap : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:nsimm16 -> Tot
va_code | [] | Vale.PPC64LE.InsBasic.va_code_SubImmWrap | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src1: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src2: Vale.PPC64LE.Machine_s.nsimm16
-> Vale.PPC64LE.Decls.va_code | {
"end_col": 32,
"end_line": 424,
"start_col": 2,
"start_line": 424
} |
Prims.Tot | val va_code_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | [
{
"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
}
] | false | let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2)) | val va_code_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code
let va_code_AddCarry dst src1 src2 = | false | null | false | (Ins (S.AddCarry dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.AddCarry",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr
-> Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_AddCarry | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 34,
"end_line": 245,
"start_col": 2,
"start_line": 245
} |
Prims.Tot | val va_codegen_success_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ()) | val va_codegen_success_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_AddCarry dst src1 src2 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_AddCarry : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_AddCarry | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 249,
"start_col": 2,
"start_line": 249
} |
Prims.Tot | val va_codegen_success_MulHigh64U : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [
{
"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
}
] | false | let va_codegen_success_MulHigh64U dst src1 src2 =
(va_ttrue ()) | val va_codegen_success_MulHigh64U : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool
let va_codegen_success_MulHigh64U dst src1 src2 = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"]
let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtendedOV dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1
src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub
[@ "opaque_to_smt"]
let va_code_Sub dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Sub dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub 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)
//--
//-- SubWrap
[@ "opaque_to_smt"]
let va_code_SubWrap dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap 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)
//--
//-- SubImm
[@ "opaque_to_smt"]
let va_code_SubImm dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm 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)
//--
//-- SubImmWrap
[@ "opaque_to_smt"]
let va_code_SubImmWrap dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImmWrap) (va_code_SubImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImmWrap (va_code_SubImmWrap 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)
//--
//-- MulLow64
[@ "opaque_to_smt"]
let va_code_MulLow64 dst src1 src2 =
(Ins (S.MulLow64 dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_MulLow64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_MulLow64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_MulLow64) (va_code_MulLow64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_MulLow64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulLow64 (va_code_MulLow64 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)
//--
//-- MulLow64Wrap
[@ "opaque_to_smt"]
let va_code_MulLow64Wrap dst src1 src2 =
(Ins (S.MulLow64 dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_MulLow64Wrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_MulLow64Wrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_MulLow64Wrap) (va_code_MulLow64Wrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_MulLow64Wrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulLow64Wrap (va_code_MulLow64Wrap 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)
//--
//-- MulHigh64U
[@ "opaque_to_smt"]
let va_code_MulHigh64U dst src1 src2 =
(Ins (S.MulHigh64U dst src1 src2))
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_codegen_success_MulHigh64U : dst:va_operand_reg_opr -> src1:va_operand_reg_opr ->
src2:va_operand_reg_opr -> Tot va_pbool | [] | Vale.PPC64LE.InsBasic.va_codegen_success_MulHigh64U | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 15,
"end_line": 516,
"start_col": 2,
"start_line": 516
} |
Prims.Tot | val va_code_Xor : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr ->
Tot va_code | [
{
"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
}
] | false | let va_code_Xor dst src1 src2 =
(Ins (S.Xor dst src1 src2)) | val va_code_Xor : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr ->
Tot va_code
let va_code_Xor dst src1 src2 = | false | null | false | (Ins (S.Xor dst src1 src2)) | {
"checked_file": "Vale.PPC64LE.InsBasic.fst.checked",
"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"
} | [
"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.Xor",
"Vale.PPC64LE.Decls.va_code"
] | [] | 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))
[@ "opaque_to_smt"]
let va_codegen_success_Add dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Add va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Add dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Add (va_code_Add 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)
//--
//-- AddWrap
[@ "opaque_to_smt"]
let va_code_AddWrap dst src1 src2 =
(Ins (S.Add dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap 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)
//--
//-- AddImm
[@ "opaque_to_smt"]
let va_code_AddImm dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm 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)
//--
//-- AddImmWrap
[@ "opaque_to_smt"]
let va_code_AddImmWrap dst src1 src2 =
(Ins (S.AddImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap 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)
//--
//-- AddCarry
[@ "opaque_to_smt"]
let va_code_AddCarry dst src1 src2 =
(Ins (S.AddCarry dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddCarry dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddCarry dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtended
[@ "opaque_to_smt"]
let va_code_AddExtended dst src1 src2 =
(Ins (S.AddExtended dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtended dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtended dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AddExtendedOV
[@ "opaque_to_smt"]
let va_code_AddExtendedOV dst src1 src2 =
(Ins (S.AddExtendedOV dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_AddExtendedOV dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1
src2 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst
va_sM va_s0))));
va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Sub
[@ "opaque_to_smt"]
let va_code_Sub dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_Sub dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Sub va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Sub dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub 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)
//--
//-- SubWrap
[@ "opaque_to_smt"]
let va_code_SubWrap dst src1 src2 =
(Ins (S.Sub dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap 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)
//--
//-- SubImm
[@ "opaque_to_smt"]
let va_code_SubImm dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImm dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImm va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImm dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm 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)
//--
//-- SubImmWrap
[@ "opaque_to_smt"]
let va_code_SubImmWrap dst src1 src2 =
(Ins (S.SubImm dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_SubImmWrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_SubImmWrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_SubImmWrap) (va_code_SubImmWrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_SubImmWrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_SubImmWrap (va_code_SubImmWrap 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)
//--
//-- MulLow64
[@ "opaque_to_smt"]
let va_code_MulLow64 dst src1 src2 =
(Ins (S.MulLow64 dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_MulLow64 dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_MulLow64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_MulLow64) (va_code_MulLow64 dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_MulLow64 dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulLow64 (va_code_MulLow64 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)
//--
//-- MulLow64Wrap
[@ "opaque_to_smt"]
let va_code_MulLow64Wrap dst src1 src2 =
(Ins (S.MulLow64 dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_MulLow64Wrap dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_MulLow64Wrap va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_MulLow64Wrap) (va_code_MulLow64Wrap dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_MulLow64Wrap dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulLow64Wrap (va_code_MulLow64Wrap 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)
//--
//-- MulHigh64U
[@ "opaque_to_smt"]
let va_code_MulHigh64U dst src1 src2 =
(Ins (S.MulHigh64U dst src1 src2))
[@ "opaque_to_smt"]
let va_codegen_success_MulHigh64U dst src1 src2 =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_MulHigh64U va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_MulHigh64U) (va_code_MulHigh64U dst src1 src2);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (Ins (S.MulHigh64U dst src1 src2)) va_s0;
let (va_sM, va_fM) = va_eval_ins (Ins (S.MulHigh64U dst src1 src2)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_MulHigh64U dst src1 src2 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulHigh64U (va_code_MulHigh64U 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)
//--
//-- Xor
[@ "opaque_to_smt"] | false | true | Vale.PPC64LE.InsBasic.fst | {
"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"
} | null | val va_code_Xor : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr ->
Tot va_code | [] | Vale.PPC64LE.InsBasic.va_code_Xor | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 29,
"end_line": 541,
"start_col": 2,
"start_line": 541
} |
Subsets and Splits