file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Pulse.Extract.Main.fst
Pulse.Extract.Main.head_and_args
val head_and_args (t: term) : option (R.term & list R.argv)
val head_and_args (t: term) : option (R.term & list R.argv)
let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 145, "start_col": 0, "start_line": 141 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option (FStar.Stubs.Reflection.Types.term * Prims.list FStar.Stubs.Reflection.V2.Data.argv)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Reflection.V2.Derived.collect_app_ln", "Pulse.Syntax.Base.term'", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
false
false
false
true
false
let head_and_args (t: term) : option (R.term & list R.argv) =
match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.term_eq_string
val term_eq_string (s: string) (t: R.term) : bool
val term_eq_string (s: string) (t: R.term) : bool
let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 150, "start_col": 0, "start_line": 147 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> t: FStar.Stubs.Reflection.Types.term -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "Prims.op_Equality", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.bool" ]
[]
false
false
false
true
false
let term_eq_string (s: string) (t: R.term) : bool =
match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s = s' | _ -> false
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.unascribe
val unascribe (t: R.term) : T.Tac R.term
val unascribe (t: R.term) : T.Tac R.term
let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 215, "start_col": 0, "start_line": 211 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Pervasives.Native.option", "Prims.bool", "Pulse.Extract.Main.unascribe", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Data.term_view" ]
[ "recursion" ]
false
true
false
false
false
let rec unascribe (t: R.term) : T.Tac R.term =
match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.is_internal_binder
val is_internal_binder (b: binder) : T.Tac bool
val is_internal_binder (b: binder) : T.Tac bool
let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br"
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 328, "start_col": 0, "start_line": 321 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Pulse.Syntax.Base.binder -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Syntax.Base.binder", "Prims.op_BarBar", "Prims.op_Equality", "Prims.string", "Prims.bool", "FStar.Tactics.Unseal.unseal", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname" ]
[]
false
true
false
false
false
let is_internal_binder (b: binder) : T.Tac bool =
let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br"
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.as_normal_t
val as_normal_t (#a: Type) (x: a) : normal a
val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a:Type) (x:a) : normal a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 37, "start_col": 0, "start_line": 37 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Vale.Interop.Base.normal a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_normal_t (#a: Type) (x: a) : normal a =
x
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.is_return
val is_return (e: st_term) : option term
val is_return (e: st_term) : option term
let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 333, "start_col": 0, "start_line": 330 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br"
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: Pulse.Syntax.Base.st_term -> FStar.Pervasives.Native.option Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.term", "Prims.bool", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.st_term'", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
false
false
false
true
false
let is_return (e: st_term) : option term =
match e.term with | Tm_Return { term = term } -> Some term | _ -> None
false
Vale.SHA.PPC64LE.SHA_helpers.fst
Vale.SHA.PPC64LE.SHA_helpers.translate_hash_update
val translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old: quad32) : Lemma (requires a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old) (ensures (let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in mapped == h'))
val translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old: quad32) : Lemma (requires a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old) (ensures (let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in mapped == h'))
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma (requires a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old) (ensures ( let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in mapped == h')) = let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod; assert (equal mapped h'); ()
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 546, "start_col": 0, "start_line": 522 }
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Spec.SHA2 open Spec.SHA2.Lemmas open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.Lemmas open Vale.Def.Types_s open Vale.Def.Words_s open FStar.Seq open FStar.UInt32 // Interop with UInt-based SHA spec open Vale.Arch.Types open Vale.Arch.TypesNative open Vale.Def.Sel open Vale.SHA2.Wrapper friend Spec.SHA2 friend Spec.SHA2.Lemmas friend Vale.SHA2.Wrapper #reset-options "--max_fuel 0 --max_ifuel 0" // Define these specific converters here, so that F* only reasons about // the correctness of the conversion once, rather that at every call site let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n let word = Lib.IntTypes.uint32 let k = (Spec.SHA2.k0 SHA2_256) val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 -> Lemma (add_mod x y == Lib.IntTypes.(x +. y)) [SMTPat (Lib.IntTypes.(x +. y))] let add_mod_lemma x y = () unfold let ws_opaque_aux = ws let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 = vv (ws_opaque_aux SHA2_256 b t) unfold let shuffle_core_opaque_aux = shuffle_core let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 = shuffle_core_opaque_aux SHA2_256 block hash t [@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 = update_multi_opaque_aux SHA2_256 hash () blocks let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) = update_multi SHA2_256 hash () blocks let word_to_nat32 = vv let nat32_to_word = to_uint32 let make_ordered_hash_def (abcd efgh:quad32) : (hash:words_state SHA2_256 { length hash == 8 /\ hash.[0] == to_uint32 abcd.lo0 /\ hash.[1] == to_uint32 abcd.lo1 /\ hash.[2] == to_uint32 abcd.hi2 /\ hash.[3] == to_uint32 abcd.hi3 /\ hash.[4] == to_uint32 efgh.lo0 /\ hash.[5] == to_uint32 efgh.lo1 /\ hash.[6] == to_uint32 efgh.hi2 /\ hash.[7] == to_uint32 efgh.hi3 }) = let a = to_uint32 abcd.lo0 in let b = to_uint32 abcd.lo1 in let c = to_uint32 abcd.hi2 in let d = to_uint32 abcd.hi3 in let e = to_uint32 efgh.lo0 in let f = to_uint32 efgh.lo1 in let g = to_uint32 efgh.hi2 in let h = to_uint32 efgh.hi3 in let l = [a; b; c; d; e; f; g; h] in assert_norm (List.length l == 8); let hash = seq_of_list l in assert (length hash == 8); elim_of_list l; hash [@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) : Lemma(let h = shuffle_core_opaque block hash t in let open Lib.IntTypes in let a0 = hash.[0] in let b0 = hash.[1] in let c0 = hash.[2] in let d0 = hash.[3] in let e0 = hash.[4] in let f0 = hash.[5] in let g0 = hash.[6] in let h0 = hash.[7] in let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in h.[0] == t1 +. t2 /\ h.[1] == a0 /\ h.[2] == b0 /\ h.[3] == c0 /\ h.[4] == d0 +. t1 /\ h.[5] == e0 /\ h.[6] == f0 /\ h.[7] == g0) = Pervasives.reveal_opaque (`%shuffle_core) shuffle_core; let h = shuffle_core SHA2_256 block hash t in let a0 = hash.[0] in let b0 = hash.[1] in let c0 = hash.[2] in let d0 = hash.[3] in let e0 = hash.[4] in let f0 = hash.[5] in let g0 = hash.[6] in let h0 = hash.[7] in let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in assert (h == seq_of_list l); elim_of_list l; () let lemma_add_wrap_is_add_mod (n0 n1:nat32) : Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1))) = assert_norm (pow2 32 == pow2_32); () unfold let shuffle_opaque = shuffle let update_block (hash:hash256) (block:block_w): Tot (hash256) = let hash_1 = shuffle_opaque SHA2_256 hash block in let open Lib.IntTypes in Spec.Loops.seq_map2 ( +. ) hash hash_1 #push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *) let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) : Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block) = Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update; Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle; assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block)); () #pop-options let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma (ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) = update_multi_update SHA2_256 h b friend Lib.ByteSequence #reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true" let lemma_be_to_n_4 (s:seq4 nat8) : Lemma (Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s) = let open Lib.IntTypes in let open Vale.Def.Words.Four_s in assert (pow2 8 = 0x100); assert (pow2 16 = 0x10000); assert_norm (pow2 24 = 0x1000000); let x = seq_nat8_to_seq_uint8 s in let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in calc (==) { f x <: nat ; == { } FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3); == {} index s 3 + pow2 8 * f (slice x 0 3); == {} index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2); == {} index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1); == {} index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0); == {} index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0; == {} four_to_nat_unfold 8 (seq_to_four_BE s); == {reveal_opaque (`%four_to_nat) four_to_nat} be_bytes_to_nat32 s; } let lemma_mod_transform (quads:seq quad32) : Lemma (requires length quads % 4 == 0) (ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0) = () let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) = update_multi_reveal (); () let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 = if 16 <= t && t < size_k_w_256 then (let sigma0_in = ws_opaque block (t-15) in sigma256_0_0 sigma0_in) else 0 #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30" let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w(SHA2_256) /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) = sigma_0_0_partial_reveal (); () #reset-options "--max_fuel 0 --max_ifuel 0" let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 = if 16 <= t && t < size_k_w_256 then (let sigma1_in = ws_opaque block (t-2) in sigma256_0_1 sigma1_in) else 0 #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30" let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w(SHA2_256) /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) = sigma_0_1_partial_reveal (); () #reset-options "--max_fuel 0 --max_ifuel 0" let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 = if t < size_k_w_256 then (let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in sigma256_1_0 sigma0_in) else 0 #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30" let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w(SHA2_256) /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) = sigma_1_0_partial_reveal (); () #reset-options "--max_fuel 0 --max_ifuel 0" let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 = if t < size_k_w_256 then (let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in sigma256_1_1 sigma1_in) else 0 #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30" let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w(SHA2_256) /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) = sigma_1_1_partial_reveal (); () #reset-options "--max_fuel 0 --max_ifuel 0" let make_seperated_hash_def (a b c d e f g h:nat32) : (hash:words_state SHA2_256 { length hash == 8 /\ hash.[0] == to_uint32 a /\ hash.[1] == to_uint32 b /\ hash.[2] == to_uint32 c /\ hash.[3] == to_uint32 d /\ hash.[4] == to_uint32 e /\ hash.[5] == to_uint32 f /\ hash.[6] == to_uint32 g /\ hash.[7] == to_uint32 h }) = let a = to_uint32 a in let b = to_uint32 b in let c = to_uint32 c in let d = to_uint32 d in let e = to_uint32 e in let f = to_uint32 f in let g = to_uint32 g in let h = to_uint32 h in let l = [a; b; c; d; e; f; g; h] in assert_norm (List.length l == 8); let hash = seq_of_list l in assert (length hash == 8); elim_of_list l; hash [@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def let make_seperated_hash_quad32_def (a b c d e f g h:quad32) : (hash:words_state SHA2_256 { length hash == 8 /\ hash.[0] == to_uint32 a.hi3 /\ hash.[1] == to_uint32 b.hi3 /\ hash.[2] == to_uint32 c.hi3 /\ hash.[3] == to_uint32 d.hi3 /\ hash.[4] == to_uint32 e.hi3 /\ hash.[5] == to_uint32 f.hi3 /\ hash.[6] == to_uint32 g.hi3 /\ hash.[7] == to_uint32 h.hi3 }) = let a = to_uint32 a.hi3 in let b = to_uint32 b.hi3 in let c = to_uint32 c.hi3 in let d = to_uint32 d.hi3 in let e = to_uint32 e.hi3 in let f = to_uint32 f.hi3 in let g = to_uint32 g.hi3 in let h = to_uint32 h.hi3 in let l = [a; b; c; d; e; f; g; h] in assert_norm (List.length l == 8); let hash = seq_of_list l in assert (length hash == 8); elim_of_list l; hash [@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) = assert (equal hash (make_seperated_hash_quad32 a b c d e f g h)) let lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) = reveal_iand_all 32; reveal_inot_all 32; reveal_ixor_all 32; lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b)) let ch_256_def (x y z:nat32) : (a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)}) = reveal_iand_all 32; reveal_inot_all 32; reveal_ixor_all 32; ch256 x y z [@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) = reveal_iand_all 32; reveal_ixor_all 32; lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))) let maj_256_def (x y z:nat32) : (a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))}) = reveal_iand_all 32; reveal_ixor_all 32; maj256 x y z [@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w(SHA2_256)) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) = sigma_0_0_partial_reveal () let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w(SHA2_256)) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) = sigma_0_1_partial_reveal () let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w(SHA2_256)) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) = sigma_1_0_partial_reveal () let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w(SHA2_256)) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) = sigma_1_1_partial_reveal () #reset-options "--z3rlimit 20 --max_fuel 1" let lemma_quads_to_block_be qs = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); reveal_opaque (`%ws) ws #reset-options "--max_fuel 0 --max_ifuel 0" #reset-options "--z3rlimit 20" let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in let a0 = word_to_nat32 hash.[0] in let b0 = word_to_nat32 hash.[1] in let c0 = word_to_nat32 hash.[2] in let d0 = word_to_nat32 hash.[3] in let e0 = word_to_nat32 hash.[4] in let f0 = word_to_nat32 hash.[5] in let g0 = word_to_nat32 hash.[6] in let h0 = word_to_nat32 hash.[7] in let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in word_to_nat32 h.[0] == add_wrap t1 t2 /\ word_to_nat32 h.[1] == a0 /\ word_to_nat32 h.[2] == b0 /\ word_to_nat32 h.[3] == c0 /\ word_to_nat32 h.[4] == add_wrap d0 t1 /\ word_to_nat32 h.[5] == e0 /\ word_to_nat32 h.[6] == f0 /\ word_to_nat32 h.[7] == g0)) = let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in let a0 = word_to_nat32 hash.[0] in let b0 = word_to_nat32 hash.[1] in let c0 = word_to_nat32 hash.[2] in let d0 = word_to_nat32 hash.[3] in let e0 = word_to_nat32 hash.[4] in let f0 = word_to_nat32 hash.[5] in let g0 = word_to_nat32 hash.[6] in let h0 = word_to_nat32 hash.[7] in ch_256_reveal (); maj_256_reveal (); lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0); lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0); lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]); lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t); lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0); lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0)); lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)); Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig; shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t #reset-options "--max_fuel 0 --max_ifuel 0" let lemma_add_mod_commutes (x y:UInt32.t) : Lemma (add_mod x y == add_mod y x) = () let lemma_add_mod_associates_U32 (x y z:UInt32.t) : Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) = let open Lib.IntTypes in calc (==) { v (x +. (y +. z)); (==) { } (v x + (v y + v z) % pow2 32) % pow2 32; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) } ((v x + v y) + v z) % pow2 32; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) } ((v x + v y) % pow2 32 + v z) % pow2 32; (==) { } v ((x +. y) +. z); }; v_inj (x +. (y +. z)) ((x +. y) +. z) let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) : Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) = let open Lib.IntTypes in calc (==) { a +. b +. c +. d; (==) {} (((a +. b) +. c) +. d); (==) { lemma_add_mod_commutes ((a +. b) +. c) d; lemma_add_mod_commutes (a +. b) c; lemma_add_mod_commutes a b } d +. (c +. (b +. a)); (==) { lemma_add_mod_associates_U32 d c (b +. a); lemma_add_mod_associates_U32 (d +. c) b a} (((d +. c) +. b) +. a); } #reset-options "--fuel 1 --z3rlimit 50" let lemma_ws_opaque (block:block_w) (t:counter) : Lemma (requires 16 <= t && t < size_k_w_256) (ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)))) = let t16 = ws SHA2_256 block (t - 16) in let t15 = ws SHA2_256 block (t - 15) in let t7 = ws SHA2_256 block (t - 7) in let t2 = ws SHA2_256 block (t - 2) in let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in let s1 = _sigma1 SHA2_256 t2 in let s0 = _sigma0 SHA2_256 t15 in calc (==) { ws_opaque block t; (==) { Pervasives.reveal_opaque (`%ws) ws } vv ((s1 +. t7 +. s0) +. t16); (==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) } add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16)); (==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 } add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16)); (==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) } add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)); }
{ "checked_file": "/", "dependencies": [ "Vale.SHA2.Wrapper.fst.checked", "Vale.SHA2.Wrapper.fst.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Seq.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.SHA2.Lemmas.fst.checked", "Spec.SHA2.Lemmas.fst.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Loops.fst.checked", "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.UInt32 // Interop with UInt-based SHA spec", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Types_s.quad32 -> b: Vale.Def.Types_s.quad32 -> c: Vale.Def.Types_s.quad32 -> d: Vale.Def.Types_s.quad32 -> e: Vale.Def.Types_s.quad32 -> f: Vale.Def.Types_s.quad32 -> g: Vale.Def.Types_s.quad32 -> h: Vale.Def.Types_s.quad32 -> a': Vale.Def.Types_s.quad32 -> b': Vale.Def.Types_s.quad32 -> c': Vale.Def.Types_s.quad32 -> d': Vale.Def.Types_s.quad32 -> e': Vale.Def.Types_s.quad32 -> f': Vale.Def.Types_s.quad32 -> g': Vale.Def.Types_s.quad32 -> h': Vale.Def.Types_s.quad32 -> a_old: Vale.Def.Types_s.quad32 -> b_old: Vale.Def.Types_s.quad32 -> c_old: Vale.Def.Types_s.quad32 -> d_old: Vale.Def.Types_s.quad32 -> e_old: Vale.Def.Types_s.quad32 -> f_old: Vale.Def.Types_s.quad32 -> g_old: Vale.Def.Types_s.quad32 -> h_old: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires a' == Vale.Arch.Types.add_wrap_quad32 a a_old /\ b' == Vale.Arch.Types.add_wrap_quad32 b b_old /\ c' == Vale.Arch.Types.add_wrap_quad32 c c_old /\ d' == Vale.Arch.Types.add_wrap_quad32 d d_old /\ e' == Vale.Arch.Types.add_wrap_quad32 e e_old /\ f' == Vale.Arch.Types.add_wrap_quad32 f f_old /\ g' == Vale.Arch.Types.add_wrap_quad32 g g_old /\ h' == Vale.Arch.Types.add_wrap_quad32 h h_old) (ensures (let h = Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a b c d e f g h in let a = Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let mapped = Spec.Loops.seq_map2 Lib.IntTypes.op_Plus_Dot h a in mapped == h'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.SHA.PPC64LE.SHA_helpers.word", "FStar.Classical.forall_intro_2", "Vale.Def.Words_s.nat32", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Types_s.add_wrap", "Vale.SHA.PPC64LE.SHA_helpers.vv", "FStar.UInt32.add_mod", "Vale.SHA.PPC64LE.SHA_helpers.to_uint32", "Vale.SHA.PPC64LE.SHA_helpers.lemma_add_wrap_is_add_mod", "FStar.Seq.Base.seq", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "FStar.Seq.Base.index", "Lib.IntTypes.add_mod", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Spec.Loops.seq_map2", "Lib.IntTypes.op_Plus_Dot", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32", "Vale.Arch.Types.add_wrap_quad32", "Prims.squash", "Prims.l_or", "Prims.int", "Lib.IntTypes.int_t", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old: quad32) : Lemma (requires a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old) (ensures (let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in mapped == h')) =
let h = make_seperated_hash_quad32 a b c d e f g h in let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in let open Lib.IntTypes in let mapped = Spec.Loops.seq_map2 ( +. ) h a in FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod; assert (equal mapped h'); ()
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.as_t
val as_t (#a: Type) (x: normal a) : a
val as_t (#a: Type) (x: normal a) : a
let as_t (#a:Type) (x:normal a) : a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 35, "start_col": 0, "start_line": 35 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Interop.Base.normal a -> a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_t (#a: Type) (x: normal a) : a =
x
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.dom
val dom:IX64.arity_ok_stdcall td
val dom:IX64.arity_ok_stdcall td
let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 53, "start_col": 0, "start_line": 50 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Stdcalls.X64.Fadd.t64_mod", "Vale.Stdcalls.X64.Fadd.t64_no_mod", "Vale.Stdcalls.X64.Fadd.tuint64", "Prims.Nil" ]
[]
false
false
false
true
false
let dom:IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.simplify_nested_let
val simplify_nested_let (e: st_term) (b_x: binder) (head e3: st_term) : option st_term
val simplify_nested_let (e: st_term) (b_x: binder) (head e3: st_term) : option st_term
let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 360, "start_col": 0, "start_line": 345 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: Pulse.Syntax.Base.st_term -> b_x: Pulse.Syntax.Base.binder -> head: Pulse.Syntax.Base.st_term -> e3: Pulse.Syntax.Base.st_term -> FStar.Pervasives.Native.option Pulse.Syntax.Base.st_term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.term", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.Tm_TotBind", "Pulse.Syntax.Base.Mkst_term'__Tm_TotBind__payload", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Syntax.Base.Tm_WithLocal", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocal__payload", "Pulse.Syntax.Base.Tm_WithLocalArray", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocalArray__payload", "Pulse.Syntax.Base.st_term'", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.default_effect_hint" ]
[]
false
false
false
true
false
let simplify_nested_let (e: st_term) (b_x: binder) (head e3: st_term) : option st_term =
let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind ({ binder = b_x; head = e2; body = e3 })) in match head.term with | Tm_TotBind { binder = b_y ; head = e1 ; body = e2 } -> Some (mk (Tm_TotBind ({ binder = b_y; head = e1; body = body e2 }))) | Tm_Bind { binder = b_y ; head = e1 ; body = e2 } -> Some (mk (Tm_Bind ({ binder = b_y; head = e1; body = body e2 }))) | Tm_WithLocal { binder = b_y ; initializer = e1 ; body = e2 } -> Some (mk (Tm_WithLocal ({ binder = b_y; initializer = e1; body = body e2 }))) | Tm_WithLocalArray { binder = b_y ; initializer = e1 ; length = length ; body = e2 } -> Some (mk (Tm_WithLocalArray ({ binder = b_y; initializer = e1; length = length; body = body e2 }))) | _ -> None
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.erase_type_for_extraction
val erase_type_for_extraction (g: env) (t: term) : T.Tac bool
val erase_type_for_extraction (g: env) (t: term) : T.Tac bool
let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 444, "start_col": 0, "start_line": 441 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> t: Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "Pulse.RuntimeUtils.must_erase_for_extraction", "Pulse.Extract.Main.tcenv_of_env", "Pulse.Syntax.Base.term'", "Prims.bool" ]
[]
false
true
false
false
false
let erase_type_for_extraction (g: env) (t: term) : T.Tac bool =
match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.add1_post
val add1_post:VSig.vale_post dom
val add1_post:VSig.vale_post dom
let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 111, "end_line": 75, "start_col": 0, "start_line": 67 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Fadd.dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fadd.b64", "Vale.Stdcalls.X64.Fadd.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastUtil.va_ens_Fast_add1_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.UInt64.v", "Prims.prop" ]
[]
false
false
false
true
false
let add1_post:VSig.vale_post dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: uint64) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.add1_pre
val add1_pre:VSig.vale_pre dom
val add1_pre:VSig.vale_pre dom
let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 64, "start_col": 0, "start_line": 57 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Fadd.dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fadd.b64", "Vale.Stdcalls.X64.Fadd.uint64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastUtil.va_req_Fast_add1_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.UInt64.v", "Prims.prop" ]
[]
false
false
false
true
false
let add1_pre:VSig.vale_pre dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: uint64) (va_s0: V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.add1_lemma
val add1_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fadd.add1_pre Vale.Stdcalls.X64.Fadd.add1_post
let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 109, "start_col": 0, "start_line": 109 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fadd.add1_pre Vale.Stdcalls.X64.Fadd.add1_post
Prims.Tot
[ "total" ]
[]
[ "Vale.Stdcalls.X64.Fadd.as_t", "Vale.AsLowStar.ValeSig.vale_sig_stdcall", "Vale.Stdcalls.X64.Fadd.dom", "Vale.Stdcalls.X64.Fadd.add1_pre", "Vale.Stdcalls.X64.Fadd.add1_post", "Vale.Stdcalls.X64.Fadd.add1_lemma'" ]
[]
false
false
false
true
false
let add1_lemma =
as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma'
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.fadd_dom
val fadd_dom:IX64.arity_ok_stdcall td
val fadd_dom:IX64.arity_ok_stdcall td
let fadd_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 130, "start_col": 0, "start_line": 127 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' noextract let code_add1 = FU.va_code_Fast_add1_stdcall IA.win (* Here's the type expected for the add1 wrapper *) [@__reduce__] noextract let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Stdcalls.X64.Fadd.t64_mod", "Vale.Stdcalls.X64.Fadd.t64_no_mod", "Prims.Nil" ]
[]
false
false
false
true
false
let fadd_dom:IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.lowstar_add1_t
val lowstar_add1_t : Type0
let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 124, "start_col": 0, "start_line": 116 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' noextract let code_add1 = FU.va_code_Fast_add1_stdcall IA.win (* Here's the type expected for the add1 wrapper *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall", "Vale.Stdcalls.X64.Fadd.code_add1", "Vale.Stdcalls.X64.Fadd.dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Vale.Stdcalls.X64.Fadd.add1_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.Fadd.add1_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.Fadd.add1_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
true
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([] <: list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.debug_
val debug_ : g: Pulse.Extract.Main.env -> f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.string) -> FStar.Tactics.Effect.Tac Prims.unit
let debug_ = debug
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 729, "start_col": 0, "start_line": 729 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.string) -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.debug" ]
[]
false
true
false
false
false
let debug_ =
debug
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.is_recursive
val is_recursive (g: env) (knot_name: R.fv) (selt: R.sigelt) : T.Tac (option string)
val is_recursive (g: env) (knot_name: R.fv) (selt: R.sigelt) : T.Tac (option string)
let is_recursive (g:env) (knot_name:R.fv) (selt:R.sigelt) : T.Tac (option string) = let attrs = RU.get_attributes selt in let unpack_string (t:R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t:R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> ( let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_; _; (tag, _); (value, _)] -> ( match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None ) | _ -> None else None ) | _ -> None in find_map pulse_recursive_attr attrs
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 760, "start_col": 0, "start_line": 736 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> knot_name: FStar.Stubs.Reflection.Types.fv -> selt: FStar.Stubs.Reflection.Types.sigelt -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.string)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.Types.sigelt", "Pulse.Extract.Main.find_map", "FStar.Stubs.Reflection.Types.term", "Prims.string", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.V2.Data.argv", "Prims.list", "FStar.Reflection.V2.Derived.is_fvar", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.None", "Prims.bool", "FStar.Reflection.V2.Derived.collect_app_ln", "FStar.Stubs.Reflection.V2.Data.term_view", "Pulse.RuntimeUtils.get_attributes" ]
[]
false
true
false
false
false
let is_recursive (g: env) (knot_name: R.fv) (selt: R.sigelt) : T.Tac (option string) =
let attrs = RU.get_attributes selt in let unpack_string (t: R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t: R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> (let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_ ; _ ; tag, _ ; value, _] -> (match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None) | _ -> None else None) | _ -> None in find_map pulse_recursive_attr attrs
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.fadd_lemma
val fadd_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fadd.fadd_pre Vale.Stdcalls.X64.Fadd.fadd_post
let fadd_lemma = as_t #(VSig.vale_sig_stdcall fadd_pre fadd_post) fadd_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 188, "start_col": 0, "start_line": 188 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' noextract let code_add1 = FU.va_code_Fast_add1_stdcall IA.win (* Here's the type expected for the add1 wrapper *) [@__reduce__] noextract let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) [@__reduce__] noextract let fadd_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] noextract let fadd_post : VSig.vale_post fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FH.va_ens_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let fadd_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FH.va_lemma_Fadd_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2; (va_s1, f) (* Prove that add1_lemma' has the required type *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Fadd.fadd_pre Vale.Stdcalls.X64.Fadd.fadd_post
Prims.Tot
[ "total" ]
[]
[ "Vale.Stdcalls.X64.Fadd.as_t", "Vale.AsLowStar.ValeSig.vale_sig_stdcall", "Vale.Stdcalls.X64.Fadd.fadd_dom", "Vale.Stdcalls.X64.Fadd.fadd_pre", "Vale.Stdcalls.X64.Fadd.fadd_post", "Vale.Stdcalls.X64.Fadd.fadd_lemma'" ]
[]
false
false
false
true
false
let fadd_lemma =
as_t #(VSig.vale_sig_stdcall fadd_pre fadd_post) fadd_lemma'
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extract_attrs
val extract_attrs (g: uenv) (se: R.sigelt) : T.Tac (list mlexpr)
val extract_attrs (g: uenv) (se: R.sigelt) : T.Tac (list mlexpr)
let extract_attrs (g:uenv) (se:R.sigelt) : T.Tac (list mlexpr) = se |> RU.get_attributes |> T.map (fun t -> let mlattr, _, _ = ECL.term_as_mlexpr g t in mlattr)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 76, "end_line": 804, "start_col": 0, "start_line": 802 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl let is_recursive (g:env) (knot_name:R.fv) (selt:R.sigelt) : T.Tac (option string) = let attrs = RU.get_attributes selt in let unpack_string (t:R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t:R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> ( let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_; _; (tag, _); (value, _)] -> ( match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None ) | _ -> None else None ) | _ -> None in find_map pulse_recursive_attr attrs let rec extract_recursive g (p:st_term) (rec_name:R.fv) : T.Tac (mlexpr & e_tag) = match p.term with | Tm_Abs { b; q; body } -> ( match body.term with | Tm_Abs _ -> let g, mlident, mlty, name = extend_env g b in let body = LN.open_st_term_nv body name in let body, _ = extract_recursive g body rec_name in let attrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let res = mle_fun [mlident, mlty, attrs] body in res, e_tag_pure | _ -> //last binder used for knot; replace it with the recursively bound name let body = LN.subst_st_term body [LN.DT 0 (tm_fstar R.(pack_ln (Tv_FVar rec_name)) Range.range_0)] in let body, tag = extract g body in body, tag ) | _ -> T.fail "Unexpected recursive definition of non-function" let extract_recursive_knot (g:env) (p:st_term) (knot_name:R.fv) (knot_typ:R.term) = let g, tys, lb_typ, Some p = generalize g knot_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let uenv, _mli, _ml_binding = extend_fv g.uenv_inner knot_name (tys, mlty) in let g = { g with uenv_inner = uenv } in let tm, tag = extract_recursive g p knot_name in let fv_name = let lids = R.inspect_fv knot_name in if Nil? lids then T.raise (Extraction_failure "Unexpected empty name"); FStar.List.Tot.last lids in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let mllb = mk_mllb fv_name (tys, mlty) tm in Inl [mlm_let true [mllb]]
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.CompilerLib.uenv -> se: FStar.Stubs.Reflection.Types.sigelt -> FStar.Tactics.Effect.Tac (Prims.list Pulse.Extract.CompilerLib.mlexpr)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.CompilerLib.uenv", "FStar.Stubs.Reflection.Types.sigelt", "FStar.Tactics.Util.map", "FStar.Tactics.NamedView.term", "Pulse.Extract.CompilerLib.mlexpr", "Pulse.Extract.CompilerLib.e_tag", "Pulse.Extract.CompilerLib.mlty", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.CompilerLib.term_as_mlexpr", "Prims.list", "Pulse.RuntimeUtils.get_attributes", "FStar.Stubs.Reflection.Types.term" ]
[]
false
true
false
false
false
let extract_attrs (g: uenv) (se: R.sigelt) : T.Tac (list mlexpr) =
se |> RU.get_attributes |> T.map (fun t -> let mlattr, _, _ = ECL.term_as_mlexpr g t in mlattr)
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.lowstar_fadd_t
val lowstar_fadd_t : Type0
let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fadd fadd_dom [] _ _ (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 203, "start_col": 0, "start_line": 195 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' noextract let code_add1 = FU.va_code_Fast_add1_stdcall IA.win (* Here's the type expected for the add1 wrapper *) [@__reduce__] noextract let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) [@__reduce__] noextract let fadd_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] noextract let fadd_post : VSig.vale_post fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FH.va_ens_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let fadd_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FH.va_lemma_Fadd_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2; (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let fadd_lemma = as_t #(VSig.vale_sig_stdcall fadd_pre fadd_post) fadd_lemma' noextract let code_Fadd = FH.va_code_Fadd_stdcall IA.win (* Here's the type expected for the add1 wrapper *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall", "Vale.Stdcalls.X64.Fadd.code_Fadd", "Vale.Stdcalls.X64.Fadd.fadd_dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Vale.Stdcalls.X64.Fadd.fadd_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.Fadd.fadd_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.Fadd.fadd_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
true
let lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([] <: list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fadd fadd_dom [] _ _ (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
false
OWGCounter.ST.fst
OWGCounter.ST.lock_inv_predicate
val lock_inv_predicate: r: R.ref int -> r1: GR.ref int -> r2: GR.ref int -> (int & int) -> vprop
val lock_inv_predicate: r: R.ref int -> r1: GR.ref int -> r2: GR.ref int -> (int & int) -> vprop
let lock_inv_predicate (r:R.ref int) (r1 r2:GR.ref int) : int & int -> vprop = fun w -> GR.pts_to r1 half_perm (fst w) `star` GR.pts_to r2 half_perm (snd w) `star` R.pts_to r full_perm (fst w + snd w)
{ "file_name": "share/steel/examples/steel/OWGCounter.ST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 40, "end_line": 71, "start_col": 0, "start_line": 64 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module OWGCounter.ST open Steel.Memory open Steel.ST.Effect.Atomic open Steel.ST.Effect open Steel.ST.SpinLock open Steel.ST.Util module G = FStar.Ghost module R = Steel.ST.Reference module GR = Steel.ST.GhostReference (* * An implementation of the parallel counter presented by Owicki and Gries * "Verifying properties of parallel programs: An axiomatic approach.", CACM'76 * * In this example, the main thread forks two worker thread that both * increment a shared counter. The goal of the example is to show that * after both the worker threads are done, the value of the counter is * its original value + 2. * * See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation * of the OWG counters in the Chalice framework. * * The main idea is that the worker threads maintain ghost state * that stores their respective contributions to the counter * And the invariant between the counter and their contributions is * protected by a lock *) #set-options "--ide_id_info_off" let half_perm = half_perm full_perm /// r1 and r2 are the ghost references for the two worker threads /// /// The counter's value is the sum of values of r1 and r2 /// /// The lock contains full permission to the counter, /// and half permission each for r1 and r2 /// /// Rest of the half permissions for r1 and r2 are given to the /// two worker threads
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.GhostReference.fsti.checked", "Steel.ST.Effect.Atomic.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "OWGCounter.ST.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.GhostReference", "short_module": "GR" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.ST.Reference.ref Prims.int -> r1: Steel.ST.GhostReference.ref Prims.int -> r2: Steel.ST.GhostReference.ref Prims.int -> _: (Prims.int * Prims.int) -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.Reference.ref", "Prims.int", "Steel.ST.GhostReference.ref", "FStar.Pervasives.Native.tuple2", "Steel.Effect.Common.star", "Steel.ST.GhostReference.pts_to", "OWGCounter.ST.half_perm", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Prims.op_Addition", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let lock_inv_predicate (r: R.ref int) (r1 r2: GR.ref int) : (int & int) -> vprop =
fun w -> ((GR.pts_to r1 half_perm (fst w)) `star` (GR.pts_to r2 half_perm (snd w))) `star` (R.pts_to r full_perm (fst w + snd w))
false
OWGCounter.ST.fst
OWGCounter.ST.half_perm
val half_perm : Steel.FractionalPermission.perm
let half_perm = half_perm full_perm
{ "file_name": "share/steel/examples/steel/OWGCounter.ST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module OWGCounter.ST open Steel.Memory open Steel.ST.Effect.Atomic open Steel.ST.Effect open Steel.ST.SpinLock open Steel.ST.Util module G = FStar.Ghost module R = Steel.ST.Reference module GR = Steel.ST.GhostReference (* * An implementation of the parallel counter presented by Owicki and Gries * "Verifying properties of parallel programs: An axiomatic approach.", CACM'76 * * In this example, the main thread forks two worker thread that both * increment a shared counter. The goal of the example is to show that * after both the worker threads are done, the value of the counter is * its original value + 2. * * See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation * of the OWG counters in the Chalice framework. * * The main idea is that the worker threads maintain ghost state * that stores their respective contributions to the counter * And the invariant between the counter and their contributions is * protected by a lock *) #set-options "--ide_id_info_off"
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.GhostReference.fsti.checked", "Steel.ST.Effect.Atomic.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "OWGCounter.ST.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.GhostReference", "short_module": "GR" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Steel.FractionalPermission.perm
Prims.Tot
[ "total" ]
[]
[ "Steel.FractionalPermission.half_perm", "Steel.FractionalPermission.full_perm" ]
[]
false
false
false
true
false
let half_perm =
half_perm full_perm
false
OWGCounter.ST.fst
OWGCounter.ST.lock_inv
val lock_inv (r: R.ref int) (r1 r2: GR.ref int) : vprop
val lock_inv (r: R.ref int) (r1 r2: GR.ref int) : vprop
let lock_inv (r:R.ref int) (r1 r2:GR.ref int) : vprop = exists_ (lock_inv_predicate r r1 r2)
{ "file_name": "share/steel/examples/steel/OWGCounter.ST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 75, "start_col": 0, "start_line": 74 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module OWGCounter.ST open Steel.Memory open Steel.ST.Effect.Atomic open Steel.ST.Effect open Steel.ST.SpinLock open Steel.ST.Util module G = FStar.Ghost module R = Steel.ST.Reference module GR = Steel.ST.GhostReference (* * An implementation of the parallel counter presented by Owicki and Gries * "Verifying properties of parallel programs: An axiomatic approach.", CACM'76 * * In this example, the main thread forks two worker thread that both * increment a shared counter. The goal of the example is to show that * after both the worker threads are done, the value of the counter is * its original value + 2. * * See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation * of the OWG counters in the Chalice framework. * * The main idea is that the worker threads maintain ghost state * that stores their respective contributions to the counter * And the invariant between the counter and their contributions is * protected by a lock *) #set-options "--ide_id_info_off" let half_perm = half_perm full_perm /// r1 and r2 are the ghost references for the two worker threads /// /// The counter's value is the sum of values of r1 and r2 /// /// The lock contains full permission to the counter, /// and half permission each for r1 and r2 /// /// Rest of the half permissions for r1 and r2 are given to the /// two worker threads [@@ __reduce__] let lock_inv_predicate (r:R.ref int) (r1 r2:GR.ref int) : int & int -> vprop = fun w -> GR.pts_to r1 half_perm (fst w) `star` GR.pts_to r2 half_perm (snd w) `star` R.pts_to r full_perm (fst w + snd w)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.GhostReference.fsti.checked", "Steel.ST.Effect.Atomic.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "OWGCounter.ST.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.GhostReference", "short_module": "GR" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "OWGCounter", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.ST.Reference.ref Prims.int -> r1: Steel.ST.GhostReference.ref Prims.int -> r2: Steel.ST.GhostReference.ref Prims.int -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.Reference.ref", "Prims.int", "Steel.ST.GhostReference.ref", "Steel.ST.Util.exists_", "FStar.Pervasives.Native.tuple2", "OWGCounter.ST.lock_inv_predicate", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let lock_inv (r: R.ref int) (r1 r2: GR.ref int) : vprop =
exists_ (lock_inv_predicate r r1 r2)
false
Hacl.Impl.RSAPSS.Padding.fst
Hacl.Impl.RSAPSS.Padding.pss_verify
val pss_verify: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> emBits:size_t{0 < v emBits} -> em:lbuffer uint8 (BD.blocks emBits 8ul) -> Stack bool (requires fun h -> live h msg /\ live h em /\ disjoint em msg) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.pss_verify a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em))
val pss_verify: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> emBits:size_t{0 < v emBits} -> em:lbuffer uint8 (BD.blocks emBits 8ul) -> Stack bool (requires fun h -> live h msg /\ live h em /\ disjoint em msg) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.pss_verify a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em))
let pss_verify a saltLen msgLen msg emBits em = let emLen = BD.blocks emBits 8ul in let msBits = emBits %. 8ul in let em_0 = if msBits >. 0ul then em.(0ul) &. (u8 0xff <<. msBits) else u8 0 in let em_last = em.(emLen -! 1ul) in if (emLen <. saltLen +! hash_len a +! 2ul) then false else begin if not (FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_last =^ 0xbcuy) && FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_0 =^ 0uy)) then false else pss_verify_ a saltLen msgLen msg emBits em end
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 250, "start_col": 0, "start_line": 239 }
module Hacl.Impl.RSAPSS.Padding open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.RSAPSS.MGF module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module Hash = Spec.Agile.Hash module S = Spec.RSAPSS module BD = Hacl.Bignum.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length inline_for_extraction noextract let salt_len_t (a:Hash.fixed_len_alg) = saltLen:size_t{8 + Hash.hash_length a + v saltLen <= max_size_t /\ (8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a} inline_for_extraction noextract let msg_len_t (a:Hash.fixed_len_alg) = msgLen:size_t{v msgLen `less_than_max_input_length` a} inline_for_extraction noextract let em_len_t (a:Hash.fixed_len_alg) (saltLen:salt_len_t a) = emBits:size_t{0 < v emBits /\ Hash.hash_length a + v saltLen + 2 <= S.blocks (v emBits) 8} inline_for_extraction noextract val xor_bytes: len:size_t{v len > 0} -> b1:lbuffer uint8 len -> b2:lbuffer uint8 len -> Stack unit (requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2) (ensures fun h0 _ h1 -> modifies (loc b1) h0 h1 /\ as_seq h1 b1 == S.xor_bytes (as_seq h0 b1) (as_seq h0 b2)) let xor_bytes len b1 b2 = map2T len b1 (fun x y -> x ^. y) b1 b2 inline_for_extraction noextract val db_zero: len:size_t{v len > 0} -> db:lbuffer uint8 len -> emBits:size_t -> Stack unit (requires fun h -> live h db) (ensures fun h0 _ h1 -> modifies (loc db) h0 h1 /\ as_seq h1 db == S.db_zero #(v len) (as_seq h0 db) (v emBits)) let db_zero len db emBits = let msBits = emBits %. 8ul in if msBits >. 0ul then db.(0ul) <- db.(0ul) &. (u8 0xff >>. (8ul -. msBits)) inline_for_extraction noextract val get_m1Hash: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> salt:lbuffer uint8 saltLen -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> hLen:size_t{v hLen == Hash.hash_length a} -> m1Hash:lbuffer uint8 hLen -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m1Hash /\ disjoint msg salt /\ disjoint m1Hash msg /\ disjoint m1Hash salt) (ensures fun h0 _ h1 -> modifies (loc m1Hash) h0 h1 /\ (let mHash = Hash.hash a (as_seq h0 msg) in let m1Len = 8 + Hash.hash_length a + v saltLen in let m1 = LSeq.create m1Len (u8 0) in let m1 = LSeq.update_sub m1 8 (Hash.hash_length a) mHash in let m1 = LSeq.update_sub m1 (8 + Hash.hash_length a) (v saltLen) (as_seq h0 salt) in as_seq h1 m1Hash == Hash.hash a m1)) let get_m1Hash a saltLen salt msgLen msg hLen m1Hash = push_frame (); //m1 = [8 * 0x00; mHash; salt] let m1Len = 8ul +! hLen +! saltLen in let m1 = create m1Len (u8 0) in let h0 = ST.get () in update_sub_f h0 m1 8ul hLen (fun h -> Hash.hash a (as_seq h0 msg)) (fun _ -> hash a (sub m1 8ul hLen) msgLen msg); update_sub m1 (8ul +! hLen) saltLen salt; hash a m1Hash m1Len m1; pop_frame() inline_for_extraction noextract val get_maskedDB: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> salt:lbuffer uint8 saltLen -> hLen:size_t{v hLen == Hash.hash_length a} -> m1Hash:lbuffer uint8 hLen -> emBits:em_len_t a saltLen -> dbLen:size_t{v dbLen == S.blocks (v emBits) 8 - Hash.hash_length a - 1} -> db_mask:lbuffer uint8 dbLen -> Stack unit (requires fun h -> live h salt /\ live h m1Hash /\ live h db_mask /\ disjoint m1Hash salt /\ disjoint m1Hash db_mask /\ disjoint db_mask salt /\ as_seq h db_mask == LSeq.create (v dbLen) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc db_mask) h0 h1 /\ (let emLen = S.blocks (v emBits) 8 in let dbLen = emLen - Hash.hash_length a - 1 in let db = LSeq.create dbLen (u8 0) in let last_before_salt = dbLen - v saltLen - 1 in let db = LSeq.upd db last_before_salt (u8 1) in let db = LSeq.update_sub db (last_before_salt + 1) (v saltLen) (as_seq h0 salt) in let dbMask = S.mgf_hash a (v hLen) (as_seq h0 m1Hash) dbLen in let maskedDB = S.xor_bytes db dbMask in let maskedDB = S.db_zero maskedDB (v emBits) in as_seq h1 db_mask == maskedDB)) let get_maskedDB a saltLen salt hLen m1Hash emBits dbLen db = push_frame (); //db = [0x00;..; 0x00; 0x01; salt] let last_before_salt = dbLen -! saltLen -! 1ul in db.(last_before_salt) <- u8 1; update_sub db (last_before_salt +! 1ul) saltLen salt; let dbMask = create dbLen (u8 0) in assert_norm (Hash.hash_length a + 4 <= max_size_t /\ (Hash.hash_length a + 4) `less_than_max_input_length` a); mgf_hash a hLen m1Hash dbLen dbMask; xor_bytes dbLen db dbMask; db_zero dbLen db emBits; pop_frame() val pss_encode: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> salt:lbuffer uint8 saltLen -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> emBits:em_len_t a saltLen -> em:lbuffer uint8 (BD.blocks emBits 8ul) -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h em /\ disjoint msg salt /\ disjoint em msg /\ disjoint em salt /\ as_seq h em == LSeq.create (S.blocks (v emBits) 8) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc em) h0 h1 /\ as_seq h1 em == S.pss_encode a (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (v emBits)) [@CInline] let pss_encode a saltLen salt msgLen msg emBits em = push_frame (); let hLen = hash_len a in let m1Hash = create hLen (u8 0) in get_m1Hash a saltLen salt msgLen msg hLen m1Hash; let emLen = BD.blocks emBits 8ul in let dbLen = emLen -! hLen -! 1ul in let db = create dbLen (u8 0) in get_maskedDB a saltLen salt hLen m1Hash emBits dbLen db; update_sub em 0ul dbLen db; update_sub em dbLen hLen m1Hash; em.(emLen -! 1ul) <- u8 0xbc; pop_frame() inline_for_extraction noextract val pss_verify_: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> emBits:em_len_t a saltLen -> em:lbuffer uint8 (BD.blocks emBits 8ul) -> Stack bool (requires fun h -> live h msg /\ live h em /\ disjoint em msg) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.pss_verify_ a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em)) let pss_verify_ a saltLen msgLen msg emBits em = push_frame (); let emLen = BD.blocks emBits 8ul in let hLen = hash_len a in let m1Hash0 = create hLen (u8 0) in let dbLen = emLen -! hLen -! 1ul in let maskedDB = sub em 0ul dbLen in let m1Hash = sub em dbLen hLen in let dbMask = create dbLen (u8 0) in mgf_hash a hLen m1Hash dbLen dbMask; xor_bytes dbLen dbMask maskedDB; db_zero dbLen dbMask emBits; let padLen = emLen -! saltLen -! hLen -! 1ul in let pad2 = create padLen (u8 0) in pad2.(padLen -! 1ul) <- u8 0x01; let pad = sub dbMask 0ul padLen in let salt = sub dbMask padLen saltLen in let res = if not (Lib.ByteBuffer.lbytes_eq #padLen pad pad2) then false else begin get_m1Hash a saltLen salt msgLen msg hLen m1Hash0; Lib.ByteBuffer.lbytes_eq #hLen m1Hash0 m1Hash end in pop_frame (); res #set-options "--z3rlimit 300" val pss_verify: a:Hash.hash_alg{S.hash_is_supported a} -> saltLen:salt_len_t a -> msgLen:msg_len_t a -> msg:lbuffer uint8 msgLen -> emBits:size_t{0 < v emBits} -> em:lbuffer uint8 (BD.blocks emBits 8ul) -> Stack bool (requires fun h -> live h msg /\ live h em /\ disjoint em msg) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.pss_verify a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em))
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.Padding.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.RSAPSS.MGF", "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.RSAPSS", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.RSAPSS", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> saltLen: Hacl.Impl.RSAPSS.Padding.salt_len_t a -> msgLen: Hacl.Impl.RSAPSS.Padding.msg_len_t a -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msgLen -> emBits: Lib.IntTypes.size_t{0 < Lib.IntTypes.v emBits} -> em: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Bignum.Definitions.blocks emBits 8ul) -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.Padding.salt_len_t", "Hacl.Impl.RSAPSS.Padding.msg_len_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.op_Plus_Bang", "Hacl.Impl.RSAPSS.MGF.hash_len", "Prims.bool", "Prims.op_Negation", "Prims.op_AmpAmp", "FStar.UInt8.op_Equals_Hat", "Lib.RawIntTypes.u8_to_UInt8", "FStar.UInt8.__uint_to_t", "Hacl.Impl.RSAPSS.Padding.pss_verify_", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Greater_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.u8", "Lib.IntTypes.op_Percent_Dot", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Hacl.Spec.Bignum.Definitions.blocks" ]
[]
false
true
false
false
false
let pss_verify a saltLen msgLen msg emBits em =
let emLen = BD.blocks emBits 8ul in let msBits = emBits %. 8ul in let em_0 = if msBits >. 0ul then em.(0ul) &. (u8 0xff <<. msBits) else u8 0 in let em_last = em.(emLen -! 1ul) in if (emLen <. saltLen +! hash_len a +! 2ul) then false else if not (FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_last =^ 0xbcuy) && FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_0 =^ 0uy)) then false else pss_verify_ a saltLen msgLen msg emBits em
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extend_env
val extend_env (g: env) (b: binder) : T.Tac (env & mlident & mlty & name)
val extend_env (g: env) (b: binder) : T.Tac (env & mlident & mlty & name)
let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 64, "end_line": 78, "start_col": 0, "start_line": 69 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> b: Pulse.Syntax.Base.binder -> FStar.Tactics.Effect.Tac (((Pulse.Extract.Main.env * Pulse.Extract.CompilerLib.mlident) * Pulse.Extract.CompilerLib.mlty) * Pulse.Extract.Main.name)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.binder", "Pulse.Extract.CompilerLib.uenv", "Pulse.Extract.CompilerLib.mlident", "FStar.Pervasives.Native.Mktuple4", "Pulse.Extract.CompilerLib.mlty", "Pulse.Extract.Main.name", "Pulse.Extract.Main.Mkenv", "FStar.Pervasives.Native.Mktuple2", "Pulse.Syntax.Base.ppname", "Prims.nat", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "FStar.Pervasives.Native.tuple4", "FStar.Pervasives.Native.tuple2", "Pulse.Extract.CompilerLib.extend_bv", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Prims.unit", "Pulse.Extract.Main.debug", "Prims.string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.binder_to_string", "Pulse.Syntax.Printer.term_to_string", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Typing.Env.env", "Prims.eq2", "FStar.Reflection.Typing.fstar_top_env", "Pulse.Typing.Env.fstar_env", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.var", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "Pulse.Typing.Env.dom", "Pulse.Typing.Env.fresh", "Pulse.Extract.Main.term_as_mlty" ]
[]
false
true
false
false
false
let extend_env (g: env) (b: binder) : T.Tac (env & mlident & mlty & name) =
let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner = uenv_inner; coreenv = coreenv }, mlident, mlty, (b.binder_ppname, x)
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.push_binding
val push_binding : g: Pulse.Extract.Main.env -> x: Pulse.Syntax.Base.var{~(FStar.Set.mem x (Pulse.Typing.Env.dom (Mkenv?.coreenv g)))} -> b: Pulse.Syntax.Base.binder -> Pulse.Extract.Main.env
let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty }
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 77, "end_line": 311, "start_col": 0, "start_line": 310 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> x: Pulse.Syntax.Base.var{~(FStar.Set.mem x (Pulse.Typing.Env.dom (Mkenv?.coreenv g)))} -> b: Pulse.Syntax.Base.binder -> Pulse.Extract.Main.env
Prims.Tot
[ "total" ]
[]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.var", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "Pulse.Typing.Env.dom", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "Pulse.Syntax.Base.binder", "Pulse.Extract.Main.Mkenv", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty" ]
[]
false
false
false
false
false
let push_binding (g: env) (x: var{~(x `Set.mem` (E.dom g.coreenv))}) (b: binder) =
{ g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty }
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extract_constant
val extract_constant (g: env) (c: T.vconst) : T.Tac mlconstant
val extract_constant (g: env) (c: T.vconst) : T.Tac mlconstant
let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 96, "start_col": 0, "start_line": 90 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> c: FStar.Stubs.Reflection.V2.Data.vconst -> FStar.Tactics.Effect.Tac Pulse.Extract.CompilerLib.mlconstant
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "FStar.Stubs.Reflection.V2.Data.vconst", "Pulse.Extract.CompilerLib.mlexpr", "Pulse.Extract.CompilerLib.e_tag", "Pulse.Extract.CompilerLib.mlty", "FStar.Tactics.Effect.raise", "Pulse.Extract.CompilerLib.mlconstant", "Pulse.Extract.Main.Extraction_failure", "FStar.Pervasives.Native.option", "Pulse.Extract.CompilerLib.mlconstant_of_mlexpr", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.CompilerLib.term_as_mlexpr", "Pulse.Extract.Main.uenv_of_env", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Const" ]
[]
false
true
false
false
false
let extract_constant (g: env) (c: T.vconst) : T.Tac mlconstant =
let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.unit_val
val unit_val:term
val unit_val:term
let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 74, "end_line": 134, "start_col": 0, "start_line": 134 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern")
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.tm_fstar", "Pulse.Reflection.Util.unit_tm", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let unit_val:term =
tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.st_term_abs_take_n_args
val st_term_abs_take_n_args (n_args: nat) (t: st_term) : res: (st_term & nat){snd res <= n_args}
val st_term_abs_take_n_args (n_args: nat) (t: st_term) : res: (st_term & nat){snd res <= n_args}
let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) )
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 190, "start_col": 0, "start_line": 183 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n_args: Prims.nat -> t: Pulse.Syntax.Base.st_term -> res: (Pulse.Syntax.Base.st_term * Prims.nat) {FStar.Pervasives.Native.snd res <= n_args}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Pulse.Syntax.Base.st_term", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.binder", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp_ascription", "Pulse.Extract.Main.st_term_abs_take_n_args", "Prims.op_Subtraction", "Pulse.Syntax.Base.st_term'", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Pervasives.Native.snd" ]
[ "recursion" ]
false
false
false
false
false
let rec st_term_abs_take_n_args (n_args: nat) (t: st_term) : res: (st_term & nat){snd res <= n_args} =
if n_args = 0 then t, 0 else (match t.term with | Tm_Abs { body = body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args))
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.abs_take_n_args
val abs_take_n_args (n_args: nat) (t: either st_term R.term) : T.Tac (res: (either st_term R.term & nat){snd res <= n_args})
val abs_take_n_args (n_args: nat) (t: either st_term R.term) : T.Tac (res: (either st_term R.term & nat){snd res <= n_args})
let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 209, "start_col": 0, "start_line": 201 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) )
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n_args: Prims.nat -> t: FStar.Pervasives.either Pulse.Syntax.Base.st_term FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (res: (FStar.Pervasives.either Pulse.Syntax.Base.st_term FStar.Stubs.Reflection.Types.term * Prims.nat) {FStar.Pervasives.Native.snd res <= n_args})
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.nat", "FStar.Pervasives.either", "Pulse.Syntax.Base.st_term", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Inl", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Pervasives.Native.snd", "Pulse.Extract.Main.st_term_abs_take_n_args", "FStar.Pervasives.Inr", "Pulse.Extract.Main.term_abs_take_n_args" ]
[]
false
true
false
false
false
let abs_take_n_args (n_args: nat) (t: either st_term R.term) : T.Tac (res: (either st_term R.term & nat){snd res <= n_args}) =
match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.with_open
val with_open (g: env) (b: binder) (e: st_term) (f: (env -> st_term -> T.Tac st_term)) : T.Tac st_term
val with_open (g: env) (b: binder) (e: st_term) (f: (env -> st_term -> T.Tac st_term)) : T.Tac st_term
let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 318, "start_col": 0, "start_line": 313 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty }
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> b: Pulse.Syntax.Base.binder -> e: Pulse.Syntax.Base.st_term -> f: (_: Pulse.Extract.Main.env -> _: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term) -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Naming.close_st_term'", "Pulse.Extract.Main.push_binding", "Pulse.Syntax.Naming.open_st_term'", "Pulse.Syntax.Pure.tm_var", "Pulse.Syntax.Base.Mknm", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "Pulse.Syntax.Base.var", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "Pulse.Typing.Env.dom", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "Pulse.Extract.Main.fresh" ]
[]
false
true
false
false
false
let with_open (g: env) (b: binder) (e: st_term) (f: (env -> st_term -> T.Tac st_term)) : T.Tac st_term =
let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var ({ nm_index = x; nm_ppname = b.binder_ppname })) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.name_as_mlpath
val name_as_mlpath (x: T.name) : T.Tac mlpath
val name_as_mlpath (x: T.name) : T.Tac mlpath
let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 87, "start_col": 0, "start_line": 80 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Stubs.Reflection.Types.name -> FStar.Tactics.Effect.Tac Pulse.Extract.CompilerLib.mlpath
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.name", "FStar.Tactics.V2.Derived.fail", "Pulse.Extract.CompilerLib.mlpath", "Prims.string", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "Pulse.Extract.CompilerLib.mlsymbol", "Prims.Nil", "Prims.Cons", "Pulse.Extract.Main.name_as_mlpath" ]
[ "recursion" ]
false
true
false
false
false
let rec name_as_mlpath (x: T.name) : T.Tac mlpath =
match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.term_abs_take_n_args
val term_abs_take_n_args (n_args: nat) (t: R.term) : res: (R.term & nat){snd res <= n_args}
val term_abs_take_n_args (n_args: nat) (t: R.term) : res: (R.term & nat){snd res <= n_args}
let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) )
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 199, "start_col": 0, "start_line": 192 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) )
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n_args: Prims.nat -> t: FStar.Stubs.Reflection.Types.term -> res: (FStar.Stubs.Reflection.Types.term * Prims.nat) {FStar.Pervasives.Native.snd res <= n_args}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Stubs.Reflection.Types.term", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.binder", "Pulse.Extract.Main.term_abs_take_n_args", "Prims.op_Subtraction", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Pervasives.Native.snd" ]
[ "recursion" ]
false
false
false
false
false
let rec term_abs_take_n_args (n_args: nat) (t: R.term) : res: (R.term & nat){snd res <= n_args} =
if n_args = 0 then t, 0 else (match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args))
false
Hacl.Impl.Blake2.Core.fst
Hacl.Impl.Blake2.Core.load_state_from_state32
val load_state_from_state32: #a:Spec.alg -> #m:m_spec -> load_state_st a m
val load_state_from_state32: #a:Spec.alg -> #m:m_spec -> load_state_st a m
let load_state_from_state32 #a #m st st32 = let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let b0 = rowi st32 0ul in let b1 = rowi st32 1ul in let b2 = rowi st32 2ul in let b3 = rowi st32 3ul in g_rowi_disjoint_other #_ #_ #(word_t a) st 0ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 0ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 1ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 1ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 2ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 2ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 3ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 3ul st; assert (disjoint r0 st32); assert (disjoint r0 b0); assert (disjoint r1 st32); assert (disjoint r1 b1); let h0 = ST.get() in load_row r0 b0; load_row r1 b1; load_row r2 b2; load_row r3 b3; let h1 = ST.get() in Lib.Sequence.eq_intro (as_seq h0 b0) (Spec.load_row #a (as_seq h0 b0)); Lib.Sequence.eq_intro (as_seq h0 b1) (Spec.load_row #a (as_seq h0 b1)); Lib.Sequence.eq_intro (as_seq h0 b2) (Spec.load_row #a (as_seq h0 b2)); Lib.Sequence.eq_intro (as_seq h0 b3) (Spec.load_row #a (as_seq h0 b3)); assert(row_v h0 b0 == Spec.load_row (as_seq h0 b0)); assert(row_v h1 r0 == row_v h0 b0); assert (state_v h1 st == state_v h0 st32)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 340, "start_col": 0, "start_line": 307 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" noextract inline_for_extraction let zero_element (a:Spec.alg) (m:m_spec) : element_t a m = match a,m with | Spec.Blake2S,M128 -> (vec_zero U32 4) | Spec.Blake2S,M256 -> (vec_zero U32 4) | Spec.Blake2B,M256 -> (vec_zero U64 4) | _ -> Spec.zero a noextract inline_for_extraction let row_v #a #m h r = match a,m with | Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | _ -> as_seq h r let row_v_lemma #a #m h0 h1 r1 r2 = () let create_default_params a salt personal = match a with | Spec.Blake2S -> { digest_length = u8 32; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u16 0; node_depth = u8 0; inner_length = u8 0; salt; personal } <: blake2s_params | Spec.Blake2B -> { digest_length = u8 64; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u32 0; node_depth = u8 0; inner_length = u8 0; salt; personal } #push-options "--z3rlimit 50" let g_rowi_disjoint #a #m st idx1 idx2 = if idx1 <. idx2 then ( assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m)); assert (g_rowi st idx1 == gsub st (idx1 *. row_len a m) (row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) ) else if idx2 <. idx1 then ( assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))) else () let g_rowi_unchanged #a #m h0 h1 st i = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) let g_rowi_disjoint_other #a #m #b st i x = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) #pop-options inline_for_extraction noextract let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) = let r0 = row_v h (g_rowi st 0ul) in let r1 = row_v h (g_rowi st 1ul) in let r2 = row_v h (g_rowi st 2ul) in let r3 = row_v h (g_rowi st 3ul) in Lib.Sequence.create4 r0 r1 r2 r3 #push-options "--z3rlimit 100" let state_v_eq_lemma #a #m h0 h1 st1 st2 = assert (v (0ul *. row_len a m) == 0); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m))); assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m))); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul)); row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul); Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) #pop-options let state_v_rowi_lemma #a #m h st i = () let state_v_live_rowi_lemma #a #m h st i = () #push-options "--z3rlimit 50" let modifies_one_row a m h0 h1 st i j = let ri = g_rowi st i in let rj = g_rowi st j in assert (live h0 ri); assert (live h0 rj); assert (modifies (loc ri) h0 h1); assert (disjoint rj ri); assert (as_seq h1 rj == as_seq h0 rj) let modifies_row_state a m h0 h1 st i = Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i))) #pop-options noextract inline_for_extraction let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) = sub st (idx *. row_len a m) (row_len a m) noextract inline_for_extraction let xor_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 noextract inline_for_extraction let add_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2 #push-options "--z3rlimit 200" noextract inline_for_extraction let ror_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2S,M256 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2B,M256 -> r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2 | _ -> let r1:lbuffer (Spec.word_t a) 4ul = r1 in mapT 4ul r1 (rotate_right_i r2) r1 #pop-options #push-options "--z3rlimit 50" noextract inline_for_extraction let permr_row #a #m r1 n = [@inline_let] let n0 = n in [@inline_let] let n1 = (n+.1ul)%.4ul in [@inline_let] let n2 = (n+.2ul)%.4ul in [@inline_let] let n3 = (n+.3ul)%.4ul in match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 -> let v0 : vec_t U32 4 = r1.(0ul) in let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | Spec.Blake2B,M256 -> let v0 : vec_t U64 4 = r1.(0ul) in let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | _ -> let h0 = ST.get() in let r1:lbuffer (Spec.word_t a) 4ul = r1 in let x0 = r1.(n0) in let x1 = r1.(n1) in let x2 = r1.(n2) in let x3 = r1.(n3) in r1.(0ul) <- x0; r1.(1ul) <- x1; r1.(2ul) <- x2; r1.(3ul) <- x3; let h1 = ST.get() in Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4]))); Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4])))); Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3)); () #pop-options #push-options "--z3rlimit 50" let create4_lemma #a x0 x1 x2 x3 = let open Lib.Sequence in let l : list a = [x0;x1;x2;x3] in assert_norm (List.Tot.length l = 4); let s1 : lseq a 4 = of_list l in let s2 : lseq a 4 = create4 x0 x1 x2 x3 in Seq.intro_of_list s2 l; eq_intro s1 s2 #pop-options noextract inline_for_extraction let alloc_row a m = create (row_len a m) (zero_element a m) noextract inline_for_extraction let create_row #a #m r w0 w1 w2 w3 = match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 | Spec.Blake2B,M256 -> r.(0ul) <- vec_load4 w0 w1 w2 w3 | _ -> r.(0ul) <- w0; r.(1ul) <- w1; r.(2ul) <- w2; r.(3ul) <- w3; let h1 = ST.get() in Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3) noextract inline_for_extraction let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul) noextract inline_for_extraction let store_row #a #m b r = match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 -> vec_store_le #U32 #4 b r.(0ul) | Spec.Blake2B,M256 -> vec_store_le #U64 #4 b r.(0ul) | _ -> uints_to_bytes_le #(Spec.wt a) 4ul b r noextract inline_for_extraction let store_row32 #a #m b r = push_frame(); let h0 = ST.get() in let b8 = create (size_row a) (u8 0) in store_row b8 r; let h1 = ST.get() in uints_from_bytes_le b b8; let h2 = ST.get() in assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r)); assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8)); Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b)); assert (Spec.load_row (as_seq h2 b) == Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8)); Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r); pop_frame() noextract inline_for_extraction let gather_row #a #ms r m i0 i1 i2 i3 = create_row r m.(i0) m.(i1) m.(i2) m.(i3) noextract inline_for_extraction let le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } = let open FStar.Mul in assert_norm ((4 * 1) % pow2 32 = 4); assert_norm ((4 * 4) % pow2 32 = 16); Lib.IntTypes.mul_mod_lemma 4ul 1ul; Lib.IntTypes.mul_mod_lemma 4ul 4ul; match a,m with | Spec.Blake2S,M128 -> 4ul | Spec.Blake2S,M256 -> 4ul | Spec.Blake2B,M256 -> 4ul | _ -> 16ul noextract inline_for_extraction let alloc_state a m = // See git blame below. I never managed to get the previous expression (4ul *. // row_len a m) to reduce, which generated VLAs in the C code. create (le_sigh a m) (zero_element a m) let copy_state #a #m st2 st1 = copy #_ #_ #(le_sigh a m) st2 st1
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Blake2.Core.fst" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Impl.Blake2.Core.load_state_st a m
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.M32", "Prims._assert", "Prims.eq2", "Spec.Blake2.Definitions.state", "Hacl.Impl.Blake2.Core.state_v", "Prims.unit", "Spec.Blake2.Definitions.row", "Hacl.Impl.Blake2.Core.row_v", "Spec.Blake2.Definitions.load_row", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Impl.Blake2.Core.element_t", "Hacl.Impl.Blake2.Core.row_len", "Lib.Sequence.eq_intro", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Blake2.Core.load_row", "Lib.Buffer.disjoint", "Hacl.Impl.Blake2.Core.g_rowi_disjoint_other", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Blake2.Core.word_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.Blake2.Core.rowi", "Hacl.Impl.Blake2.Core.row_p" ]
[]
false
false
false
false
false
let load_state_from_state32 #a #m st st32 =
let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let b0 = rowi st32 0ul in let b1 = rowi st32 1ul in let b2 = rowi st32 2ul in let b3 = rowi st32 3ul in g_rowi_disjoint_other #_ #_ #(word_t a) st 0ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 0ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 1ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 1ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 2ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 2ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 3ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 3ul st; assert (disjoint r0 st32); assert (disjoint r0 b0); assert (disjoint r1 st32); assert (disjoint r1 b1); let h0 = ST.get () in load_row r0 b0; load_row r1 b1; load_row r2 b2; load_row r3 b3; let h1 = ST.get () in Lib.Sequence.eq_intro (as_seq h0 b0) (Spec.load_row #a (as_seq h0 b0)); Lib.Sequence.eq_intro (as_seq h0 b1) (Spec.load_row #a (as_seq h0 b1)); Lib.Sequence.eq_intro (as_seq h0 b2) (Spec.load_row #a (as_seq h0 b2)); Lib.Sequence.eq_intro (as_seq h0 b3) (Spec.load_row #a (as_seq h0 b3)); assert (row_v h0 b0 == Spec.load_row (as_seq h0 b0)); assert (row_v h1 r0 == row_v h0 b0); assert (state_v h1 st == state_v h0 st32)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.eternal_pointer
val eternal_pointer : a: Type0 -> Type0
let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 }
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 20, "start_col": 0, "start_line": 20 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.buffer", "Prims.l_and", "LowStar.Monotonic.Buffer.recallable", "LowStar.Buffer.trivial_preorder", "Prims.b2t", "Prims.op_Equality", "Prims.int", "LowStar.Monotonic.Buffer.length" ]
[]
false
false
false
true
true
let eternal_pointer a =
buf: B.buffer a {B.recallable buf /\ B.length buf = 1}
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cached_flag
val cached_flag : b: Prims.bool -> Type0
let cached_flag (b: bool) = eternal_pointer (flag b)
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 23, "start_col": 0, "start_line": 23 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 }
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Prims.bool -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "EverCrypt.AutoConfig2.eternal_pointer", "EverCrypt.AutoConfig2.flag" ]
[]
false
false
false
true
true
let cached_flag (b: bool) =
eternal_pointer (flag b)
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.maybe_unfold_head
val maybe_unfold_head (g: env) (head: R.term) : T.Tac (option (either st_term R.term))
val maybe_unfold_head (g: env) (head: R.term) : T.Tac (option (either st_term R.term))
let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 15, "end_line": 181, "start_col": 0, "start_line": 152 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> head: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (FStar.Pervasives.either Pulse.Syntax.Base.st_term FStar.Stubs.Reflection.Types.term))
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V2.Builtins.lookup_typ", "Pulse.Extract.Main.topenv_of_env", "FStar.Pervasives.Native.None", "FStar.Pervasives.either", "Pulse.Syntax.Base.st_term", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.sigelt", "Prims.op_BarBar", "FStar.List.Tot.Base.existsb", "Pulse.Extract.Main.term_eq_string", "FStar.Stubs.Reflection.V2.Data.qualifier", "Prims.bool", "Pulse.Extract.CompilerLib.sigelt_extension_data", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Inl", "Prims.unit", "Pulse.Extract.Main.debug", "FStar.Printf.sprintf", "Prims.string", "Pulse.Syntax.Printer.st_term_to_string", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.NamedView.term", "FStar.Pervasives.Inr", "FStar.Tactics.NamedView.named_sigelt_view", "FStar.Tactics.NamedView.inspect_sigelt", "Prims.list", "FStar.Stubs.Reflection.V2.Builtins.sigelt_quals", "FStar.Stubs.Reflection.V2.Builtins.sigelt_attrs", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.V2.Data.term_view" ]
[]
false
true
false
false
false
let maybe_unfold_head (g: env) (head: R.term) : T.Tac (option (either st_term R.term)) =
debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> (let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> (match T.inspect_sigelt se with | T.Sg_Let { isrec = false ; lbs = [{ lb_us = [] ; lb_def = lb_def }] } -> Some (Inr lb_def) | _ -> None) else None) | R.Tv_UInst f _ -> None | _ -> None
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.is_return_bv0
val is_return_bv0 (e: st_term) : bool
val is_return_bv0 (e: st_term) : bool
let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 338, "start_col": 0, "start_line": 335 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: Pulse.Syntax.Base.st_term -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.st_term", "Pulse.Extract.Main.is_return", "Pulse.Syntax.Base.term", "Prims.op_Equality", "FStar.Pervasives.Native.option", "Prims.nat", "Pulse.Syntax.Pure.is_bvar", "FStar.Pervasives.Native.Some", "Prims.bool" ]
[]
false
false
false
true
false
let is_return_bv0 (e: st_term) : bool =
match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false
false
Hacl.Impl.Blake2.Core.fst
Hacl.Impl.Blake2.Core.modifies_row_state
val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)]
val modifies_row_state: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1)) (ensures (modifies (loc st) h0 h1 /\ state_v h1 st == Lib.Sequence.((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))) [SMTPat (modifies (loc (g_rowi #a #m st i)) h0 h1)]
let modifies_row_state a m h0 h1 st i = Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 93, "end_line": 129, "start_col": 0, "start_line": 128 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" noextract inline_for_extraction let zero_element (a:Spec.alg) (m:m_spec) : element_t a m = match a,m with | Spec.Blake2S,M128 -> (vec_zero U32 4) | Spec.Blake2S,M256 -> (vec_zero U32 4) | Spec.Blake2B,M256 -> (vec_zero U64 4) | _ -> Spec.zero a noextract inline_for_extraction let row_v #a #m h r = match a,m with | Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | _ -> as_seq h r let row_v_lemma #a #m h0 h1 r1 r2 = () let create_default_params a salt personal = match a with | Spec.Blake2S -> { digest_length = u8 32; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u16 0; node_depth = u8 0; inner_length = u8 0; salt; personal } <: blake2s_params | Spec.Blake2B -> { digest_length = u8 64; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u32 0; node_depth = u8 0; inner_length = u8 0; salt; personal } #push-options "--z3rlimit 50" let g_rowi_disjoint #a #m st idx1 idx2 = if idx1 <. idx2 then ( assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m)); assert (g_rowi st idx1 == gsub st (idx1 *. row_len a m) (row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) ) else if idx2 <. idx1 then ( assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))) else () let g_rowi_unchanged #a #m h0 h1 st i = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) let g_rowi_disjoint_other #a #m #b st i x = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) #pop-options inline_for_extraction noextract let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) = let r0 = row_v h (g_rowi st 0ul) in let r1 = row_v h (g_rowi st 1ul) in let r2 = row_v h (g_rowi st 2ul) in let r3 = row_v h (g_rowi st 3ul) in Lib.Sequence.create4 r0 r1 r2 r3 #push-options "--z3rlimit 100" let state_v_eq_lemma #a #m h0 h1 st1 st2 = assert (v (0ul *. row_len a m) == 0); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m))); assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m))); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul)); row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul); Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) #pop-options let state_v_rowi_lemma #a #m h st i = () let state_v_live_rowi_lemma #a #m h st i = () #push-options "--z3rlimit 50" let modifies_one_row a m h0 h1 st i j = let ri = g_rowi st i in let rj = g_rowi st j in assert (live h0 ri); assert (live h0 rj); assert (modifies (loc ri) h0 h1); assert (disjoint rj ri); assert (as_seq h1 rj == as_seq h0 rj)
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Blake2.Core.fst" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> st: Hacl.Impl.Blake2.Core.state_p a m -> i: Hacl.Impl.Blake2.Core.index_t -> FStar.Pervasives.Lemma (requires Lib.Buffer.live h0 st /\ Lib.Buffer.modifies (Lib.Buffer.loc (Hacl.Impl.Blake2.Core.g_rowi st i)) h0 h1) (ensures Lib.Buffer.modifies (Lib.Buffer.loc st) h0 h1 /\ Hacl.Impl.Blake2.Core.state_v h1 st == ((Hacl.Impl.Blake2.Core.state_v h0 st).[ Lib.IntTypes.v i ] <- Hacl.Impl.Blake2.Core.row_v h1 (Hacl.Impl.Blake2.Core.g_rowi st i))) [SMTPat (Lib.Buffer.modifies (Lib.Buffer.loc (Hacl.Impl.Blake2.Core.g_rowi st i)) h0 h1)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.index_t", "Lib.Sequence.eq_intro", "Spec.Blake2.Definitions.row", "Hacl.Impl.Blake2.Core.state_v", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Blake2.Core.row_v", "Hacl.Impl.Blake2.Core.g_rowi", "Prims.unit" ]
[]
true
false
true
false
false
let modifies_row_state a m h0 h1 st i =
let open Lib.Sequence in eq_intro (state_v h1 st) ((state_v h0 st).[ v i ] <- row_v h1 (g_rowi st i))
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.add1_lemma'
val add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
val add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 105, "start_col": 0, "start_line": 80 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
code: Vale.X64.Decls.va_code -> _win: Prims.bool -> out: Vale.Stdcalls.X64.Fadd.b64 -> f1: Vale.Stdcalls.X64.Fadd.b64 -> f2: Vale.Stdcalls.X64.Fadd.uint64 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Stdcalls.X64.Fadd.b64", "Vale.Stdcalls.X64.Fadd.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims._assert", "Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall", "Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.Curve25519.X64.FastUtil.va_lemma_Fast_add1_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "FStar.UInt64.v", "Vale.Stdcalls.X64.Fadd.add1_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.Stdcalls.X64.Fadd.add1_post", "Vale.X64.Memory.buffer_readable", "Vale.X64.State.vs_get_vale_heap", "Vale.X64.Memory.buffer_writeable", "Vale.X64.Memory.modifies", "Vale.X64.Memory.loc_union", "Vale.X64.Memory.loc_buffer", "Vale.X64.Memory.loc_none" ]
[]
false
false
false
false
false
let add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1))) =
let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_aesni
val has_aesni: getter Vale.X64.CPU_Features_s.aesni_enabled
val has_aesni: getter Vale.X64.CPU_Features_s.aesni_enabled
let has_aesni = mk_getter cpu_has_aesni
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 54, "start_col": 0, "start_line": 54 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.aesni_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.aesni_enabled", "EverCrypt.AutoConfig2.cpu_has_aesni" ]
[]
false
false
false
true
false
let has_aesni =
mk_getter cpu_has_aesni
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.find_map
val find_map (f: ('a -> option 'b)) (l: list 'a) : option 'b
val find_map (f: ('a -> option 'b)) (l: list 'a) : option 'b
let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 66, "end_line": 734, "start_col": 0, "start_line": 731 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Pervasives.Native.option 'b) -> l: Prims.list 'a -> FStar.Pervasives.Native.option 'b
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.uu___is_Some", "Prims.bool", "Pulse.Extract.Main.find_map" ]
[ "recursion" ]
false
false
false
true
false
let rec find_map (f: ('a -> option 'b)) (l: list 'a) : option 'b =
match l with | [] -> None | hd :: tl -> let x = f hd in if Some? x then x else find_map f tl
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_shaext
val has_shaext: getter Vale.X64.CPU_Features_s.sha_enabled
val has_shaext: getter Vale.X64.CPU_Features_s.sha_enabled
let has_shaext = mk_getter cpu_has_shaext
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 53, "start_col": 0, "start_line": 53 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.sha_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.sha_enabled", "EverCrypt.AutoConfig2.cpu_has_shaext" ]
[]
false
false
false
true
false
let has_shaext =
mk_getter cpu_has_shaext
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_pclmulqdq
val has_pclmulqdq: getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
val has_pclmulqdq: getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
let has_pclmulqdq = mk_getter cpu_has_pclmulqdq
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 55, "start_col": 0, "start_line": 55 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "EverCrypt.AutoConfig2.cpu_has_pclmulqdq" ]
[]
false
false
false
true
false
let has_pclmulqdq =
mk_getter cpu_has_pclmulqdq
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.simplify_branch
val simplify_branch (g: env) (b: branch) : T.Tac branch
val simplify_branch (g: env) (b: branch) : T.Tac branch
let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 439, "start_col": 0, "start_line": 369 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> b: Pulse.Syntax.Base.branch -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.branch
FStar.Tactics.Effect.Tac
[]
[ "simplify_st_term", "simplify_branch" ]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.branch", "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.st_term", "Pulse.Extract.CompilerLib.mlpattern", "Prims.list", "Pulse.Typing.Env.binding", "FStar.Pervasives.Native.Mktuple2", "Pulse.Syntax.Naming.close_st_term_n", "FStar.List.Tot.Base.map", "Pulse.Syntax.Base.var", "FStar.Pervasives.Native.fst", "Pulse.Syntax.Base.typ", "Pulse.Extract.Main.simplify_st_term", "Pulse.Checker.Match.open_st_term_bs", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.Main.extend_env_pat" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec simplify_branch (g: env) (b: branch) : T.Tac branch =
let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_avx2
val has_avx2: getter Vale.X64.CPU_Features_s.avx2_enabled
val has_avx2: getter Vale.X64.CPU_Features_s.avx2_enabled
let has_avx2 = mk_getter cpu_has_avx2
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 56, "start_col": 0, "start_line": 56 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.avx2_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.avx2_enabled", "EverCrypt.AutoConfig2.cpu_has_avx2" ]
[]
false
false
false
true
false
let has_avx2 =
mk_getter cpu_has_avx2
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_adx
val has_adx: getter Vale.X64.CPU_Features_s.adx_enabled
val has_adx: getter Vale.X64.CPU_Features_s.adx_enabled
let has_adx = mk_getter cpu_has_adx
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 59, "start_col": 0, "start_line": 59 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.adx_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.adx_enabled", "EverCrypt.AutoConfig2.cpu_has_adx" ]
[]
false
false
false
true
false
let has_adx =
mk_getter cpu_has_adx
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_movbe
val has_movbe: getter Vale.X64.CPU_Features_s.movbe_enabled
val has_movbe: getter Vale.X64.CPU_Features_s.movbe_enabled
let has_movbe = mk_getter cpu_has_movbe
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 61, "start_col": 0, "start_line": 61 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.movbe_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.movbe_enabled", "EverCrypt.AutoConfig2.cpu_has_movbe" ]
[]
false
false
false
true
false
let has_movbe =
mk_getter cpu_has_movbe
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_sse
val has_sse: getter Vale.X64.CPU_Features_s.sse_enabled
val has_sse: getter Vale.X64.CPU_Features_s.sse_enabled
let has_sse = mk_getter cpu_has_sse
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 60, "start_col": 0, "start_line": 60 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.sse_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.sse_enabled", "EverCrypt.AutoConfig2.cpu_has_sse" ]
[]
false
false
false
true
false
let has_sse =
mk_getter cpu_has_sse
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_bmi2
val has_bmi2: getter Vale.X64.CPU_Features_s.bmi2_enabled
val has_bmi2: getter Vale.X64.CPU_Features_s.bmi2_enabled
let has_bmi2 = mk_getter cpu_has_bmi2
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 58, "start_col": 0, "start_line": 58 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.bmi2_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.bmi2_enabled", "EverCrypt.AutoConfig2.cpu_has_bmi2" ]
[]
false
false
false
true
false
let has_bmi2 =
mk_getter cpu_has_bmi2
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_avx
val has_avx: getter Vale.X64.CPU_Features_s.avx_enabled
val has_avx: getter Vale.X64.CPU_Features_s.avx_enabled
let has_avx = mk_getter cpu_has_avx
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 57, "start_col": 0, "start_line": 57 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.avx_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.avx_enabled", "EverCrypt.AutoConfig2.cpu_has_avx" ]
[]
false
false
false
true
false
let has_avx =
mk_getter cpu_has_avx
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.simplify_st_term
val simplify_st_term (g: env) (e: st_term) : T.Tac st_term
val simplify_st_term (g: env) (e: st_term) : T.Tac st_term
let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 439, "start_col": 0, "start_line": 369 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> e: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term
FStar.Tactics.Effect.Tac
[]
[ "simplify_st_term", "simplify_branch" ]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.st_term'__Tm_Return__payload", "Pulse.Syntax.Base.st_term'__Tm_IntroPure__payload", "Pulse.Syntax.Base.st_term'__Tm_ElimExists__payload", "Pulse.Syntax.Base.st_term'__Tm_IntroExists__payload", "Pulse.Syntax.Base.st_term'__Tm_STApp__payload", "Pulse.Syntax.Base.st_term'__Tm_Rewrite__payload", "Pulse.Syntax.Base.st_term'__Tm_Admit__payload", "Pulse.Syntax.Base.st_term'__Tm_ProofHintWithBinders__payload", "Pulse.Syntax.Base.binder", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp_ascription", "Pulse.Syntax.Base.st_term'", "Pulse.Syntax.Base.Tm_Abs", "Pulse.Syntax.Base.st_term'__Tm_Abs__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_Abs__payload", "Prims.op_AmpAmp", "Pulse.Extract.Main.is_return_bv0", "Pulse.Extract.Main.simplify_st_term", "Prims.bool", "FStar.Pervasives.Native.uu___is_Some", "Pulse.Syntax.Base.term", "Pulse.Extract.Main.is_return", "Pulse.Syntax.Naming.subst_st_term", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Prims.Nil", "Pulse.Extract.Main.simplify_nested_let", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Extract.Main.is_internal_binder", "Pulse.Syntax.Base.Tm_TotBind", "Pulse.Syntax.Base.st_term'__Tm_TotBind__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_TotBind__payload", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Tm_If", "Pulse.Syntax.Base.st_term'__Tm_If__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_If__payload", "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.Tm_Match", "Pulse.Syntax.Base.st_term'__Tm_Match__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_Match__payload", "FStar.Tactics.Util.map", "Pulse.Extract.Main.simplify_branch", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.Tm_While", "Pulse.Syntax.Base.Mkst_term'__Tm_While__payload", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Pulse.Syntax.Base.Tm_Par", "Pulse.Syntax.Base.Mkst_term'__Tm_Par__payload", "Pulse.Syntax.Base.Tm_WithLocal", "Pulse.Syntax.Base.st_term'__Tm_WithLocal__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocal__payload", "Pulse.Syntax.Base.Tm_WithLocalArray", "Pulse.Syntax.Base.st_term'__Tm_WithLocalArray__payload", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocalArray__payload", "Pulse.Extract.Main.with_open" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec simplify_st_term (g: env) (e: st_term) : T.Tac st_term =
let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b = b ; q = q ; ascription = ascription ; body = body } -> ret (Tm_Abs ({ b = b; q = q; ascription = ascription; body = with_open b body })) | Tm_Bind { binder = binder ; head = head ; body = body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else (match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind ({ binder = binder; head = head; body = body }))) | Tm_TotBind { binder = binder ; head = head ; body = body } -> ret (Tm_TotBind ({ binder = binder; head = head; body = with_open binder body })) | Tm_If { b = b ; then_ = then_ ; else_ = else_ ; post = post } -> ret (Tm_If ({ b = b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post = post })) | Tm_Match { sc = sc ; returns_ = returns_ ; brs = brs } -> ret (Tm_Match ({ sc = sc; returns_ = returns_; brs = T.map (simplify_branch g) brs })) | Tm_While { invariant = invariant ; condition = condition ; condition_var = condition_var ; body = body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While ({ invariant = invariant; condition = condition; condition_var = condition_var; body = body }) } | Tm_Par { pre1 = pre1 ; body1 = body1 ; post1 = post1 ; pre2 = pre2 ; body2 = body2 ; post2 = post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par ({ pre1 = pre1; body1 = body1; post1 = post1; pre2 = pre2; body2 = body2; post2 = post2 }) } | Tm_WithLocal { binder = binder ; initializer = initializer ; body = body } -> ret (Tm_WithLocal ({ binder = binder; initializer = initializer; body = with_open binder body })) | Tm_WithLocalArray { binder = binder ; initializer = initializer ; length = length ; body = body } -> ret (Tm_WithLocalArray ({ binder = binder; initializer = initializer; length = length; body = with_open binder body } )) | Tm_WithInv { body = body } -> simplify_st_term g body | Tm_Unreachable -> e
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_avx512
val has_avx512: getter Vale.X64.CPU_Features_s.avx512_enabled
val has_avx512: getter Vale.X64.CPU_Features_s.avx512_enabled
let has_avx512 = mk_getter cpu_has_avx512
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 63, "start_col": 0, "start_line": 63 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.avx512_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.avx512_enabled", "EverCrypt.AutoConfig2.cpu_has_avx512" ]
[]
false
false
false
true
false
let has_avx512 =
mk_getter cpu_has_avx512
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_aesni
val cpu_has_aesni:cached_flag Vale.X64.CPU_Features_s.aesni_enabled
val cpu_has_aesni:cached_flag Vale.X64.CPU_Features_s.aesni_enabled
let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 28, "start_col": 0, "start_line": 27 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.aesni_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.aesni_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_aesni:cached_flag Vale.X64.CPU_Features_s.aesni_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.has_rdrand
val has_rdrand: getter Vale.X64.CPU_Features_s.rdrand_enabled
val has_rdrand: getter Vale.X64.CPU_Features_s.rdrand_enabled
let has_rdrand = mk_getter cpu_has_rdrand
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 62, "start_col": 0, "start_line": 62 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.getter Vale.X64.CPU_Features_s.rdrand_enabled
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.mk_getter", "Vale.X64.CPU_Features_s.rdrand_enabled", "EverCrypt.AutoConfig2.cpu_has_rdrand" ]
[]
false
false
false
true
false
let has_rdrand =
mk_getter cpu_has_rdrand
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_avx
val cpu_has_avx:cached_flag Vale.X64.CPU_Features_s.avx_enabled
val cpu_has_avx:cached_flag Vale.X64.CPU_Features_s.avx_enabled
let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 34, "start_col": 0, "start_line": 33 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.avx_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_avx:cached_flag Vale.X64.CPU_Features_s.avx_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_bmi2
val cpu_has_bmi2:cached_flag Vale.X64.CPU_Features_s.bmi2_enabled
val cpu_has_bmi2:cached_flag Vale.X64.CPU_Features_s.bmi2_enabled
let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 36, "start_col": 0, "start_line": 35 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.bmi2_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.bmi2_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_bmi2:cached_flag Vale.X64.CPU_Features_s.bmi2_enabled =
B.gcmalloc_of_list HS.root [false]
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extract_recursive_knot
val extract_recursive_knot : g: Pulse.Extract.Main.env -> p: Pulse.Syntax.Base.st_term -> knot_name: FStar.Stubs.Reflection.Types.fv -> knot_typ: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either (Prims.list Pulse.Extract.CompilerLib.mlmodule1) _)
let extract_recursive_knot (g:env) (p:st_term) (knot_name:R.fv) (knot_typ:R.term) = let g, tys, lb_typ, Some p = generalize g knot_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let uenv, _mli, _ml_binding = extend_fv g.uenv_inner knot_name (tys, mlty) in let g = { g with uenv_inner = uenv } in let tm, tag = extract_recursive g p knot_name in let fv_name = let lids = R.inspect_fv knot_name in if Nil? lids then T.raise (Extraction_failure "Unexpected empty name"); FStar.List.Tot.last lids in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let mllb = mk_mllb fv_name (tys, mlty) tm in Inl [mlm_let true [mllb]]
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 800, "start_col": 0, "start_line": 785 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl let is_recursive (g:env) (knot_name:R.fv) (selt:R.sigelt) : T.Tac (option string) = let attrs = RU.get_attributes selt in let unpack_string (t:R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t:R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> ( let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_; _; (tag, _); (value, _)] -> ( match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None ) | _ -> None else None ) | _ -> None in find_map pulse_recursive_attr attrs let rec extract_recursive g (p:st_term) (rec_name:R.fv) : T.Tac (mlexpr & e_tag) = match p.term with | Tm_Abs { b; q; body } -> ( match body.term with | Tm_Abs _ -> let g, mlident, mlty, name = extend_env g b in let body = LN.open_st_term_nv body name in let body, _ = extract_recursive g body rec_name in let attrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let res = mle_fun [mlident, mlty, attrs] body in res, e_tag_pure | _ -> //last binder used for knot; replace it with the recursively bound name let body = LN.subst_st_term body [LN.DT 0 (tm_fstar R.(pack_ln (Tv_FVar rec_name)) Range.range_0)] in let body, tag = extract g body in body, tag ) | _ -> T.fail "Unexpected recursive definition of non-function"
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> p: Pulse.Syntax.Base.st_term -> knot_name: FStar.Stubs.Reflection.Types.fv -> knot_typ: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either (Prims.list Pulse.Extract.CompilerLib.mlmodule1) _)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.st_term", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.Types.term", "Prims.list", "Pulse.Extract.CompilerLib.mlident", "FStar.Stubs.Reflection.Types.typ", "Pulse.Extract.CompilerLib.uenv", "Pulse.Extract.CompilerLib.exp_binding", "Pulse.Extract.CompilerLib.mlexpr", "Pulse.Extract.CompilerLib.e_tag", "FStar.Pervasives.Inl", "Pulse.Extract.CompilerLib.mlmodule1", "Prims.Cons", "Pulse.Extract.CompilerLib.mlm_let", "Pulse.Extract.CompilerLib.mllb", "Prims.Nil", "Pulse.Extract.CompilerLib.mk_mllb", "FStar.Pervasives.Native.Mktuple2", "Pulse.Extract.CompilerLib.mlty", "FStar.Pervasives.either", "Prims.unit", "Pulse.Extract.Main.debug_", "FStar.Printf.sprintf", "Prims.string", "Pulse.Extract.CompilerLib.mlexpr_to_string", "FStar.List.Tot.Base.last", "Prims.uu___is_Nil", "FStar.Tactics.Effect.raise", "Pulse.Extract.Main.Extraction_failure", "Prims.bool", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "FStar.Pervasives.Native.tuple2", "Pulse.Extract.Main.extract_recursive", "Pulse.Extract.Main.Mkenv", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.CompilerLib.extend_fv", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Pulse.Extract.CompilerLib.term_as_mlty", "FStar.Pervasives.Native.tuple4", "FStar.Pervasives.Native.option", "Prims.l_iff", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.Some", "Pulse.Extract.Main.generalize" ]
[]
false
true
false
false
false
let extract_recursive_knot (g: env) (p: st_term) (knot_name: R.fv) (knot_typ: R.term) =
let g, tys, lb_typ, Some p = generalize g knot_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let uenv, _mli, _ml_binding = extend_fv g.uenv_inner knot_name (tys, mlty) in let g = { g with uenv_inner = uenv } in let tm, tag = extract_recursive g p knot_name in let fv_name = let lids = R.inspect_fv knot_name in if Nil? lids then T.raise (Extraction_failure "Unexpected empty name"); FStar.List.Tot.last lids in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let mllb = mk_mllb fv_name (tys, mlty) tm in Inl [mlm_let true [mllb]]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.fp
val fp: unit -> GTot B.loc
val fp: unit -> GTot B.loc
let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 76, "start_col": 0, "start_line": 65 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_buffer", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sha_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_shaext", "Vale.X64.CPU_Features_s.aesni_enabled", "EverCrypt.AutoConfig2.cpu_has_aesni", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "EverCrypt.AutoConfig2.cpu_has_pclmulqdq", "Vale.X64.CPU_Features_s.avx2_enabled", "EverCrypt.AutoConfig2.cpu_has_avx2", "Vale.X64.CPU_Features_s.avx_enabled", "EverCrypt.AutoConfig2.cpu_has_avx", "Vale.X64.CPU_Features_s.bmi2_enabled", "EverCrypt.AutoConfig2.cpu_has_bmi2", "Vale.X64.CPU_Features_s.adx_enabled", "EverCrypt.AutoConfig2.cpu_has_adx", "Vale.X64.CPU_Features_s.sse_enabled", "EverCrypt.AutoConfig2.cpu_has_sse", "Vale.X64.CPU_Features_s.movbe_enabled", "EverCrypt.AutoConfig2.cpu_has_movbe", "Vale.X64.CPU_Features_s.rdrand_enabled", "EverCrypt.AutoConfig2.cpu_has_rdrand", "Vale.X64.CPU_Features_s.avx512_enabled", "EverCrypt.AutoConfig2.cpu_has_avx512", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let fp () =
((((((((((B.loc_buffer cpu_has_shaext) `B.loc_union` (B.loc_buffer cpu_has_aesni)) `B.loc_union` (B.loc_buffer cpu_has_pclmulqdq)) `B.loc_union` (B.loc_buffer cpu_has_avx2)) `B.loc_union` (B.loc_buffer cpu_has_avx)) `B.loc_union` (B.loc_buffer cpu_has_bmi2)) `B.loc_union` (B.loc_buffer cpu_has_adx)) `B.loc_union` (B.loc_buffer cpu_has_sse)) `B.loc_union` (B.loc_buffer cpu_has_movbe)) `B.loc_union` (B.loc_buffer cpu_has_rdrand)) `B.loc_union` (B.loc_buffer cpu_has_avx512)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_sse
val cpu_has_sse:cached_flag Vale.X64.CPU_Features_s.sse_enabled
val cpu_has_sse:cached_flag Vale.X64.CPU_Features_s.sse_enabled
let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 40, "start_col": 0, "start_line": 39 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.sse_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sse_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_sse:cached_flag Vale.X64.CPU_Features_s.sse_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_pclmulqdq
val cpu_has_pclmulqdq:cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled
val cpu_has_pclmulqdq:cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled
let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 30, "start_col": 0, "start_line": 29 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.pclmulqdq_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_pclmulqdq:cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_shaext
val cpu_has_shaext:cached_flag Vale.X64.CPU_Features_s.sha_enabled
val cpu_has_shaext:cached_flag Vale.X64.CPU_Features_s.sha_enabled
let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 26, "start_col": 0, "start_line": 25 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b)
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.sha_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sha_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_shaext:cached_flag Vale.X64.CPU_Features_s.sha_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_adx
val cpu_has_adx:cached_flag Vale.X64.CPU_Features_s.adx_enabled
val cpu_has_adx:cached_flag Vale.X64.CPU_Features_s.adx_enabled
let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 38, "start_col": 0, "start_line": 37 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.adx_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.adx_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_adx:cached_flag Vale.X64.CPU_Features_s.adx_enabled =
B.gcmalloc_of_list HS.root [false]
false
Hacl.Impl.Blake2.Core.fst
Hacl.Impl.Blake2.Core.store_state_to_state32
val store_state_to_state32: #a:Spec.alg -> #m:m_spec -> store_state_st a m
val store_state_to_state32: #a:Spec.alg -> #m:m_spec -> store_state_st a m
let store_state_to_state32 #a #m st32 st = let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let b0 = rowi st32 0ul in let b1 = rowi st32 1ul in let b2 = rowi st32 2ul in let b3 = rowi st32 3ul in g_rowi_disjoint_other #_ #_ #(word_t a) st 0ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 0ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 1ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 1ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 2ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 2ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 3ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 3ul st; assert (disjoint r0 b0); assert (disjoint r1 b1); assert (disjoint r2 b2); assert (disjoint r3 b3); let h0 = ST.get() in store_row32 b0 r0; store_row32 b1 r1; store_row32 b2 r2; store_row32 b3 r3; let h1 = ST.get() in Lib.Sequence.eq_intro (as_seq h1 b0) (Spec.load_row #a (as_seq h1 b0)); Lib.Sequence.eq_intro (as_seq h1 b1) (Spec.load_row #a (as_seq h1 b1)); Lib.Sequence.eq_intro (as_seq h1 b2) (Spec.load_row #a (as_seq h1 b2)); Lib.Sequence.eq_intro (as_seq h1 b3) (Spec.load_row #a (as_seq h1 b3)); assert (state_v h1 st32 == state_v h0 st)
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 376, "start_col": 0, "start_line": 345 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" noextract inline_for_extraction let zero_element (a:Spec.alg) (m:m_spec) : element_t a m = match a,m with | Spec.Blake2S,M128 -> (vec_zero U32 4) | Spec.Blake2S,M256 -> (vec_zero U32 4) | Spec.Blake2B,M256 -> (vec_zero U64 4) | _ -> Spec.zero a noextract inline_for_extraction let row_v #a #m h r = match a,m with | Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | _ -> as_seq h r let row_v_lemma #a #m h0 h1 r1 r2 = () let create_default_params a salt personal = match a with | Spec.Blake2S -> { digest_length = u8 32; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u16 0; node_depth = u8 0; inner_length = u8 0; salt; personal } <: blake2s_params | Spec.Blake2B -> { digest_length = u8 64; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u32 0; node_depth = u8 0; inner_length = u8 0; salt; personal } #push-options "--z3rlimit 50" let g_rowi_disjoint #a #m st idx1 idx2 = if idx1 <. idx2 then ( assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m)); assert (g_rowi st idx1 == gsub st (idx1 *. row_len a m) (row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) ) else if idx2 <. idx1 then ( assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))) else () let g_rowi_unchanged #a #m h0 h1 st i = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) let g_rowi_disjoint_other #a #m #b st i x = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) #pop-options inline_for_extraction noextract let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) = let r0 = row_v h (g_rowi st 0ul) in let r1 = row_v h (g_rowi st 1ul) in let r2 = row_v h (g_rowi st 2ul) in let r3 = row_v h (g_rowi st 3ul) in Lib.Sequence.create4 r0 r1 r2 r3 #push-options "--z3rlimit 100" let state_v_eq_lemma #a #m h0 h1 st1 st2 = assert (v (0ul *. row_len a m) == 0); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m))); assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m))); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul)); row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul); Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) #pop-options let state_v_rowi_lemma #a #m h st i = () let state_v_live_rowi_lemma #a #m h st i = () #push-options "--z3rlimit 50" let modifies_one_row a m h0 h1 st i j = let ri = g_rowi st i in let rj = g_rowi st j in assert (live h0 ri); assert (live h0 rj); assert (modifies (loc ri) h0 h1); assert (disjoint rj ri); assert (as_seq h1 rj == as_seq h0 rj) let modifies_row_state a m h0 h1 st i = Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i))) #pop-options noextract inline_for_extraction let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) = sub st (idx *. row_len a m) (row_len a m) noextract inline_for_extraction let xor_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 noextract inline_for_extraction let add_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2 #push-options "--z3rlimit 200" noextract inline_for_extraction let ror_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2S,M256 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2B,M256 -> r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2 | _ -> let r1:lbuffer (Spec.word_t a) 4ul = r1 in mapT 4ul r1 (rotate_right_i r2) r1 #pop-options #push-options "--z3rlimit 50" noextract inline_for_extraction let permr_row #a #m r1 n = [@inline_let] let n0 = n in [@inline_let] let n1 = (n+.1ul)%.4ul in [@inline_let] let n2 = (n+.2ul)%.4ul in [@inline_let] let n3 = (n+.3ul)%.4ul in match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 -> let v0 : vec_t U32 4 = r1.(0ul) in let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | Spec.Blake2B,M256 -> let v0 : vec_t U64 4 = r1.(0ul) in let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | _ -> let h0 = ST.get() in let r1:lbuffer (Spec.word_t a) 4ul = r1 in let x0 = r1.(n0) in let x1 = r1.(n1) in let x2 = r1.(n2) in let x3 = r1.(n3) in r1.(0ul) <- x0; r1.(1ul) <- x1; r1.(2ul) <- x2; r1.(3ul) <- x3; let h1 = ST.get() in Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4]))); Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4])))); Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3)); () #pop-options #push-options "--z3rlimit 50" let create4_lemma #a x0 x1 x2 x3 = let open Lib.Sequence in let l : list a = [x0;x1;x2;x3] in assert_norm (List.Tot.length l = 4); let s1 : lseq a 4 = of_list l in let s2 : lseq a 4 = create4 x0 x1 x2 x3 in Seq.intro_of_list s2 l; eq_intro s1 s2 #pop-options noextract inline_for_extraction let alloc_row a m = create (row_len a m) (zero_element a m) noextract inline_for_extraction let create_row #a #m r w0 w1 w2 w3 = match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 | Spec.Blake2B,M256 -> r.(0ul) <- vec_load4 w0 w1 w2 w3 | _ -> r.(0ul) <- w0; r.(1ul) <- w1; r.(2ul) <- w2; r.(3ul) <- w3; let h1 = ST.get() in Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3) noextract inline_for_extraction let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul) noextract inline_for_extraction let store_row #a #m b r = match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 -> vec_store_le #U32 #4 b r.(0ul) | Spec.Blake2B,M256 -> vec_store_le #U64 #4 b r.(0ul) | _ -> uints_to_bytes_le #(Spec.wt a) 4ul b r noextract inline_for_extraction let store_row32 #a #m b r = push_frame(); let h0 = ST.get() in let b8 = create (size_row a) (u8 0) in store_row b8 r; let h1 = ST.get() in uints_from_bytes_le b b8; let h2 = ST.get() in assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r)); assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8)); Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b)); assert (Spec.load_row (as_seq h2 b) == Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8)); Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r); pop_frame() noextract inline_for_extraction let gather_row #a #ms r m i0 i1 i2 i3 = create_row r m.(i0) m.(i1) m.(i2) m.(i3) noextract inline_for_extraction let le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } = let open FStar.Mul in assert_norm ((4 * 1) % pow2 32 = 4); assert_norm ((4 * 4) % pow2 32 = 16); Lib.IntTypes.mul_mod_lemma 4ul 1ul; Lib.IntTypes.mul_mod_lemma 4ul 4ul; match a,m with | Spec.Blake2S,M128 -> 4ul | Spec.Blake2S,M256 -> 4ul | Spec.Blake2B,M256 -> 4ul | _ -> 16ul noextract inline_for_extraction let alloc_state a m = // See git blame below. I never managed to get the previous expression (4ul *. // row_len a m) to reduce, which generated VLAs in the C code. create (le_sigh a m) (zero_element a m) let copy_state #a #m st2 st1 = copy #_ #_ #(le_sigh a m) st2 st1 #push-options "--z3rlimit 100" let load_state_from_state32 #a #m st st32 = let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let b0 = rowi st32 0ul in let b1 = rowi st32 1ul in let b2 = rowi st32 2ul in let b3 = rowi st32 3ul in g_rowi_disjoint_other #_ #_ #(word_t a) st 0ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 0ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 1ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 1ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 2ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 2ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 3ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 3ul st; assert (disjoint r0 st32); assert (disjoint r0 b0); assert (disjoint r1 st32); assert (disjoint r1 b1); let h0 = ST.get() in load_row r0 b0; load_row r1 b1; load_row r2 b2; load_row r3 b3; let h1 = ST.get() in Lib.Sequence.eq_intro (as_seq h0 b0) (Spec.load_row #a (as_seq h0 b0)); Lib.Sequence.eq_intro (as_seq h0 b1) (Spec.load_row #a (as_seq h0 b1)); Lib.Sequence.eq_intro (as_seq h0 b2) (Spec.load_row #a (as_seq h0 b2)); Lib.Sequence.eq_intro (as_seq h0 b3) (Spec.load_row #a (as_seq h0 b3)); assert(row_v h0 b0 == Spec.load_row (as_seq h0 b0)); assert(row_v h1 r0 == row_v h0 b0); assert (state_v h1 st == state_v h0 st32) #pop-options
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Blake2.Core.fst" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Impl.Blake2.Core.store_state_st a m
Prims.Tot
[ "total" ]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.state_p", "Hacl.Impl.Blake2.Core.M32", "Prims._assert", "Prims.eq2", "Spec.Blake2.Definitions.state", "Hacl.Impl.Blake2.Core.state_v", "Prims.unit", "Lib.Sequence.eq_intro", "Hacl.Impl.Blake2.Core.element_t", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Blake2.Core.row_len", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Spec.Blake2.Definitions.load_row", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Blake2.Core.store_row32", "Lib.Buffer.disjoint", "Hacl.Impl.Blake2.Core.g_rowi_disjoint_other", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Blake2.Core.word_t", "Lib.Buffer.lbuffer_t", "Hacl.Impl.Blake2.Core.rowi", "Hacl.Impl.Blake2.Core.row_p" ]
[]
false
false
false
false
false
let store_state_to_state32 #a #m st32 st =
let r0 = rowi st 0ul in let r1 = rowi st 1ul in let r2 = rowi st 2ul in let r3 = rowi st 3ul in let b0 = rowi st32 0ul in let b1 = rowi st32 1ul in let b2 = rowi st32 2ul in let b3 = rowi st32 3ul in g_rowi_disjoint_other #_ #_ #(word_t a) st 0ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 0ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 1ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 1ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 2ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 2ul st; g_rowi_disjoint_other #_ #_ #(word_t a) st 3ul st32; g_rowi_disjoint_other #_ #_ #(element_t a m) st32 3ul st; assert (disjoint r0 b0); assert (disjoint r1 b1); assert (disjoint r2 b2); assert (disjoint r3 b3); let h0 = ST.get () in store_row32 b0 r0; store_row32 b1 r1; store_row32 b2 r2; store_row32 b3 r3; let h1 = ST.get () in Lib.Sequence.eq_intro (as_seq h1 b0) (Spec.load_row #a (as_seq h1 b0)); Lib.Sequence.eq_intro (as_seq h1 b1) (Spec.load_row #a (as_seq h1 b1)); Lib.Sequence.eq_intro (as_seq h1 b2) (Spec.load_row #a (as_seq h1 b2)); Lib.Sequence.eq_intro (as_seq h1 b3) (Spec.load_row #a (as_seq h1 b3)); assert (state_v h1 st32 == state_v h0 st)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_avx2
val cpu_has_avx2:cached_flag Vale.X64.CPU_Features_s.avx2_enabled
val cpu_has_avx2:cached_flag Vale.X64.CPU_Features_s.avx2_enabled
let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 32, "start_col": 0, "start_line": 31 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.avx2_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx2_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_avx2:cached_flag Vale.X64.CPU_Features_s.avx2_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_avx512
val cpu_has_avx512:cached_flag Vale.X64.CPU_Features_s.avx512_enabled
val cpu_has_avx512:cached_flag Vale.X64.CPU_Features_s.avx512_enabled
let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 46, "start_col": 0, "start_line": 45 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.avx512_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx512_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_avx512:cached_flag Vale.X64.CPU_Features_s.avx512_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_rdrand
val cpu_has_rdrand:cached_flag Vale.X64.CPU_Features_s.rdrand_enabled
val cpu_has_rdrand:cached_flag Vale.X64.CPU_Features_s.rdrand_enabled
let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 44, "start_col": 0, "start_line": 43 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.rdrand_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.rdrand_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_rdrand:cached_flag Vale.X64.CPU_Features_s.rdrand_enabled =
B.gcmalloc_of_list HS.root [false]
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extract_pulse_sig
val extract_pulse_sig (g: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either (uenv & iface) string)
val extract_pulse_sig (g: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either (uenv & iface) string)
let extract_pulse_sig (g:uenv) (selt:R.sigelt) (p:st_term) : T.Tac (either (uenv & iface) string) = let open T in try let sigelt_view = R.inspect_sigelt selt in match sigelt_view with | R.Sg_Let is_rec lbs -> if is_rec || List.length lbs <> 1 then T.raise (Extraction_failure "Extraction of iface for recursive lets is not yet supported") else let {lb_fv; lb_typ} = R.inspect_lb (List.Tot.hd lbs) in let g0 = g in let g = { uenv_inner=g; coreenv=initial_core_env g } in let g, tys, lb_typ, _ = generalize g lb_typ None in debug_ g (fun _ -> Printf.sprintf "Extracting ml typ: %s\n" (T.term_to_string lb_typ)); let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let g, _, e_bnd = extend_fv g0 lb_fv (tys, mlty) in Inl (g, iface_of_bindings [lb_fv, e_bnd]) | _ -> T.raise (Extraction_failure "Unexpected sigelt") with | Extraction_failure msg -> Inr msg | e -> Inr (Printf.sprintf "Unexpected extraction error (iface): %s" (RU.print_exn e))
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 83, "end_line": 870, "start_col": 0, "start_line": 847 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl let is_recursive (g:env) (knot_name:R.fv) (selt:R.sigelt) : T.Tac (option string) = let attrs = RU.get_attributes selt in let unpack_string (t:R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t:R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> ( let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_; _; (tag, _); (value, _)] -> ( match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None ) | _ -> None else None ) | _ -> None in find_map pulse_recursive_attr attrs let rec extract_recursive g (p:st_term) (rec_name:R.fv) : T.Tac (mlexpr & e_tag) = match p.term with | Tm_Abs { b; q; body } -> ( match body.term with | Tm_Abs _ -> let g, mlident, mlty, name = extend_env g b in let body = LN.open_st_term_nv body name in let body, _ = extract_recursive g body rec_name in let attrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let res = mle_fun [mlident, mlty, attrs] body in res, e_tag_pure | _ -> //last binder used for knot; replace it with the recursively bound name let body = LN.subst_st_term body [LN.DT 0 (tm_fstar R.(pack_ln (Tv_FVar rec_name)) Range.range_0)] in let body, tag = extract g body in body, tag ) | _ -> T.fail "Unexpected recursive definition of non-function" let extract_recursive_knot (g:env) (p:st_term) (knot_name:R.fv) (knot_typ:R.term) = let g, tys, lb_typ, Some p = generalize g knot_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let uenv, _mli, _ml_binding = extend_fv g.uenv_inner knot_name (tys, mlty) in let g = { g with uenv_inner = uenv } in let tm, tag = extract_recursive g p knot_name in let fv_name = let lids = R.inspect_fv knot_name in if Nil? lids then T.raise (Extraction_failure "Unexpected empty name"); FStar.List.Tot.last lids in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let mllb = mk_mllb fv_name (tys, mlty) tm in Inl [mlm_let true [mllb]] let extract_attrs (g:uenv) (se:R.sigelt) : T.Tac (list mlexpr) = se |> RU.get_attributes |> T.map (fun t -> let mlattr, _, _ = ECL.term_as_mlexpr g t in mlattr) let extract_pulse (uenv:uenv) (selt:R.sigelt) (p:st_term) : T.Tac (either mlmodule string) = let g = { uenv_inner=uenv; coreenv=initial_core_env uenv } in // T.print (Printf.sprintf "About to extract:\n%s\n" (st_term_to_string p)); debug g (fun _ -> Printf.sprintf "About to extract:\n%s\n" (st_term_to_string p)); let open T in try let sigelt_view = R.inspect_sigelt selt in match sigelt_view with | R.Sg_Let is_rec lbs -> ( if is_rec || List.length lbs <> 1 then T.raise (Extraction_failure "Extraction of recursive lets is not yet supported") else ( let {lb_fv; lb_typ} = R.inspect_lb (List.Tot.hd lbs) in match is_recursive g lb_fv selt with | Some _ -> extract_recursive_knot g p lb_fv lb_typ | _ -> let g, tys, lb_typ, Some p = generalize g lb_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let fv_name = R.inspect_fv lb_fv in if Nil? fv_name then T.raise (Extraction_failure "Unexpected empty name"); let p = erase_ghost_subterms g p in let p = simplify_st_term g p in let tm, tag = extract g p in let fv_name = FStar.List.Tot.last fv_name in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let attrs = extract_attrs uenv selt in let mllb = mk_mllb_with_attrs fv_name (tys, mlty) tm attrs in Inl [mlm_let_with_attrs false [mllb] attrs] ) ) | _ -> T.raise (Extraction_failure "Unexpected sigelt") with | Extraction_failure msg -> Inr msg | e -> Inr (Printf.sprintf "Unexpected extraction error: %s" (RU.print_exn e))
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.CompilerLib.uenv -> selt: FStar.Stubs.Reflection.Types.sigelt -> p: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either (Pulse.Extract.CompilerLib.uenv * Pulse.Extract.CompilerLib.iface) Prims.string)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.CompilerLib.uenv", "FStar.Stubs.Reflection.Types.sigelt", "Pulse.Syntax.Base.st_term", "FStar.Tactics.V2.Derived.try_with", "FStar.Pervasives.either", "FStar.Pervasives.Native.tuple2", "Pulse.Extract.CompilerLib.iface", "Prims.string", "Prims.unit", "Prims.bool", "Prims.list", "FStar.Stubs.Reflection.Types.letbinding", "Prims.op_BarBar", "Prims.op_disEquality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Tactics.Effect.raise", "Pulse.Extract.Main.Extraction_failure", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.Types.univ_name", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "Pulse.Extract.Main.env", "Pulse.Extract.CompilerLib.mlident", "FStar.Pervasives.Native.option", "Prims.l_iff", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.None", "Pulse.Extract.CompilerLib.exp_binding", "FStar.Pervasives.Inl", "FStar.Pervasives.Native.Mktuple2", "Pulse.Extract.CompilerLib.iface_of_bindings", "Prims.Cons", "Prims.Nil", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.CompilerLib.extend_fv", "Pulse.Extract.CompilerLib.mlty", "Pulse.Extract.CompilerLib.term_as_mlty", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Pulse.Extract.Main.debug_", "FStar.Printf.sprintf", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "FStar.Pervasives.Native.tuple4", "Pulse.Extract.Main.generalize", "Pulse.Extract.Main.Mkenv", "Pulse.Extract.CompilerLib.initial_core_env", "FStar.Stubs.Reflection.V2.Data.lb_view", "Prims.precedes", "FStar.List.Tot.Base.hd", "FStar.Stubs.Reflection.V2.Builtins.inspect_lb", "FStar.Stubs.Reflection.V2.Data.sigelt_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_sigelt", "Prims.exn", "FStar.Pervasives.Inr", "Pulse.RuntimeUtils.print_exn" ]
[]
false
true
false
false
false
let extract_pulse_sig (g: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either (uenv & iface) string) =
let open T in try let sigelt_view = R.inspect_sigelt selt in match sigelt_view with | R.Sg_Let is_rec lbs -> if is_rec || List.length lbs <> 1 then T.raise (Extraction_failure "Extraction of iface for recursive lets is not yet supported") else let { lb_fv = lb_fv ; lb_typ = lb_typ } = R.inspect_lb (List.Tot.hd lbs) in let g0 = g in let g = { uenv_inner = g; coreenv = initial_core_env g } in let g, tys, lb_typ, _ = generalize g lb_typ None in debug_ g (fun _ -> Printf.sprintf "Extracting ml typ: %s\n" (T.term_to_string lb_typ)); let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let g, _, e_bnd = extend_fv g0 lb_fv (tys, mlty) in Inl (g, iface_of_bindings [lb_fv, e_bnd]) | _ -> T.raise (Extraction_failure "Unexpected sigelt") with | Extraction_failure msg -> Inr msg | e -> Inr (Printf.sprintf "Unexpected extraction error (iface): %s" (RU.print_exn e))
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.erase_ghost_subterms_branch
val erase_ghost_subterms_branch (g: env) (b: branch) : T.Tac branch
val erase_ghost_subterms_branch (g: env) (b: branch) : T.Tac branch
let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 534, "start_col": 0, "start_line": 446 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> b: Pulse.Syntax.Base.branch -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.branch
FStar.Tactics.Effect.Tac
[]
[ "erase_ghost_subterms", "erase_ghost_subterms_branch" ]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.branch", "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.st_term", "Pulse.Extract.CompilerLib.mlpattern", "Prims.list", "Pulse.Typing.Env.binding", "FStar.Pervasives.Native.Mktuple2", "Pulse.Syntax.Naming.close_st_term_n", "FStar.List.Tot.Base.map", "Pulse.Syntax.Base.var", "FStar.Pervasives.Native.fst", "Pulse.Syntax.Base.typ", "Pulse.Extract.Main.erase_ghost_subterms", "Pulse.Checker.Match.open_st_term_bs", "FStar.Pervasives.Native.tuple3", "Pulse.Extract.Main.extend_env_pat" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec erase_ghost_subterms_branch (g: env) (b: branch) : T.Tac branch =
let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.cpu_has_movbe
val cpu_has_movbe:cached_flag Vale.X64.CPU_Features_s.movbe_enabled
val cpu_has_movbe:cached_flag Vale.X64.CPU_Features_s.movbe_enabled
let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 42, "start_col": 0, "start_line": 41 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled =
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.eternal_pointer (EverCrypt.AutoConfig2.flag Vale.X64.CPU_Features_s.movbe_enabled )
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.movbe_enabled", "FStar.Monotonic.HyperHeap.root", "Prims.Cons", "Prims.Nil", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable" ]
[]
false
false
false
true
false
let cpu_has_movbe:cached_flag Vale.X64.CPU_Features_s.movbe_enabled =
B.gcmalloc_of_list HS.root [false]
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init
val init: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init () = init_cpu_flags()
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 231, "start_col": 0, "start_line": 230 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "EverCrypt.AutoConfig2.init_cpu_flags" ]
[]
false
true
false
false
false
let init () =
init_cpu_flags ()
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.erase_ghost_subterms
val erase_ghost_subterms (g: env) (p: st_term) : T.Tac st_term
val erase_ghost_subterms (g: env) (p: st_term) : T.Tac st_term
let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs)
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 534, "start_col": 0, "start_line": 446 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> p: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term
FStar.Tactics.Effect.Tac
[]
[ "erase_ghost_subterms", "erase_ghost_subterms_branch" ]
[ "Pulse.Extract.Main.env", "Pulse.Syntax.Base.st_term", "Prims.bool", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.st_term'__Tm_IntroPure__payload", "Pulse.Syntax.Base.st_term'__Tm_ElimExists__payload", "Pulse.Syntax.Base.st_term'__Tm_IntroExists__payload", "Pulse.Syntax.Base.st_term'__Tm_Rewrite__payload", "Pulse.Syntax.Base.binder", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp_ascription", "Pulse.Syntax.Base.Tm_Abs", "Pulse.Syntax.Base.Mkst_term'__Tm_Abs__payload", "Pulse.Syntax.Base.st_term'__Tm_Return__payload", "Pulse.Syntax.Base.st_term'__Tm_STApp__payload", "Pulse.Extract.Main.erase_ghost_subterms", "Pulse.Syntax.Naming.subst_st_term", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Pulse.Extract.Main.unit_val", "Prims.Nil", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Extract.Main.is_erasable", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.Tm_TotBind", "Pulse.Syntax.Base.Mkst_term'__Tm_TotBind__payload", "Pulse.Extract.Main.erase_type_for_extraction", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Tm_If", "Pulse.Syntax.Base.Mkst_term'__Tm_If__payload", "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.Tm_Match", "Pulse.Syntax.Base.Mkst_term'__Tm_Match__payload", "FStar.Tactics.Util.map", "Pulse.Extract.Main.erase_ghost_subterms_branch", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.Tm_While", "Pulse.Syntax.Base.Mkst_term'__Tm_While__payload", "Pulse.Syntax.Base.Tm_Par", "Pulse.Syntax.Base.Mkst_term'__Tm_Par__payload", "Pulse.Syntax.Base.Tm_WithLocal", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocal__payload", "Pulse.Syntax.Base.Tm_WithLocalArray", "Pulse.Syntax.Base.Mkst_term'__Tm_WithLocalArray__payload", "Pulse.Syntax.Base.st_term'__Tm_Admit__payload", "Pulse.Syntax.Base.st_term'", "FStar.Tactics.V2.Derived.fail", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Pulse.Syntax.Base.Tm_Return", "Pulse.Syntax.Base.Mkst_term'__Tm_Return__payload", "Pulse.Syntax.Base.tm_unknown", "Pulse.Syntax.Naming.close_st_term'", "Pulse.Syntax.Naming.open_st_term'", "Pulse.Syntax.Pure.tm_var", "Pulse.Syntax.Base.Mknm", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "Pulse.Syntax.Base.var", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "Pulse.Typing.Env.dom", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "Pulse.Extract.Main.Mkenv", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Pulse.Typing.Env.push_binding", "Pulse.Typing.Env.fresh" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec erase_ghost_subterms (g: env) (p: st_term) : T.Tac st_term =
let open Pulse.Syntax.Naming in let fresh (g: env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g: env) (b: binder) (e: st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var ({ nm_index = x; nm_ppname = b.binder_ppname })) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return ({ expected_type = tm_unknown; insert_eq = false; term = unit_val }) } in let ret (t: st_term') = { p with term = t } in if is_erasable p then unit_tm else match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b = b ; q = q ; body = body ; ascription = ascription } -> let body = open_erase_close g b body in ret (Tm_Abs ({ b = b; q = q; body = body; ascription = ascription })) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder = binder ; head = head ; body = body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind ({ binder = binder; head = head; body = body })) | Tm_TotBind { binder = binder ; head = head ; body = body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind ({ binder = binder; head = head; body = body })) | Tm_If { b = b ; then_ = then_ ; else_ = else_ ; post = post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If ({ b = b; then_ = then_; else_ = else_; post = post })) | Tm_Match { sc = sc ; brs = brs ; returns_ = returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match ({ sc = sc; brs = brs; returns_ = returns_ })) | Tm_While { invariant = invariant ; condition = condition ; condition_var = condition_var ; body = body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While ({ invariant = invariant; condition = condition; condition_var = condition_var; body = body })) | Tm_Par { pre1 = pre1 ; body1 = body1 ; post1 = post1 ; pre2 = pre2 ; body2 = body2 ; post2 = post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par ({ pre1 = pre1; body1 = body1; post1 = post1; pre2 = pre2; body2 = body2; post2 = post2 })) | Tm_WithLocal { binder = binder ; initializer = initializer ; body = body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal ({ binder = binder; initializer = initializer; body = body })) | Tm_WithLocalArray { binder = binder ; initializer = initializer ; length = length ; body = body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray ({ binder = binder; initializer = initializer; length = length; body = body })) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms"
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.mk_getter
val mk_getter (#b: _) (f: cached_flag b) : getter b
val mk_getter (#b: _) (f: cached_flag b) : getter b
let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 51, "start_col": 0, "start_line": 49 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ]
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: EverCrypt.AutoConfig2.cached_flag b -> EverCrypt.AutoConfig2.getter b
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "EverCrypt.AutoConfig2.cached_flag", "Prims.unit", "LowStar.Monotonic.Buffer.index", "EverCrypt.AutoConfig2.flag", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "EverCrypt.AutoConfig2.getter" ]
[]
false
false
false
false
false
let mk_getter #b (f: cached_flag b) : getter b =
fun () -> B.recall f; B.index f 0ul
false
Hacl.Impl.Blake2.Core.fst
Hacl.Impl.Blake2.Core.permr_row
val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) )))
val permr_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> n:index_t -> Stack unit (requires (fun h -> live h r1)) (ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\ row_v h1 r1 == Spec.( rotr (row_v h0 r1) (v n) )))
let permr_row #a #m r1 n = [@inline_let] let n0 = n in [@inline_let] let n1 = (n+.1ul)%.4ul in [@inline_let] let n2 = (n+.2ul)%.4ul in [@inline_let] let n3 = (n+.3ul)%.4ul in match a,m with | Spec.Blake2S,M256 | Spec.Blake2S,M128 -> let v0 : vec_t U32 4 = r1.(0ul) in let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | Spec.Blake2B,M256 -> let v0 : vec_t U64 4 = r1.(0ul) in let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4])))); r1.(0ul) <- v1 | _ -> let h0 = ST.get() in let r1:lbuffer (Spec.word_t a) 4ul = r1 in let x0 = r1.(n0) in let x1 = r1.(n1) in let x2 = r1.(n2) in let x3 = r1.(n3) in r1.(0ul) <- x0; r1.(1ul) <- x1; r1.(2ul) <- x2; r1.(3ul) <- x3; let h1 = ST.get() in Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4]))); Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4])))); Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3)); ()
{ "file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 217, "start_col": 0, "start_line": 179 }
module Hacl.Impl.Blake2.Core module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Spec.Blake2 #set-options "--max_fuel 0 --max_ifuel 1" noextract inline_for_extraction let zero_element (a:Spec.alg) (m:m_spec) : element_t a m = match a,m with | Spec.Blake2S,M128 -> (vec_zero U32 4) | Spec.Blake2S,M256 -> (vec_zero U32 4) | Spec.Blake2B,M256 -> (vec_zero U64 4) | _ -> Spec.zero a noextract inline_for_extraction let row_v #a #m h r = match a,m with | Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0) | _ -> as_seq h r let row_v_lemma #a #m h0 h1 r1 r2 = () let create_default_params a salt personal = match a with | Spec.Blake2S -> { digest_length = u8 32; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u16 0; node_depth = u8 0; inner_length = u8 0; salt; personal } <: blake2s_params | Spec.Blake2B -> { digest_length = u8 64; key_length = u8 0; fanout = u8 1; depth = u8 1; leaf_length = u32 0; node_offset = u32 0; xof_length = u32 0; node_depth = u8 0; inner_length = u8 0; salt; personal } #push-options "--z3rlimit 50" let g_rowi_disjoint #a #m st idx1 idx2 = if idx1 <. idx2 then ( assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m)); assert (g_rowi st idx1 == gsub st (idx1 *. row_len a m) (row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) ) else if idx2 <. idx1 then ( assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m)); assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m)); LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))) else () let g_rowi_unchanged #a #m h0 h1 st i = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) let g_rowi_disjoint_other #a #m #b st i x = assert (v (i *. row_len a m) + v (row_len a m) <= length st); LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) #pop-options inline_for_extraction noextract let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) = let r0 = row_v h (g_rowi st 0ul) in let r1 = row_v h (g_rowi st 1ul) in let r2 = row_v h (g_rowi st 2ul) in let r3 = row_v h (g_rowi st 3ul) in Lib.Sequence.create4 r0 r1 r2 r3 #push-options "--z3rlimit 100" let state_v_eq_lemma #a #m h0 h1 st1 st2 = assert (v (0ul *. row_len a m) == 0); LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)); assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m))); assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m))); assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m))); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul)); Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul)); row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul); Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) #pop-options let state_v_rowi_lemma #a #m h st i = () let state_v_live_rowi_lemma #a #m h st i = () #push-options "--z3rlimit 50" let modifies_one_row a m h0 h1 st i j = let ri = g_rowi st i in let rj = g_rowi st j in assert (live h0 ri); assert (live h0 rj); assert (modifies (loc ri) h0 h1); assert (disjoint rj ri); assert (as_seq h1 rj == as_seq h0 rj) let modifies_row_state a m h0 h1 st i = Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i))) #pop-options noextract inline_for_extraction let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) = sub st (idx *. row_len a m) (row_len a m) noextract inline_for_extraction let xor_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 noextract inline_for_extraction let add_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2S,M256 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul) | Spec.Blake2B,M256 -> r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul) | _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2 #push-options "--z3rlimit 200" noextract inline_for_extraction let ror_row #a #m r1 r2 = match a,m with | Spec.Blake2S,M128 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2S,M256 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2 | Spec.Blake2B,M256 -> r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2 | _ -> let r1:lbuffer (Spec.word_t a) 4ul = r1 in mapT 4ul r1 (rotate_right_i r2) r1 #pop-options #push-options "--z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Blake2.Core.fst" }
[ { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r1: Hacl.Impl.Blake2.Core.row_p a m -> n: Hacl.Impl.Blake2.Core.index_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Spec.Blake2.Definitions.alg", "Hacl.Impl.Blake2.Core.m_spec", "Hacl.Impl.Blake2.Core.row_p", "Hacl.Impl.Blake2.Core.index_t", "FStar.Pervasives.Native.Mktuple2", "Lib.Buffer.op_Array_Assignment", "Hacl.Impl.Blake2.Core.element_t", "Hacl.Impl.Blake2.Core.row_len", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.Sequence.eq_intro", "Spec.Blake2.Definitions.word_t", "Spec.Blake2.Definitions.Blake2S", "Spec.Blake2.Definitions.rotr", "Lib.IntVector.vec_v", "Lib.IntTypes.U32", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.Sequence.createi", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.op_String_Access", "Prims.op_Modulus", "Prims.op_Addition", "Lib.Sequence.create4", "Lib.IntVector.vec_t", "Lib.IntVector.vec_rotate_right_lanes", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Spec.Blake2.Definitions.Blake2B", "Lib.IntTypes.U64", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Spec.Blake2.Definitions.wt", "FStar.UInt32.uint_to_t", "Lib.Buffer.as_seq", "Lib.Sequence.lseq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "FStar.UInt32.t", "Lib.IntTypes.op_Percent_Dot", "Lib.IntTypes.op_Plus_Dot" ]
[]
false
true
false
false
false
let permr_row #a #m r1 n =
[@@ inline_let ]let n0 = n in [@@ inline_let ]let n1 = (n +. 1ul) %. 4ul in [@@ inline_let ]let n2 = (n +. 2ul) %. 4ul in [@@ inline_let ]let n3 = (n +. 3ul) %. 4ul in match a, m with | Spec.Blake2S, M256 | Spec.Blake2S, M128 -> let v0:vec_t U32 4 = r1.(0ul) in let v1:vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in (let open Lib.Sequence in eq_intro (create4 (vec_v v0).[ v n0 ] (vec_v v0).[ v n1 ] (vec_v v0).[ v n2 ] (vec_v v0).[ v n3 ]) (let open Lib.Sequence in createi 4 (fun i -> (vec_v v0).[ (i + v n) % 4 ]))); (let open Lib.Sequence in eq_intro (Spec.rotr (vec_v v0) (v n)) (let open Lib.Sequence in createi 4 (fun i -> (vec_v v0).[ (i + v n) % 4 ]))); r1.(0ul) <- v1 | Spec.Blake2B, M256 -> let v0:vec_t U64 4 = r1.(0ul) in let v1:vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in (let open Lib.Sequence in eq_intro (create4 (vec_v v0).[ v n0 ] (vec_v v0).[ v n1 ] (vec_v v0).[ v n2 ] (vec_v v0).[ v n3 ]) (let open Lib.Sequence in createi 4 (fun i -> (vec_v v0).[ (i + v n) % 4 ]))); (let open Lib.Sequence in eq_intro (Spec.rotr (vec_v v0) (v n)) (let open Lib.Sequence in createi 4 (fun i -> (vec_v v0).[ (i + v n) % 4 ]))); r1.(0ul) <- v1 | _ -> let h0 = ST.get () in let r1:lbuffer (Spec.word_t a) 4ul = r1 in let x0 = r1.(n0) in let x1 = r1.(n1) in let x2 = r1.(n2) in let x3 = r1.(n3) in r1.(0ul) <- x0; r1.(1ul) <- x1; r1.(2ul) <- x2; r1.(3ul) <- x3; let h1 = ST.get () in (let open Lib.Sequence in let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[ (i + v n) % 4 ]))); (let open Lib.Sequence in let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (let open Lib.Sequence in createi 4 (fun i -> s0.[ (i + v n) % 4 ]))); (let open Lib.Sequence in eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3)); ()
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_rdrand_flags
val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 193, "start_col": 0, "start_line": 189 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.rdrand_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_rdrand", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_rdrand" ]
[]
false
true
false
false
false
let init_rdrand_flags () =
if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0uL then (B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_shaext_flags
val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 115, "start_col": 0, "start_line": 111 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sha_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_shaext", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_sha" ]
[]
false
true
false
false
false
let init_shaext_flags () =
if Vale.Wrapper.X64.Cpuid.check_sha () <> 0uL then (B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true)
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.extract_pulse
val extract_pulse (uenv: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either mlmodule string)
val extract_pulse (uenv: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either mlmodule string)
let extract_pulse (uenv:uenv) (selt:R.sigelt) (p:st_term) : T.Tac (either mlmodule string) = let g = { uenv_inner=uenv; coreenv=initial_core_env uenv } in // T.print (Printf.sprintf "About to extract:\n%s\n" (st_term_to_string p)); debug g (fun _ -> Printf.sprintf "About to extract:\n%s\n" (st_term_to_string p)); let open T in try let sigelt_view = R.inspect_sigelt selt in match sigelt_view with | R.Sg_Let is_rec lbs -> ( if is_rec || List.length lbs <> 1 then T.raise (Extraction_failure "Extraction of recursive lets is not yet supported") else ( let {lb_fv; lb_typ} = R.inspect_lb (List.Tot.hd lbs) in match is_recursive g lb_fv selt with | Some _ -> extract_recursive_knot g p lb_fv lb_typ | _ -> let g, tys, lb_typ, Some p = generalize g lb_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let fv_name = R.inspect_fv lb_fv in if Nil? fv_name then T.raise (Extraction_failure "Unexpected empty name"); let p = erase_ghost_subterms g p in let p = simplify_st_term g p in let tm, tag = extract g p in let fv_name = FStar.List.Tot.last fv_name in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let attrs = extract_attrs uenv selt in let mllb = mk_mllb_with_attrs fv_name (tys, mlty) tm attrs in Inl [mlm_let_with_attrs false [mllb] attrs] ) ) | _ -> T.raise (Extraction_failure "Unexpected sigelt") with | Extraction_failure msg -> Inr msg | e -> Inr (Printf.sprintf "Unexpected extraction error: %s" (RU.print_exn e))
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 75, "end_line": 845, "start_col": 0, "start_line": 806 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e let debug_ = debug let rec find_map (f: 'a -> option 'b) (l:list 'a) : option 'b = match l with | [] -> None | hd::tl -> let x = f hd in if Some? x then x else find_map f tl let is_recursive (g:env) (knot_name:R.fv) (selt:R.sigelt) : T.Tac (option string) = let attrs = RU.get_attributes selt in let unpack_string (t:R.term) : option string = match R.inspect_ln t with | R.Tv_Const (R.C_String s) -> Some s | _ -> None in let pulse_recursive_attr (t:R.term) : option string = match R.inspect_ln t with | R.Tv_App _ _ -> ( let hd, args = T.collect_app_ln t in if T.is_fvar hd (`%Mktuple2) then match args with | [_; _; (tag, _); (value, _)] -> ( match unpack_string tag, unpack_string value with | Some "pulse.recursive.knot", Some v -> Some v | _ -> None ) | _ -> None else None ) | _ -> None in find_map pulse_recursive_attr attrs let rec extract_recursive g (p:st_term) (rec_name:R.fv) : T.Tac (mlexpr & e_tag) = match p.term with | Tm_Abs { b; q; body } -> ( match body.term with | Tm_Abs _ -> let g, mlident, mlty, name = extend_env g b in let body = LN.open_st_term_nv body name in let body, _ = extract_recursive g body rec_name in let attrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let res = mle_fun [mlident, mlty, attrs] body in res, e_tag_pure | _ -> //last binder used for knot; replace it with the recursively bound name let body = LN.subst_st_term body [LN.DT 0 (tm_fstar R.(pack_ln (Tv_FVar rec_name)) Range.range_0)] in let body, tag = extract g body in body, tag ) | _ -> T.fail "Unexpected recursive definition of non-function" let extract_recursive_knot (g:env) (p:st_term) (knot_name:R.fv) (knot_typ:R.term) = let g, tys, lb_typ, Some p = generalize g knot_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let uenv, _mli, _ml_binding = extend_fv g.uenv_inner knot_name (tys, mlty) in let g = { g with uenv_inner = uenv } in let tm, tag = extract_recursive g p knot_name in let fv_name = let lids = R.inspect_fv knot_name in if Nil? lids then T.raise (Extraction_failure "Unexpected empty name"); FStar.List.Tot.last lids in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let mllb = mk_mllb fv_name (tys, mlty) tm in Inl [mlm_let true [mllb]] let extract_attrs (g:uenv) (se:R.sigelt) : T.Tac (list mlexpr) = se |> RU.get_attributes |> T.map (fun t -> let mlattr, _, _ = ECL.term_as_mlexpr g t in mlattr)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
uenv: Pulse.Extract.CompilerLib.uenv -> selt: FStar.Stubs.Reflection.Types.sigelt -> p: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either Pulse.Extract.CompilerLib.mlmodule Prims.string)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.CompilerLib.uenv", "FStar.Stubs.Reflection.Types.sigelt", "Pulse.Syntax.Base.st_term", "FStar.Tactics.V2.Derived.try_with", "FStar.Pervasives.either", "Prims.list", "Pulse.Extract.CompilerLib.mlmodule1", "Prims.string", "Prims.unit", "Prims.bool", "FStar.Stubs.Reflection.Types.letbinding", "Prims.op_BarBar", "Prims.op_disEquality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Tactics.Effect.raise", "Pulse.Extract.Main.Extraction_failure", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.Types.univ_name", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "Pulse.Extract.Main.extract_recursive_knot", "FStar.Pervasives.Native.option", "Pulse.Extract.Main.env", "Pulse.Extract.CompilerLib.mlident", "Pulse.Extract.CompilerLib.mlexpr", "Pulse.Extract.CompilerLib.e_tag", "FStar.Pervasives.Inl", "Prims.Cons", "Pulse.Extract.CompilerLib.mlm_let_with_attrs", "Pulse.Extract.CompilerLib.mllb", "Prims.Nil", "Pulse.Extract.CompilerLib.mk_mllb_with_attrs", "FStar.Pervasives.Native.Mktuple2", "Pulse.Extract.CompilerLib.mlty", "Pulse.Extract.Main.extract_attrs", "Pulse.Extract.Main.debug_", "FStar.Printf.sprintf", "Pulse.Extract.CompilerLib.mlexpr_to_string", "FStar.List.Tot.Base.last", "FStar.Pervasives.Native.tuple2", "Pulse.Extract.Main.extract", "Pulse.Extract.Main.simplify_st_term", "Pulse.Extract.Main.erase_ghost_subterms", "Prims.uu___is_Nil", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "Pulse.Extract.CompilerLib.term_as_mlty", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "FStar.Pervasives.Native.tuple4", "Prims.l_iff", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.Some", "Pulse.Extract.Main.generalize", "Pulse.Extract.Main.is_recursive", "FStar.Stubs.Reflection.V2.Data.lb_view", "Prims.precedes", "FStar.List.Tot.Base.hd", "FStar.Stubs.Reflection.V2.Builtins.inspect_lb", "FStar.Stubs.Reflection.V2.Data.sigelt_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_sigelt", "Prims.exn", "FStar.Pervasives.Inr", "Pulse.RuntimeUtils.print_exn", "Pulse.Extract.Main.debug", "Pulse.Syntax.Printer.st_term_to_string", "Pulse.Extract.CompilerLib.mlmodule", "Pulse.Extract.Main.Mkenv", "Pulse.Extract.CompilerLib.initial_core_env" ]
[]
false
true
false
false
false
let extract_pulse (uenv: uenv) (selt: R.sigelt) (p: st_term) : T.Tac (either mlmodule string) =
let g = { uenv_inner = uenv; coreenv = initial_core_env uenv } in debug g (fun _ -> Printf.sprintf "About to extract:\n%s\n" (st_term_to_string p)); let open T in try let sigelt_view = R.inspect_sigelt selt in match sigelt_view with | R.Sg_Let is_rec lbs -> (if is_rec || List.length lbs <> 1 then T.raise (Extraction_failure "Extraction of recursive lets is not yet supported") else (let { lb_fv = lb_fv ; lb_typ = lb_typ } = R.inspect_lb (List.Tot.hd lbs) in match is_recursive g lb_fv selt with | Some _ -> extract_recursive_knot g p lb_fv lb_typ | _ -> let g, tys, lb_typ, Some p = generalize g lb_typ (Some p) in let mlty = ECL.term_as_mlty g.uenv_inner lb_typ in let fv_name = R.inspect_fv lb_fv in if Nil? fv_name then T.raise (Extraction_failure "Unexpected empty name"); let p = erase_ghost_subterms g p in let p = simplify_st_term g p in let tm, tag = extract g p in let fv_name = FStar.List.Tot.last fv_name in debug_ g (fun _ -> Printf.sprintf "Extracted term (%s): %s\n" fv_name (mlexpr_to_string tm)); let attrs = extract_attrs uenv selt in let mllb = mk_mllb_with_attrs fv_name (tys, mlty) tm attrs in Inl [mlm_let_with_attrs false [mllb] attrs])) | _ -> T.raise (Extraction_failure "Unexpected sigelt") with | Extraction_failure msg -> Inr msg | e -> Inr (Printf.sprintf "Unexpected extraction error: %s" (RU.print_exn e))
false
Vale.Stdcalls.X64.Fadd.fsti
Vale.Stdcalls.X64.Fadd.fadd_lemma'
val fadd_lemma' (code: V.va_code) (_win: bool) (out f1 f2: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
val fadd_lemma' (code: V.va_code) (_win: bool) (out f1 f2: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
let fadd_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FH.va_lemma_Fadd_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2; (va_s1, f)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 184, "start_col": 0, "start_line": 157 }
module Vale.Stdcalls.X64.Fadd val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] noextract let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #reset-options "--z3rlimit 50" [@__reduce__] noextract let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ add1_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1); (va_s1, f) (* Prove that add1_lemma' has the required type *) noextract let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' noextract let code_add1 = FU.va_code_Fast_add1_stdcall IA.win (* Here's the type expected for the add1 wrapper *) [@__reduce__] noextract let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) [@__reduce__] noextract let fadd_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] noextract let fadd_post : VSig.vale_post fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FH.va_ens_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 100"
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fadd.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
code: Vale.X64.Decls.va_code -> _win: Prims.bool -> out: Vale.Stdcalls.X64.Fadd.b64 -> f1: Vale.Stdcalls.X64.Fadd.b64 -> f2: Vale.Stdcalls.X64.Fadd.b64 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Stdcalls.X64.Fadd.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.Curve25519.X64.FastHybrid.va_lemma_Fadd_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Stdcalls.X64.Fadd.fadd_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall", "Vale.Stdcalls.X64.Fadd.fadd_post", "Vale.X64.Memory.buffer_readable", "Vale.X64.State.vs_get_vale_heap", "Vale.X64.Memory.buffer_writeable", "Vale.X64.Memory.modifies", "Vale.X64.Memory.loc_union", "Vale.X64.Memory.loc_buffer", "Vale.X64.Memory.loc_none" ]
[]
false
false
false
false
false
let fadd_lemma' (code: V.va_code) (_win: bool) (out f1 f2: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fadd_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fadd_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1))) =
let va_s1, f = FH.va_lemma_Fadd_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2; (va_s1, f)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_sse_flags
val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 169, "start_col": 0, "start_line": 165 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sse_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_sse", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_sse" ]
[]
false
true
false
false
false
let init_sse_flags () =
if Vale.Wrapper.X64.Cpuid.check_sse () <> 0uL then (B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_movbe_flags
val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 181, "start_col": 0, "start_line": 177 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.movbe_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_movbe", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_movbe" ]
[]
false
true
false
false
false
let init_movbe_flags () =
if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0uL then (B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_aesni_flags
val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 103, "start_col": 0, "start_line": 97 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_pclmulqdq", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Vale.X64.CPU_Features_s.aesni_enabled", "EverCrypt.AutoConfig2.cpu_has_aesni", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_aesni" ]
[]
false
true
false
false
false
let init_aesni_flags () =
if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0uL then (B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.disable_avx
val disable_avx: disabler
val disable_avx: disabler
let disable_avx () = B.recall cpu_has_avx; B.upd cpu_has_avx 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 240, "start_col": 0, "start_line": 240 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags() inline_for_extraction noextract let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false /// FIXME use mk_disabler
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall" ]
[]
false
false
false
true
false
let disable_avx () =
B.recall cpu_has_avx; B.upd cpu_has_avx 0ul false
false
Hacl.K256.Scalar.fsti
Hacl.K256.Scalar.qnlimb
val qnlimb : FStar.UInt32.t
let qnlimb = 4ul
{ "file_name": "code/k256/Hacl.K256.Scalar.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 23, "start_col": 0, "start_line": 23 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence module S = Spec.K256 module SG = Hacl.Spec.K256.GLV module BD = Hacl.Bignum.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.K256.Scalar.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.UInt32.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let qnlimb =
4ul
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_avx512_flags
val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 208, "start_col": 0, "start_line": 201 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx512_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx512", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_avx512_xcr0", "Vale.Wrapper.X64.Cpuid.check_avx_xcr0", "Vale.Wrapper.X64.Cpuid.check_osxsave", "Vale.Wrapper.X64.Cpuid.check_avx512" ]
[]
false
true
false
false
false
let init_avx512_flags () =
if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0uL then (B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_avx2_flags
val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 143, "start_col": 0, "start_line": 137 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx2_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx2", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_avx_xcr0", "Vale.Wrapper.X64.Cpuid.check_osxsave", "Vale.Wrapper.X64.Cpuid.check_avx2" ]
[]
false
true
false
false
false
let init_avx2_flags () =
if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0uL then (B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.recall
val recall: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.(loc_not_unused_in h1 `loc_includes` (fp ())) /\ h0 == h1))
val recall: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.(loc_not_unused_in h1 `loc_includes` (fp ())) /\ h0 == h1))
let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 89, "start_col": 0, "start_line": 78 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.recall", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx512_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx512", "Vale.X64.CPU_Features_s.rdrand_enabled", "EverCrypt.AutoConfig2.cpu_has_rdrand", "Vale.X64.CPU_Features_s.movbe_enabled", "EverCrypt.AutoConfig2.cpu_has_movbe", "Vale.X64.CPU_Features_s.sse_enabled", "EverCrypt.AutoConfig2.cpu_has_sse", "Vale.X64.CPU_Features_s.adx_enabled", "EverCrypt.AutoConfig2.cpu_has_adx", "Vale.X64.CPU_Features_s.bmi2_enabled", "EverCrypt.AutoConfig2.cpu_has_bmi2", "Vale.X64.CPU_Features_s.avx_enabled", "EverCrypt.AutoConfig2.cpu_has_avx", "Vale.X64.CPU_Features_s.avx2_enabled", "EverCrypt.AutoConfig2.cpu_has_avx2", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "EverCrypt.AutoConfig2.cpu_has_pclmulqdq", "Vale.X64.CPU_Features_s.aesni_enabled", "EverCrypt.AutoConfig2.cpu_has_aesni", "Vale.X64.CPU_Features_s.sha_enabled", "EverCrypt.AutoConfig2.cpu_has_shaext" ]
[]
false
true
false
false
false
let recall () =
B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.mk_disabler
val mk_disabler (f: eternal_pointer bool {B.loc_includes (fp ()) (B.loc_buffer f)}) : disabler
val mk_disabler (f: eternal_pointer bool {B.loc_includes (fp ()) (B.loc_buffer f)}) : disabler
let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 236, "start_col": 0, "start_line": 234 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags()
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: EverCrypt.AutoConfig2.eternal_pointer Prims.bool { LowStar.Monotonic.Buffer.loc_includes (EverCrypt.AutoConfig2.fp ()) (LowStar.Monotonic.Buffer.loc_buffer f) } -> EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.AutoConfig2.eternal_pointer", "Prims.bool", "LowStar.Monotonic.Buffer.loc_includes", "EverCrypt.AutoConfig2.fp", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.trivial_preorder", "Prims.unit", "LowStar.Monotonic.Buffer.upd", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "EverCrypt.AutoConfig2.disabler" ]
[]
false
false
false
false
false
let mk_disabler (f: eternal_pointer bool {B.loc_includes (fp ()) (B.loc_buffer f)}) : disabler =
fun () -> B.recall f; B.upd f 0ul false
false
Pulse.Extract.Main.fst
Pulse.Extract.Main.generalize
val generalize (g: env) (t: R.typ) (e: option st_term) : T.Tac (env & list mlident & R.typ & o: option st_term {Some? e <==> Some? o})
val generalize (g: env) (t: R.typ) (e: option st_term) : T.Tac (env & list mlident & R.typ & o: option st_term {Some? e <==> Some? o})
let rec generalize (g:env) (t:R.typ) (e:option st_term) : T.Tac (env & list mlident & R.typ & o:option st_term { Some? e <==> Some? o}) = debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let {sort; ppname} = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = R.(pack_ln (Tv_Var (pack_namedv {uniq = x; sort = RT.sort_default; ppname}))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some {term=Tm_Abs {b; body}} -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv { uniq = x; sort = FStar.Sealed.seal sort; ppname } in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv)::tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e
{ "file_name": "lib/steel/pulse/Pulse.Extract.Main.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 727, "start_col": 0, "start_line": 684 }
(* Copyright 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 Pulse.Extract.Main open Pulse.Syntax.Base open Pulse.Syntax.Pure open Pulse.Extract.CompilerLib open Pulse.Syntax.Printer open FStar.List.Tot module L = FStar.List.Tot module R = FStar.Reflection module RT = FStar.Reflection.Typing module T = FStar.Tactics.V2 module RB = Pulse.Readback module Elab = Pulse.Elaborate.Pure module E = Pulse.Typing.Env module LN = Pulse.Syntax.Naming module RU = Pulse.RuntimeUtils module ECL = Pulse.Extract.CompilerLib exception Extraction_failure of string noeq type env = { uenv_inner: uenv; coreenv: Pulse.Typing.Env.env } let name = ppname & nat let topenv_of_env (g:env) = E.fstar_env g.coreenv let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f()) let term_as_mlexpr (g:env) (t:term) : T.Tac mlexpr = let t = Elab.elab_term t in let uenv = uenv_of_env g in let t = normalize_for_extraction uenv t in let mlt, _, _ = term_as_mlexpr uenv t in mlt let term_as_mlty (g:env) (t:term) : T.Tac mlty = let t = Elab.elab_term t in term_as_mlty (uenv_of_env g) t let extend_env (g:env) (b:binder) : T.Tac (env & mlident & mlty & name) = let mlty = term_as_mlty g b.binder_ty in let x = E.fresh g.coreenv in let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n" (binder_to_string b) (term_to_string b.binder_ty)); let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in { uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x) let rec name_as_mlpath (x:T.name) : T.Tac mlpath = match x with | [] -> T.fail "Unexpected empty name" | [x] -> [], x | x :: xs -> let xs, x = name_as_mlpath xs in x :: xs, x module R = FStar.Reflection.V2 let extract_constant (g:env) (c:T.vconst) : T.Tac mlconstant = let e = T.pack_ln (R.Tv_Const c) in let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in match mlconstant_of_mlexpr mle with | None -> T.raise (Extraction_failure "Failed to extract constant") | Some c -> c let rec extend_env_pat_core (g:env) (p:pattern) : T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding) = match p with | Pat_Dot_Term _ -> g, [], [] | Pat_Var pp sort -> let x = E.fresh g.coreenv in let pp = mk_ppname pp FStar.Range.range_0 in let ty = T.unseal sort in assume (not_tv_unknown ty); let ty = tm_fstar ty (T.range_of_term ty) in debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty)); let coreenv = E.push_binding g.coreenv x pp ty in let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in { uenv_inner; coreenv }, [ mlp_var mlident ], [ (x, tm_unknown) ] | Pat_Cons f pats -> let g, pats, bindings = T.fold_left (fun (g, pats, bindings) (p, _) -> let g, pats', bindings' = extend_env_pat_core g p in g, pats @ pats', bindings@bindings') (g, [], []) pats in g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings | Pat_Constant c -> let c = extract_constant g c in g, [mlp_const c], [] let extend_env_pat g p = let g, pats, bs = extend_env_pat_core g p in match pats with | [p] -> g, p, bs | _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0 let is_erasable (p:st_term) : T.Tac bool = let tag = T.unseal p.effect_tag in match tag with | Some STT_Ghost -> true | _ -> false let head_and_args (t:term) : option (R.term & list R.argv) = match t.t with | Tm_FStar t0 -> Some (R.collect_app_ln t0) | _ -> None let term_eq_string (s:string) (t:R.term) : bool = match R.inspect_ln t with | R.Tv_Const (R.C_String s') -> s=s' | _ -> false let maybe_unfold_head (g:env) (head:R.term) : T.Tac (option (either st_term R.term)) = debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head)); match R.inspect_ln head with | R.Tv_FVar f -> ( let name = R.inspect_fv f in match R.lookup_typ (topenv_of_env g) name with | None -> None | Some se -> let attrs = R.sigelt_attrs se in let quals = R.sigelt_quals se in if List.Tot.existsb (term_eq_string "inline") attrs || List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals then match sigelt_extension_data se with | Some se -> debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head)); debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se)); Some (Inl se) | None -> ( match T.inspect_sigelt se with | T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } -> Some (Inr lb_def) | _ -> None ) else None ) | R.Tv_UInst f _ -> //No universe-polymorphic inlining ... yet None | _ -> None let rec st_term_abs_take_n_args (n_args:nat) (t:st_term) : res:(st_term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match t.term with | Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let rec term_abs_take_n_args (n_args:nat) (t:R.term) : res:(R.term & nat){snd res <= n_args} = if n_args = 0 then t, 0 else ( match R.inspect_ln t with | R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body | _ -> (t, n_args) ) let abs_take_n_args (n_args:nat) (t:either st_term R.term) : T.Tac (res:(either st_term R.term & nat){snd res <= n_args}) = match t with | Inl t -> let t, n_args = st_term_abs_take_n_args n_args t in Inl t, n_args | Inr t -> let t, n_args = term_abs_take_n_args n_args t in Inr t, n_args let rec unascribe (t:R.term) : T.Tac R.term = match R.inspect_ln t with | R.Tv_AscribedT e _ _ _ -> unascribe e | R.Tv_AscribedC e _ _ _ -> unascribe e | _ -> t let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) = debug g (fun _ -> Printf.sprintf "Considering inlining %s\n" (term_to_string head)); match head_and_args head with | None -> None | Some (head, args) -> debug g (fun _ -> Printf.sprintf "head=%s with %d args\n" (T.term_to_string head) (List.length args)); match maybe_unfold_head g head with | None -> debug g (fun _ -> Printf.sprintf "No unfolding of %s\n" (T.term_to_string head)); None | Some def -> // debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n" // (T.term_to_string head) // (st_term_to_string body)); let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in let all_args : list (term & option qualifier) = L.map #R.argv (fun (t, q) -> let t = as_term t in let qual = if R.Q_Implicit? q then Some Implicit else None in t, qual) args @ [arg, None] in let n_args = L.length all_args in let body, remaining_args = abs_take_n_args n_args def in let args, rest = L.splitAt (n_args - remaining_args) all_args in let _, subst = L.fold_right (fun arg (i, subst) -> i + 1, LN.DT i (fst arg)::subst) args (0, []) in match body with | Inl body -> ( let applied_body = LN.subst_st_term body subst in match rest with | [] -> Some applied_body | _ -> T.fail (Printf.sprintf "Partial or over application of inlined Pulse definition is not yet supported\n\ %s has %d arguments, but %s were left unapplied" (T.term_to_string head) (L.length args) (String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest)) ) ) | Inr body -> assume (not_tv_unknown body); let applied_body = unascribe (LN.subst_host_term body subst) in let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) = assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in let tm = Tm_STApp { head; arg_qual; arg } in Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint } in match rest with | [] -> ( match R.inspect_ln applied_body with | R.Tv_App head (arg, aqual) -> assume (not_tv_unknown arg); let arg = tm_fstar arg (T.range_of_term arg) in let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in mk_st_app head arg arg_qual | _ -> T.fail (Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s" (T.term_to_string applied_body)) ) | rest -> FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest; let rest, [last] = L.splitAt (L.length rest - 1) rest in let head = L.fold_left (fun head (tm, qual) -> R.pack_ln ( R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit)) )) applied_body rest in mk_st_app head (fst last) (snd last) let fresh (g:env) = Pulse.Typing.fresh g.coreenv let push_binding (g:env) (x:var { ~ (x `Set.mem` E.dom g.coreenv )}) (b:binder) = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } let with_open (g:env) (b:binder) (e:st_term) (f:env -> st_term -> T.Tac st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = f (push_binding g x b) e in close_st_term' e x 0 let is_internal_binder (b:binder) : T.Tac bool = let s = T.unseal b.binder_ppname.name in s = "_fret" || s = "_bind_c" || s = "_while_c" || s = "_tbind_c" || s = "_if_br" || s = "_br" let is_return (e:st_term) : option term = match e.term with | Tm_Return { term } -> Some term | _ -> None let is_return_bv0 (e:st_term) : bool = match is_return e with | Some term -> is_bvar term = Some 0 | _ -> false // // let x = (let y = e1 in e2) in e3 ~~> let y = e1 in let x = e2 in e3 // // The y let binding can be a TotBind, Bind, let mut, let mut array // let simplify_nested_let (e:st_term) (b_x:binder) (head:st_term) (e3:st_term) : option st_term = let mk t : st_term = { range = e.range; effect_tag = default_effect_hint; term = t } in let body e2 = mk (Tm_Bind { binder = b_x; head = e2; body = e3 }) in match head.term with | Tm_TotBind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_TotBind { binder = b_y; head = e1; body = body e2 })) | Tm_Bind { binder = b_y; head = e1; body = e2 } -> Some (mk (Tm_Bind { binder = b_y; head = e1; body = body e2 })) | Tm_WithLocal { binder = b_y; initializer = e1; body = e2 } -> Some (mk (Tm_WithLocal { binder = b_y; initializer = e1; body = body e2 })) | Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = e2 } -> Some (mk (Tm_WithLocalArray { binder = b_y; initializer = e1; length; body = body e2 })) | _ -> None // // 1. let x = e in x ~~> e // 2. let x = return e1 in e2 ~~> e2[e1/x] // 3. The nested let rule above // // These apply only when x is an internal binder // let rec simplify_st_term (g:env) (e:st_term) : T.Tac st_term = let ret t = { e with term = t } in let with_open b e = with_open g b e simplify_st_term in match e.term with | Tm_Return _ | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_STApp _ | Tm_Rewrite _ | Tm_Admit _ | Tm_ProofHintWithBinders _ -> e | Tm_Abs { b; q; ascription; body } -> ret (Tm_Abs { b; q; ascription; body = with_open b body }) | Tm_Bind { binder; head; body } -> let is_internal_binder = is_internal_binder binder in if is_internal_binder && is_return_bv0 body then simplify_st_term g head else if is_internal_binder && Some? (is_return head) then let Some head = is_return head in simplify_st_term g (LN.subst_st_term body [LN.DT 0 head]) else begin match simplify_nested_let e binder head body with | Some e -> simplify_st_term g e | None -> let head = simplify_st_term g head in let body = with_open binder body in ret (Tm_Bind { binder; head; body }) end | Tm_TotBind { binder; head; body } -> ret (Tm_TotBind { binder; head; body = with_open binder body }) | Tm_If { b; then_; else_; post } -> ret (Tm_If { b; then_ = simplify_st_term g then_; else_ = simplify_st_term g else_; post }) | Tm_Match { sc; returns_; brs } -> ret (Tm_Match { sc; returns_; brs = T.map (simplify_branch g) brs }) | Tm_While { invariant; condition; condition_var; body } -> let condition = simplify_st_term g condition in let body = simplify_st_term g body in { e with term = Tm_While { invariant; condition; condition_var; body } } | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = simplify_st_term g body1 in let body2 = simplify_st_term g body2 in { e with term = Tm_Par { pre1; body1; post1; pre2; body2; post2 } } | Tm_WithLocal { binder; initializer; body } -> ret (Tm_WithLocal { binder; initializer; body = with_open binder body }) | Tm_WithLocalArray { binder; initializer; length; body } -> ret (Tm_WithLocalArray { binder; initializer; length; body = with_open binder body }) | Tm_WithInv {body} -> simplify_st_term g body | Tm_Unreachable -> e and simplify_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = simplify_st_term g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let erase_type_for_extraction (g:env) (t:term) : T.Tac bool = match t.t with | Tm_FStar t -> RU.must_erase_for_extraction (tcenv_of_env g) t | _ -> false let rec erase_ghost_subterms (g:env) (p:st_term) : T.Tac st_term = let open Pulse.Syntax.Naming in let fresh (g:env) = Pulse.Typing.fresh g.coreenv in let push_binding g x b = { g with coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty } in let open_erase_close (g:env) (b:binder) (e:st_term) : T.Tac st_term = let x = fresh g in let e = open_st_term' e (tm_var { nm_index = x; nm_ppname = b.binder_ppname }) 0 in let e = erase_ghost_subterms (push_binding g x b) e in close_st_term' e x 0 in let unit_tm = { p with term = Tm_Return { expected_type=tm_unknown; insert_eq = false; term = unit_val } } in let ret (t:st_term') = { p with term = t } in if is_erasable p then unit_tm else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> unit_tm | Tm_Abs { b; q; body; ascription } -> let body = open_erase_close g b body in ret (Tm_Abs { b; q; body; ascription }) | Tm_Return _ -> p | Tm_STApp _ -> p | Tm_Bind { binder; head; body } -> if is_erasable head then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let head = erase_ghost_subterms g head in let body = open_erase_close g binder body in ret (Tm_Bind { binder; head; body }) | Tm_TotBind { binder; head; body } -> if erase_type_for_extraction g binder.binder_ty then let body = LN.subst_st_term body [LN.DT 0 unit_val] in erase_ghost_subterms g body else let body = open_erase_close g binder body in ret (Tm_TotBind { binder; head; body }) | Tm_If { b; then_; else_; post } -> let then_ = erase_ghost_subterms g then_ in let else_ = erase_ghost_subterms g else_ in ret (Tm_If { b; then_; else_; post }) | Tm_Match { sc; brs; returns_ } -> let brs = T.map (erase_ghost_subterms_branch g) brs in ret (Tm_Match { sc; brs; returns_ }) | Tm_While { invariant; condition; condition_var; body } -> let condition = erase_ghost_subterms g condition in let body = erase_ghost_subterms g body in ret (Tm_While { invariant; condition; condition_var; body }) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> let body1 = erase_ghost_subterms g body1 in let body2 = erase_ghost_subterms g body2 in ret (Tm_Par { pre1; body1; post1; pre2; body2; post2 }) | Tm_WithLocal { binder; initializer; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocal { binder; initializer; body }) | Tm_WithLocalArray { binder; initializer; length; body } -> let body = open_erase_close g binder body in ret (Tm_WithLocalArray { binder; initializer; length; body }) | Tm_Unreachable -> p | Tm_Admit _ -> p | _ -> T.fail "Unexpected st term when erasing ghost subterms" end and erase_ghost_subterms_branch (g:env) (b:branch) : T.Tac branch = let pat, body = b in let g, _, bs = extend_env_pat g pat in let body = Pulse.Checker.Match.open_st_term_bs body bs in let body = erase_ghost_subterms g body in pat, Pulse.Syntax.Naming.close_st_term_n body (L.map fst bs) let rec extract (g:env) (p:st_term) : T.Tac (mlexpr & e_tag) = let erased_result = mle_unit, e_tag_erasable in debug g (fun _ -> Printf.sprintf "Extracting term@%s:\n%s\n" (T.range_to_string p.range) (st_term_to_string p)); if is_erasable p then erased_result else begin match p.term with | Tm_IntroPure _ | Tm_ElimExists _ | Tm_IntroExists _ | Tm_Rewrite _ -> erased_result | Tm_Abs { b; q; body } -> let g, mlident, mlty, name = extend_env g b in let mlattrs = b.binder_attrs |> T.unseal |> T.map (term_as_mlexpr g) in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let res = mle_fun [mlident, mlty, mlattrs] body in res, e_tag_pure | Tm_Return { term } -> term_as_mlexpr g term, e_tag_pure | Tm_STApp { head; arg } -> ( match maybe_inline g head arg with | None -> let head = term_as_mlexpr g head in let arg = term_as_mlexpr g arg in mle_app head [arg], e_tag_impure | Some t -> debug g (fun _ -> Printf.sprintf "Inlined to: %s\n" (st_term_to_string t)); extract g t ) | Tm_Bind { binder; head; body } -> if is_erasable head then ( let body = LN.subst_st_term body [LN.DT 0 unit_val] in debug g (fun _ -> Printf.sprintf "Erasing head of bind %s\nopened body to %s" (st_term_to_string head) (st_term_to_string body)); extract g body ) else ( let head, _ = extract g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure ) // tot here means non-stateful, head could also be ghost, we should rename it | Tm_TotBind { binder; head; body } -> let head = term_as_mlexpr g head in let g, mlident, mlty, name = extend_env g binder in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let mllb = mk_mllb mlident ([], mlty) head in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_If { b; then_; else_ } -> let b = term_as_mlexpr g b in let then_, _ = extract g then_ in let else_, _ = extract g else_ in mle_if b then_ (Some else_), e_tag_impure | Tm_Match { sc; brs } -> let sc = term_as_mlexpr g sc in let extract_branch (pat0, body) = let g, pat, bs = extend_env_pat g pat0 in debug g (fun _ -> Printf.sprintf "Extracting branch with pattern %s\n" (Pulse.Syntax.Printer.pattern_to_string pat0) ); let body = Pulse.Checker.Match.open_st_term_bs body bs in let body, _ = extract g body in pat, body in let brs = T.map extract_branch brs in mle_match sc brs, e_tag_impure | Tm_While { condition; body } -> let condition, _ = extract g condition in let body, _ = extract g body in let condition = mle_fun [("_", mlty_unit, [])] condition in let body = mle_fun [("_", mlty_unit, [])] body in let w = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "while_")) [condition; body] in w, e_tag_impure | Tm_Par { body1; body2 } -> let body1, _ = extract g body1 in let body2, _ = extract g body2 in let body1 = mle_fun [("_", mlty_unit, [])] body1 in let body2 = mle_fun [("_", mlty_unit, [])] body2 in let p = mle_app (mle_name (["Pulse"; "Lib"; "Core"], "par")) [body1; body2] in p, e_tag_impure | Tm_WithLocal { binder; initializer; body } -> let initializer = term_as_mlexpr g initializer in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Reference"] , "alloc")) [initializer] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithLocalArray { binder; initializer; length; body } -> let initializer = term_as_mlexpr g initializer in let length = term_as_mlexpr g length in let g, mlident, mlty, name = extend_env g { binder with binder_ty = binder.binder_ty } in let body = LN.open_st_term_nv body name in let body, _ = extract g body in // // Slice library doesn't have an alloc // // This is parsed by Pulse2Rust // let allocator = mle_app (mle_name (["Pulse"; "Lib"; "Array"; "Core"] , "alloc")) [initializer; length] in let mllb = mk_mut_mllb mlident ([], mlty) allocator in let mlletbinding = mk_mlletbinding false [mllb] in mle_let mlletbinding body, e_tag_impure | Tm_WithInv { body } -> extract g body | Tm_Unreachable -> mle_app (mle_name (["Pulse"; "Lib"; "Core"], "unreachable")) [mle_unit], e_tag_impure | Tm_ProofHintWithBinders { t } -> T.fail "Unexpected constructor: ProofHintWithBinders should have been desugared away" | Tm_Admit _ -> mle_app (mle_name ([], "failwith")) [mle_unit], e_tag_impure // T.raise (Extraction_failure (Printf.sprintf "Cannot extract code with admit: %s\n" (Pulse.Syntax.Printer.st_term_to_string p))) end
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Pure.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Extract.CompilerLib.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Match.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Reflection.fst.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Pulse.Extract.Main.fst" }
[ { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Extract.CompilerLib", "short_module": "ECL" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "LN" }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "E" }, { "abbrev": true, "full_module": "Pulse.Elaborate.Pure", "short_module": "Elab" }, { "abbrev": true, "full_module": "Pulse.Readback", "short_module": "RB" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract.CompilerLib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Extract", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Extract.Main.env -> t: FStar.Stubs.Reflection.Types.typ -> e: FStar.Pervasives.Native.option Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac (((Pulse.Extract.Main.env * Prims.list Pulse.Extract.CompilerLib.mlident) * FStar.Stubs.Reflection.Types.typ) * o: FStar.Pervasives.Native.option Pulse.Syntax.Base.st_term {Some? e <==> Some? o})
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Extract.Main.env", "FStar.Stubs.Reflection.Types.typ", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.st_term", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Data.aqualv", "Prims.list", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Stubs.Reflection.V2.Data.uu___is_Tv_Unknown", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Tactics.Effect.raise", "FStar.Pervasives.Native.tuple4", "Pulse.Extract.CompilerLib.mlident", "Prims.l_iff", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Pulse.Extract.Main.Extraction_failure", "Prims.bool", "FStar.Pervasives.Native.Mktuple4", "Prims.Cons", "Pulse.Extract.CompilerLib.lookup_ty", "Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner", "Pulse.Extract.Main.generalize", "Pulse.Extract.Main.Mkenv", "Pulse.Typing.Env.env", "Prims.eq2", "FStar.Reflection.Typing.fstar_top_env", "Pulse.Typing.Env.fstar_env", "Pulse.Extract.Main.__proj__Mkenv__item__coreenv", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.mk_ppname", "FStar.Range.range_0", "Pulse.Syntax.Base.tm_fstar", "Pulse.Extract.CompilerLib.uenv", "Pulse.Extract.CompilerLib.extend_ty", "FStar.Stubs.Reflection.Types.namedv", "FStar.Stubs.Reflection.V2.Builtins.pack_namedv", "FStar.Stubs.Reflection.V2.Data.Mknamedv_view", "FStar.Sealed.seal", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp_ascription", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.effect_hint", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Naming.subst_st_term", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Prims.Nil", "FStar.Stubs.Reflection.V2.Builtins.subst_term", "FStar.Stubs.Syntax.Syntax.subst_elt", "FStar.Stubs.Syntax.Syntax.DT", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Var", "FStar.Reflection.Typing.sort_default", "Pulse.Syntax.Base.var", "Prims.l_not", "FStar.Set.mem", "Pulse.Typing.Env.dom", "Pulse.Typing.Env.fresh", "FStar.Stubs.Reflection.V2.Data.comp_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp", "Pulse.Extract.CompilerLib.is_type", "FStar.Stubs.Reflection.V2.Data.binder_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_binder", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.unit", "Pulse.Extract.Main.debug", "FStar.Printf.sprintf", "Prims.string", "FStar.Stubs.Tactics.V2.Builtins.term_to_string" ]
[ "recursion" ]
false
true
false
false
false
let rec generalize (g: env) (t: R.typ) (e: option st_term) : T.Tac (env & list mlident & R.typ & o: option st_term {Some? e <==> Some? o}) =
debug g (fun _ -> Printf.sprintf "Generalizing arrow:\n%s\n" (T.term_to_string t)); let tv = R.inspect_ln t in match tv with | R.Tv_Arrow b c -> let { sort = sort ; ppname = ppname } = R.inspect_binder b in if R.Tv_Unknown? (R.inspect_ln sort) then T.raise (Extraction_failure "Unexpected unknown sort when generalizing") else if is_type g.uenv_inner sort then let cview = R.inspect_comp c in match cview with | R.C_Total t -> let x = Pulse.Typing.fresh g.coreenv in let xt = let open R in pack_ln (Tv_Var (pack_namedv ({ uniq = x; sort = RT.sort_default; ppname = ppname }))) in let t = R.subst_term [R.DT 0 xt] t in let e = match e with | Some { term = Tm_Abs { b = b ; body = body } } -> Some (LN.subst_st_term body [LN.DT 0 (tm_fstar xt Range.range_0)]) | _ -> e in let namedv = R.pack_namedv ({ uniq = x; sort = FStar.Sealed.seal sort; ppname = ppname }) in let uenv = extend_ty g.uenv_inner namedv in let coreenv = E.push_binding g.coreenv x (mk_ppname ppname FStar.Range.range_0) (tm_fstar sort FStar.Range.range_0) in let g = { g with uenv_inner = uenv; coreenv = coreenv } in let g, tys, t, e = generalize g t e in g, (lookup_ty g.uenv_inner namedv) :: tys, t, e | _ -> T.raise (Extraction_failure "Unexpected effectful arrow") else g, [], t, e | _ -> g, [], t, e
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_adx_bmi2_flags
val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 157, "start_col": 0, "start_line": 151 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.adx_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_adx", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Vale.X64.CPU_Features_s.bmi2_enabled", "EverCrypt.AutoConfig2.cpu_has_bmi2", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_adx_bmi2" ]
[]
false
true
false
false
false
let init_adx_bmi2_flags () =
if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0uL then (B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true)
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.disable_shaext
val disable_shaext: disabler
val disable_shaext: disabler
let disable_shaext () = B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 243, "start_col": 0, "start_line": 243 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags() inline_for_extraction noextract let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false /// FIXME use mk_disabler let disable_avx2 () = B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul false let disable_avx () = B.recall cpu_has_avx; B.upd cpu_has_avx 0ul false let disable_bmi2 () = B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul false
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.sha_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_shaext", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall" ]
[]
false
false
false
true
false
let disable_shaext () =
B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul false
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.disable_avx2
val disable_avx2: disabler
val disable_avx2: disabler
let disable_avx2 () = B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 239, "start_col": 0, "start_line": 239 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags() inline_for_extraction noextract let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx2_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx2", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall" ]
[]
false
false
false
true
false
let disable_avx2 () =
B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul false
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_cpu_flags
val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 227, "start_col": 0, "start_line": 216 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "EverCrypt.TargetConfig.hacl_can_compile_vale", "EverCrypt.AutoConfig2.init_avx512_flags", "EverCrypt.AutoConfig2.init_rdrand_flags", "EverCrypt.AutoConfig2.init_movbe_flags", "EverCrypt.AutoConfig2.init_sse_flags", "EverCrypt.AutoConfig2.init_avx2_flags", "EverCrypt.AutoConfig2.init_avx_flags", "EverCrypt.AutoConfig2.init_adx_bmi2_flags", "EverCrypt.AutoConfig2.init_shaext_flags", "EverCrypt.AutoConfig2.init_aesni_flags", "Prims.bool" ]
[]
false
true
false
false
false
let init_cpu_flags () =
if EverCrypt.TargetConfig.hacl_can_compile_vale then (init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags (); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags ())
false
Hacl.K256.Scalar.fsti
Hacl.K256.Scalar.qe_lt_q
val qe_lt_q : h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Scalar.qelem -> Prims.GTot Prims.bool
let qe_lt_q (h:mem) (e:qelem) = qas_nat h e < S.q
{ "file_name": "code/k256/Hacl.K256.Scalar.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 35, "start_col": 0, "start_line": 35 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence module S = Spec.K256 module SG = Hacl.Spec.K256.GLV module BD = Hacl.Bignum.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let qnlimb = 4ul inline_for_extraction noextract let qelem = lbuffer uint64 qnlimb noextract let qas_nat (h:mem) (e:qelem) : GTot nat = BD.bn_v #U64 #qnlimb h e noextract let qeval (h:mem) (e:qelem) : GTot S.qelem = qas_nat h e % S.q
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.K256.Scalar.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Scalar.qelem -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.K256.Scalar.qelem", "Prims.op_LessThan", "Hacl.K256.Scalar.qas_nat", "Spec.K256.PointOps.q", "Prims.bool" ]
[]
false
false
false
false
false
let qe_lt_q (h: mem) (e: qelem) =
qas_nat h e < S.q
false
Hacl.K256.Scalar.fsti
Hacl.K256.Scalar.qas_nat4
val qas_nat4 : f: Hacl.K256.Scalar.qelem4 -> Prims.int
let qas_nat4 (f:qelem4) = let (f0, f1, f2, f3) = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
{ "file_name": "code/k256/Hacl.K256.Scalar.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 44, "start_col": 0, "start_line": 42 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence module S = Spec.K256 module SG = Hacl.Spec.K256.GLV module BD = Hacl.Bignum.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let qnlimb = 4ul inline_for_extraction noextract let qelem = lbuffer uint64 qnlimb noextract let qas_nat (h:mem) (e:qelem) : GTot nat = BD.bn_v #U64 #qnlimb h e noextract let qeval (h:mem) (e:qelem) : GTot S.qelem = qas_nat h e % S.q noextract let qe_lt_q (h:mem) (e:qelem) = qas_nat h e < S.q inline_for_extraction noextract let qelem4 = uint64 & uint64 & uint64 & uint64
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.K256.Scalar.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem4 -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Hacl.K256.Scalar.qelem4", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Prims.pow2", "Prims.int" ]
[]
false
false
false
true
false
let qas_nat4 (f: qelem4) =
let f0, f1, f2, f3 = f in v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
false
Hacl.K256.Scalar.fsti
Hacl.K256.Scalar.qelem
val qelem : Type0
let qelem = lbuffer uint64 qnlimb
{ "file_name": "code/k256/Hacl.K256.Scalar.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 26, "start_col": 0, "start_line": 26 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence module S = Spec.K256 module SG = Hacl.Spec.K256.GLV module BD = Hacl.Bignum.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let qnlimb = 4ul
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.K256.Scalar.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb" ]
[]
false
false
false
true
true
let qelem =
lbuffer uint64 qnlimb
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.disable_bmi2
val disable_bmi2: disabler
val disable_bmi2: disabler
let disable_bmi2 () = B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 241, "start_col": 0, "start_line": 241 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags() inline_for_extraction noextract let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false /// FIXME use mk_disabler let disable_avx2 () = B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul false
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.bmi2_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_bmi2", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall" ]
[]
false
false
false
true
false
let disable_bmi2 () =
B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul false
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.init_avx_flags
val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 129, "start_col": 0, "start_line": 123 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.avx_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_avx", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall", "Prims.bool", "Prims.op_disEquality", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "Vale.Wrapper.X64.Cpuid.check_avx_xcr0", "Vale.Wrapper.X64.Cpuid.check_osxsave", "Vale.Wrapper.X64.Cpuid.check_avx" ]
[]
false
true
false
false
false
let init_avx_flags () =
if Vale.Wrapper.X64.Cpuid.check_avx () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0uL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0uL then (B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true)
false
Hacl.K256.Scalar.fsti
Hacl.K256.Scalar.qelem4
val qelem4 : Type0
let qelem4 = uint64 & uint64 & uint64 & uint64
{ "file_name": "code/k256/Hacl.K256.Scalar.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 39, "start_col": 0, "start_line": 39 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence module S = Spec.K256 module SG = Hacl.Spec.K256.GLV module BD = Hacl.Bignum.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let qnlimb = 4ul inline_for_extraction noextract let qelem = lbuffer uint64 qnlimb noextract let qas_nat (h:mem) (e:qelem) : GTot nat = BD.bn_v #U64 #qnlimb h e noextract let qeval (h:mem) (e:qelem) : GTot S.qelem = qas_nat h e % S.q noextract let qe_lt_q (h:mem) (e:qelem) = qas_nat h e < S.q
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.K256.Scalar.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let qelem4 =
uint64 & uint64 & uint64 & uint64
false
EverCrypt.AutoConfig2.fst
EverCrypt.AutoConfig2.disable_aesni
val disable_aesni: disabler
val disable_aesni: disabler
let disable_aesni () = B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul false
{ "file_name": "providers/evercrypt/fst/EverCrypt.AutoConfig2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 244, "start_col": 0, "start_line": 244 }
module EverCrypt.AutoConfig2 module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module S = FStar.Seq open FStar.HyperStack.ST #set-options "--max_fuel 0 --max_ifuel 0" (** Only partially specified; the flag may be false because it has been intentionally disabled by the client, for instance. *) type flag (b: bool) = b':bool { b' ==> b } (** Flags, cached in a mutable global reference *) let eternal_pointer a = buf:B.buffer a { B.recallable buf /\ B.length buf = 1 } unfold let cached_flag (b: bool) = eternal_pointer (flag b) let cpu_has_shaext: cached_flag Vale.X64.CPU_Features_s.sha_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_aesni: cached_flag Vale.X64.CPU_Features_s.aesni_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_pclmulqdq: cached_flag Vale.X64.CPU_Features_s.pclmulqdq_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx2: cached_flag Vale.X64.CPU_Features_s.avx2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx: cached_flag Vale.X64.CPU_Features_s.avx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_bmi2: cached_flag Vale.X64.CPU_Features_s.bmi2_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_adx: cached_flag Vale.X64.CPU_Features_s.adx_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_sse: cached_flag Vale.X64.CPU_Features_s.sse_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_movbe: cached_flag Vale.X64.CPU_Features_s.movbe_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_rdrand: cached_flag Vale.X64.CPU_Features_s.rdrand_enabled = B.gcmalloc_of_list HS.root [ false ] let cpu_has_avx512: cached_flag Vale.X64.CPU_Features_s.avx512_enabled = B.gcmalloc_of_list HS.root [ false ] inline_for_extraction let mk_getter #b (f: cached_flag b): getter b = fun () -> B.recall f; B.index f 0ul let has_shaext = mk_getter cpu_has_shaext let has_aesni = mk_getter cpu_has_aesni let has_pclmulqdq = mk_getter cpu_has_pclmulqdq let has_avx2 = mk_getter cpu_has_avx2 let has_avx = mk_getter cpu_has_avx let has_bmi2 = mk_getter cpu_has_bmi2 let has_adx = mk_getter cpu_has_adx let has_sse = mk_getter cpu_has_sse let has_movbe = mk_getter cpu_has_movbe let has_rdrand = mk_getter cpu_has_rdrand let has_avx512 = mk_getter cpu_has_avx512 let fp () = B.loc_buffer cpu_has_shaext `B.loc_union` B.loc_buffer cpu_has_aesni `B.loc_union` B.loc_buffer cpu_has_pclmulqdq `B.loc_union` B.loc_buffer cpu_has_avx2 `B.loc_union` B.loc_buffer cpu_has_avx `B.loc_union` B.loc_buffer cpu_has_bmi2 `B.loc_union` B.loc_buffer cpu_has_adx `B.loc_union` B.loc_buffer cpu_has_sse `B.loc_union` B.loc_buffer cpu_has_movbe `B.loc_union` B.loc_buffer cpu_has_rdrand `B.loc_union` B.loc_buffer cpu_has_avx512 let recall () = B.recall cpu_has_shaext; B.recall cpu_has_aesni; B.recall cpu_has_pclmulqdq; B.recall cpu_has_avx2; B.recall cpu_has_avx; B.recall cpu_has_bmi2; B.recall cpu_has_adx; B.recall cpu_has_sse; B.recall cpu_has_movbe; B.recall cpu_has_rdrand; B.recall cpu_has_avx512 inline_for_extraction noextract val init_aesni_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_aesni_flags () = if Vale.Wrapper.X64.Cpuid.check_aesni () <> 0UL then begin B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul true; B.recall cpu_has_pclmulqdq; B.upd cpu_has_pclmulqdq 0ul true end inline_for_extraction noextract val init_shaext_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_shaext_flags () = if Vale.Wrapper.X64.Cpuid.check_sha () <> 0UL then begin B.recall cpu_has_shaext; B.upd cpu_has_shaext 0ul true end inline_for_extraction noextract val init_avx_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx_flags () = if Vale.Wrapper.X64.Cpuid.check_avx () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx; B.upd cpu_has_avx 0ul true end inline_for_extraction noextract val init_avx2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx2_flags () = if Vale.Wrapper.X64.Cpuid.check_avx2 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then begin B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul true end inline_for_extraction noextract val init_adx_bmi2_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_adx_bmi2_flags () = if Vale.Wrapper.X64.Cpuid.check_adx_bmi2 () <> 0UL then begin B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul true; B.recall cpu_has_adx; B.upd cpu_has_adx 0ul true end inline_for_extraction noextract val init_sse_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_sse_flags () = if Vale.Wrapper.X64.Cpuid.check_sse () <> 0UL then begin B.recall cpu_has_sse; B.upd cpu_has_sse 0ul true end inline_for_extraction noextract val init_movbe_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_movbe_flags () = if Vale.Wrapper.X64.Cpuid.check_movbe () <> 0UL then begin B.recall cpu_has_movbe; B.upd cpu_has_movbe 0ul true end inline_for_extraction noextract val init_rdrand_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_rdrand_flags() = if Vale.Wrapper.X64.Cpuid.check_rdrand () <> 0UL then begin B.recall cpu_has_rdrand; B.upd cpu_has_rdrand 0ul true end inline_for_extraction noextract val init_avx512_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_avx512_flags () = if Vale.Wrapper.X64.Cpuid.check_avx512 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_osxsave () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx_xcr0 () <> 0UL then if Vale.Wrapper.X64.Cpuid.check_avx512_xcr0 () <> 0UL then begin B.recall cpu_has_avx512; B.upd cpu_has_avx512 0ul true end inline_for_extraction noextract val init_cpu_flags: unit -> Stack unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> B.modifies (fp ()) h0 h1)) let init_cpu_flags () = if EverCrypt.TargetConfig.hacl_can_compile_vale then begin init_aesni_flags (); init_shaext_flags (); init_adx_bmi2_flags(); init_avx_flags (); init_avx2_flags (); init_sse_flags (); init_movbe_flags (); init_rdrand_flags (); init_avx512_flags () end #set-options "--z3rlimit 50" let init () = init_cpu_flags() inline_for_extraction noextract let mk_disabler (f: eternal_pointer bool { B.loc_includes (fp ()) (B.loc_buffer f) }): disabler = fun () -> B.recall f; B.upd f 0ul false /// FIXME use mk_disabler let disable_avx2 () = B.recall cpu_has_avx2; B.upd cpu_has_avx2 0ul false let disable_avx () = B.recall cpu_has_avx; B.upd cpu_has_avx 0ul false let disable_bmi2 () = B.recall cpu_has_bmi2; B.upd cpu_has_bmi2 0ul false let disable_adx () = B.recall cpu_has_adx; B.upd cpu_has_adx 0ul false
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Vale.Wrapper.X64.Cpuid.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "EverCrypt.TargetConfig.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AutoConfig2.fst" }
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "EverCrypt.TargetConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AutoConfig2.disabler
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowStar.Monotonic.Buffer.upd", "EverCrypt.AutoConfig2.flag", "Vale.X64.CPU_Features_s.aesni_enabled", "LowStar.Buffer.trivial_preorder", "EverCrypt.AutoConfig2.cpu_has_aesni", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.recall" ]
[]
false
false
false
true
false
let disable_aesni () =
B.recall cpu_has_aesni; B.upd cpu_has_aesni 0ul false
false