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.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.with_localarray_body_post | val with_localarray_body_post (post a ret_t arr: term) : term | val with_localarray_body_post (post a ret_t arr: term) : term | let with_localarray_body_post (post:term) (a:term) (ret_t:term) (arr:term) : term =
mk_abs ret_t Q_Explicit (with_localarray_body_post_body post a arr) | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 69,
"end_line": 409,
"start_col": 0,
"start_line": 408
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*)
let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ]
let elim_exists_post (u:universe) (a:term) (p:term) (x:var) =
let erased_a = mk_erased u a in
mk_abs erased_a Q_Explicit (elim_exists_post_body u a p x)
val elim_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_elim_exists u a p)
(mk_stt_ghost_comp
u
(mk_erased u a)
(mk_exists u a p)
(elim_exists_post u a p x)))
(*
g |- a : Type u
g |- p : a -> vprop
g |- e : vprop
-------------------------------------------------------------------------
g |- intro_exists<u> #a p e : stt_ghost<0> unit empty (p e) (fun _ -> exists_ p)
*)
val intro_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#e:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
(e_typing:RT.ghost_typing g e a)
: GTot (RT.tot_typing g
(mk_intro_exists u a p e)
(mk_stt_ghost_comp uzero unit_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists u a p))))
(*
g |- a : Type u
g |- p : vprop
g |- q : a -> vprop
------------------------------------------
g |- stt_admit a p q : stt a p q
*)
val stt_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_admit u a p q)
(mk_stt_comp u a p q))
val stt_atomic_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_admit u a p q)
(mk_stt_atomic_comp neutral_fv u a emp_inames_tm p q))
val stt_ghost_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_admit u a p q)
(mk_stt_ghost_comp u a p q))
val rewrite_typing
(#g:env)
(#p:term)
(#q:term)
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q vprop_tm)
(equiv:RT.tot_typing g (`()) (stt_vprop_equiv p q))
: GTot (RT.tot_typing g
(mk_rewrite p q)
(mk_stt_ghost_comp
uzero
unit_tm
p
(mk_abs unit_tm Q_Explicit q)))
// mk_star pre (mk_pts_to a (RT.bound_var 0) full_perm_tm init
let with_local_body_pre (pre:term) (a:term) (x:term) (init:term) : term =
let pts_to : term =
mk_pts_to a x full_perm_tm init in
mk_star pre pts_to
//
// post has 0 db index free
//
let with_local_body_post_body (post:term) (a:term) (x:term) : term =
// exists_ (R.pts_to r full_perm)
let exists_tm =
mk_exists (pack_universe Uv_Zero) a
(mk_abs a Q_Explicit
(mk_pts_to a x full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm
let with_local_body_post (post:term) (a:term) (ret_t:term) (x:term) : term =
mk_abs ret_t Q_Explicit (with_local_body_post_body post a x)
val with_local_typing
(#g:env)
(#u:universe)
(#a:term)
(#init:term)
(#pre:term)
(#ret_t:term)
(#post:term) // post has db 0 free
(#body:term) // body has x free
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type (pack_universe Uv_Zero))))
(init_typing:RT.tot_typing g init a)
(pre_typing:RT.tot_typing g pre vprop_tm)
(ret_t_typing:RT.tot_typing g ret_t (pack_ln (Tv_Type u)))
(post_typing:RT.tot_typing g (RT.mk_abs ret_t Q_Explicit post)
(mk_arrow (ret_t, Q_Explicit) vprop_tm))
(body_typing:RT.tot_typing (RT.extend_env g x (mk_ref a))
body
(mk_stt_comp u ret_t
(with_local_body_pre pre a (RT.var_as_term x) init)
(with_local_body_post post a ret_t (RT.var_as_term x))))
: GTot (RT.tot_typing g (mk_withlocal u a init pre ret_t (RT.mk_abs ret_t Q_Explicit post)
(RT.mk_abs (mk_ref a) Q_Explicit (RT.close_term body x)))
(mk_stt_comp u ret_t pre (mk_abs ret_t Q_Explicit post)))
let with_localarray_body_pre (pre:term) (a:term) (arr:term) (init:term) (len:term) : term =
let pts_to : term =
mk_array_pts_to a arr full_perm_tm (mk_seq_create uzero a (mk_szv len) init) in
let len_vp : term =
mk_pure (mk_eq2 uzero nat_tm (mk_array_length a arr) (mk_szv len)) in
mk_star pre (mk_star pts_to len_vp)
//
// post has 0 db index free
//
let with_localarray_body_post_body (post:term) (a:term) (arr:term) : term =
// exists_ (A.pts_to arr full_perm)
let exists_tm =
mk_exists uzero (mk_seq uzero a)
(mk_abs (mk_seq uzero a) Q_Explicit
(mk_array_pts_to a arr full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
post: FStar.Stubs.Reflection.Types.term ->
a: FStar.Stubs.Reflection.Types.term ->
ret_t: FStar.Stubs.Reflection.Types.term ->
arr: FStar.Stubs.Reflection.Types.term
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.term",
"Pulse.Reflection.Util.mk_abs",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Pulse.Steel.Wrapper.Typing.with_localarray_body_post_body"
] | [] | false | false | false | true | false | let with_localarray_body_post (post a ret_t arr: term) : term =
| mk_abs ret_t Q_Explicit (with_localarray_body_post_body post a arr) | false |
Vale.SHA.PPC64LE.SHA_helpers.fsti | Vale.SHA.PPC64LE.SHA_helpers.k_reqs | val k_reqs (k_seq: seq quad32) : prop0 | val k_reqs (k_seq: seq quad32) : prop0 | let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 189,
"start_col": 0,
"start_line": 183
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Def.Sel
open Vale.SHA2.Wrapper
open Vale.Def.Words.Four_s
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
val update_block (hash:hash256) (block:block_w): hash256
val 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)
val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def
irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def
val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def
irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def
val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def
irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def
val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def
irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def
val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a /\
hash.[1] == nat32_to_word b /\
hash.[2] == nat32_to_word c /\
hash.[3] == nat32_to_word d /\
hash.[4] == nat32_to_word e /\
hash.[5] == nat32_to_word f /\
hash.[6] == nat32_to_word g /\
hash.[7] == nat32_to_word h
)
val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a.hi3 /\
hash.[1] == nat32_to_word b.hi3 /\
hash.[2] == nat32_to_word c.hi3 /\
hash.[3] == nat32_to_word d.hi3 /\
hash.[4] == nat32_to_word e.hi3 /\
hash.[5] == nat32_to_word f.hi3 /\
hash.[6] == nat32_to_word g.hi3 /\
hash.[7] == nat32_to_word h.hi3
)
val 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)
val lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
val ch_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z))
val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
val maj_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z)))
val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.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.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti"
} | [
{
"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": 2,
"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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k_seq: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Division",
"Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.op_LessThanOrEqual",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.SHA.PPC64LE.SHA_helpers.k",
"FStar.Mul.op_Star",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"FStar.Seq.Base.index",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | true | false | let k_reqs (k_seq: seq quad32) : prop0 =
| length k_seq == size_k_w_256 / 4 /\
(forall i. {:pattern (index k_seq i)}
0 <= i /\ i < (size_k_w_256 / 4) ==>
(k_seq.[ i ]).lo0 == word_to_nat32 (k.[ 4 * i ]) /\
(k_seq.[ i ]).lo1 == word_to_nat32 (k.[ 4 * i + 1 ]) /\
(k_seq.[ i ]).hi2 == word_to_nat32 (k.[ 4 * i + 2 ]) /\
(k_seq.[ i ]).hi3 == word_to_nat32 (k.[ 4 * i + 3 ])) | false |
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.with_localarray_body_pre | val with_localarray_body_pre (pre a arr init len: term) : term | val with_localarray_body_pre (pre a arr init len: term) : term | let with_localarray_body_pre (pre:term) (a:term) (arr:term) (init:term) (len:term) : term =
let pts_to : term =
mk_array_pts_to a arr full_perm_tm (mk_seq_create uzero a (mk_szv len) init) in
let len_vp : term =
mk_pure (mk_eq2 uzero nat_tm (mk_array_length a arr) (mk_szv len)) in
mk_star pre (mk_star pts_to len_vp) | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 37,
"end_line": 395,
"start_col": 0,
"start_line": 390
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*)
let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ]
let elim_exists_post (u:universe) (a:term) (p:term) (x:var) =
let erased_a = mk_erased u a in
mk_abs erased_a Q_Explicit (elim_exists_post_body u a p x)
val elim_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_elim_exists u a p)
(mk_stt_ghost_comp
u
(mk_erased u a)
(mk_exists u a p)
(elim_exists_post u a p x)))
(*
g |- a : Type u
g |- p : a -> vprop
g |- e : vprop
-------------------------------------------------------------------------
g |- intro_exists<u> #a p e : stt_ghost<0> unit empty (p e) (fun _ -> exists_ p)
*)
val intro_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#e:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
(e_typing:RT.ghost_typing g e a)
: GTot (RT.tot_typing g
(mk_intro_exists u a p e)
(mk_stt_ghost_comp uzero unit_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists u a p))))
(*
g |- a : Type u
g |- p : vprop
g |- q : a -> vprop
------------------------------------------
g |- stt_admit a p q : stt a p q
*)
val stt_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_admit u a p q)
(mk_stt_comp u a p q))
val stt_atomic_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_admit u a p q)
(mk_stt_atomic_comp neutral_fv u a emp_inames_tm p q))
val stt_ghost_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_admit u a p q)
(mk_stt_ghost_comp u a p q))
val rewrite_typing
(#g:env)
(#p:term)
(#q:term)
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q vprop_tm)
(equiv:RT.tot_typing g (`()) (stt_vprop_equiv p q))
: GTot (RT.tot_typing g
(mk_rewrite p q)
(mk_stt_ghost_comp
uzero
unit_tm
p
(mk_abs unit_tm Q_Explicit q)))
// mk_star pre (mk_pts_to a (RT.bound_var 0) full_perm_tm init
let with_local_body_pre (pre:term) (a:term) (x:term) (init:term) : term =
let pts_to : term =
mk_pts_to a x full_perm_tm init in
mk_star pre pts_to
//
// post has 0 db index free
//
let with_local_body_post_body (post:term) (a:term) (x:term) : term =
// exists_ (R.pts_to r full_perm)
let exists_tm =
mk_exists (pack_universe Uv_Zero) a
(mk_abs a Q_Explicit
(mk_pts_to a x full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm
let with_local_body_post (post:term) (a:term) (ret_t:term) (x:term) : term =
mk_abs ret_t Q_Explicit (with_local_body_post_body post a x)
val with_local_typing
(#g:env)
(#u:universe)
(#a:term)
(#init:term)
(#pre:term)
(#ret_t:term)
(#post:term) // post has db 0 free
(#body:term) // body has x free
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type (pack_universe Uv_Zero))))
(init_typing:RT.tot_typing g init a)
(pre_typing:RT.tot_typing g pre vprop_tm)
(ret_t_typing:RT.tot_typing g ret_t (pack_ln (Tv_Type u)))
(post_typing:RT.tot_typing g (RT.mk_abs ret_t Q_Explicit post)
(mk_arrow (ret_t, Q_Explicit) vprop_tm))
(body_typing:RT.tot_typing (RT.extend_env g x (mk_ref a))
body
(mk_stt_comp u ret_t
(with_local_body_pre pre a (RT.var_as_term x) init)
(with_local_body_post post a ret_t (RT.var_as_term x))))
: GTot (RT.tot_typing g (mk_withlocal u a init pre ret_t (RT.mk_abs ret_t Q_Explicit post)
(RT.mk_abs (mk_ref a) Q_Explicit (RT.close_term body x)))
(mk_stt_comp u ret_t pre (mk_abs ret_t Q_Explicit post))) | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
pre: FStar.Stubs.Reflection.Types.term ->
a: FStar.Stubs.Reflection.Types.term ->
arr: FStar.Stubs.Reflection.Types.term ->
init: FStar.Stubs.Reflection.Types.term ->
len: FStar.Stubs.Reflection.Types.term
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.term",
"Pulse.Reflection.Util.mk_star",
"Pulse.Reflection.Util.mk_pure",
"Pulse.Reflection.Util.mk_eq2",
"Pulse.Reflection.Util.uzero",
"Pulse.Reflection.Util.nat_tm",
"Pulse.Reflection.Util.mk_array_length",
"Pulse.Reflection.Util.mk_szv",
"Pulse.Reflection.Util.mk_array_pts_to",
"Pulse.Reflection.Util.full_perm_tm",
"Pulse.Reflection.Util.mk_seq_create"
] | [] | false | false | false | true | false | let with_localarray_body_pre (pre a arr init len: term) : term =
| let pts_to:term = mk_array_pts_to a arr full_perm_tm (mk_seq_create uzero a (mk_szv len) init) in
let len_vp:term = mk_pure (mk_eq2 uzero nat_tm (mk_array_length a arr) (mk_szv len)) in
mk_star pre (mk_star pts_to len_vp) | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_regs_modified | val cswap_regs_modified: MS.reg_64 -> bool | val cswap_regs_modified: MS.reg_64 -> bool | let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 73,
"start_col": 0,
"start_line": 70
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | r: Vale.X64.Machine_s.reg_64 -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.reg_64",
"Prims.op_BarBar",
"Prims.op_Equality",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR10",
"Prims.bool"
] | [] | false | false | false | true | false | let cswap_regs_modified: MS.reg_64 -> bool =
| fun (r: MS.reg_64) ->
let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false | false |
Vale.SHA.PPC64LE.SHA_helpers.fsti | Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be | val quads_to_block_be (qs: seq quad32) : block_w | val quads_to_block_be (qs: seq quad32) : block_w | let quads_to_block_be (qs:seq quad32) : block_w
=
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in
let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in
init 16 f | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 195,
"start_col": 0,
"start_line": 191
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Def.Sel
open Vale.SHA2.Wrapper
open Vale.Def.Words.Four_s
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
val update_block (hash:hash256) (block:block_w): hash256
val 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)
val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def
irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def
val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def
irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def
val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def
irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def
val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def
irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def
val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a /\
hash.[1] == nat32_to_word b /\
hash.[2] == nat32_to_word c /\
hash.[3] == nat32_to_word d /\
hash.[4] == nat32_to_word e /\
hash.[5] == nat32_to_word f /\
hash.[6] == nat32_to_word g /\
hash.[7] == nat32_to_word h
)
val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a.hi3 /\
hash.[1] == nat32_to_word b.hi3 /\
hash.[2] == nat32_to_word c.hi3 /\
hash.[3] == nat32_to_word d.hi3 /\
hash.[4] == nat32_to_word e.hi3 /\
hash.[5] == nat32_to_word f.hi3 /\
hash.[6] == nat32_to_word g.hi3 /\
hash.[7] == nat32_to_word h.hi3
)
val 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)
val lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
val ch_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z))
val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
val maj_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z)))
val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
(* Abbreviations and lemmas for the code itself *)
let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.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.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti"
} | [
{
"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": 2,
"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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.SHA.PPC64LE.SHA_helpers.block_w | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.init",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.op_String_Access",
"Prims.bool",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Prims.int",
"Prims.op_Multiply",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Seq_s.seq_four_to_seq_BE",
"Vale.SHA.PPC64LE.SHA_helpers.block_w"
] | [] | false | false | false | true | false | let quads_to_block_be (qs: seq quad32) : block_w =
| let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in
let f (n: nat{n < 16}) : word =
nat32_to_word (if n < length nat32_seq then nat32_seq.[ n ] else 0)
in
init 16 f | false |
Vale.SHA.PPC64LE.SHA_helpers.fsti | Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash | val le_bytes_to_hash (b: seq nat8) : hash256 | val le_bytes_to_hash (b: seq nat8) : hash256 | let le_bytes_to_hash (b:seq nat8) : hash256 =
if length b <> 32 then
(let f (n:nat{n < 8}) : word = nat32_to_word 0 in
init 8 f)
else (
let open Vale.Def.Words.Seq_s in
Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b)
) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 288,
"start_col": 0,
"start_line": 281
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Def.Sel
open Vale.SHA2.Wrapper
open Vale.Def.Words.Four_s
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
val update_block (hash:hash256) (block:block_w): hash256
val 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)
val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def
irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def
val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32
[@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def
irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def
val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def
irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def
val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
[@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def
irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def
val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_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))
val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a /\
hash.[1] == nat32_to_word b /\
hash.[2] == nat32_to_word c /\
hash.[3] == nat32_to_word d /\
hash.[4] == nat32_to_word e /\
hash.[5] == nat32_to_word f /\
hash.[6] == nat32_to_word g /\
hash.[7] == nat32_to_word h
)
val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a.hi3 /\
hash.[1] == nat32_to_word b.hi3 /\
hash.[2] == nat32_to_word c.hi3 /\
hash.[3] == nat32_to_word d.hi3 /\
hash.[4] == nat32_to_word e.hi3 /\
hash.[5] == nat32_to_word f.hi3 /\
hash.[6] == nat32_to_word g.hi3 /\
hash.[7] == nat32_to_word h.hi3
)
val 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)
val lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
val ch_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z))
val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
val maj_256 (x y z:nat32):Pure(nat32)
(requires True)
(ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z)))
val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
(* Abbreviations and lemmas for the code itself *)
let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3]))
let quads_to_block_be (qs:seq quad32) : block_w
=
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in
let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in
init 16 f
val lemma_quads_to_block_be (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block_be qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\
(qs.[i]).lo0 == ws_opaque block (4 * i + 3)))
let k_index (ks:seq quad32) (i:nat) : nat32 =
if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[(i/4)] (i % 4)
else 0
val 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))
val 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 repeat_range_vale_64 (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash
val update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
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 hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s))
=
if length s < 4 then
hash_orig
else
let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block_be qs) in
hash
val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.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.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti"
} | [
{
"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": 2,
"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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> Vale.SHA.PPC64LE.SHA_helpers.hash256 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat8",
"Prims.op_disEquality",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.init",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Prims.bool",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"Vale.SHA.PPC64LE.SHA_helpers.hash256"
] | [] | false | false | false | true | false | let le_bytes_to_hash (b: seq nat8) : hash256 =
| if length b <> 32
then
(let f (n: nat{n < 8}) : word = nat32_to_word 0 in
init 8 f)
else
(let open Vale.Def.Words.Seq_s in
Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b)) | false |
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.elim_exists_post_body | val elim_exists_post_body : u166: FStar.Stubs.Reflection.Types.universe ->
a: FStar.Stubs.Reflection.Types.term ->
p: FStar.Stubs.Reflection.Types.term ->
x: FStar.Stubs.Reflection.V2.Data.var
-> FStar.Stubs.Reflection.Types.term | let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ] | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 34,
"end_line": 230,
"start_col": 0,
"start_line": 226
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*) | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
u166: FStar.Stubs.Reflection.Types.universe ->
a: FStar.Stubs.Reflection.Types.term ->
p: FStar.Stubs.Reflection.Types.term ->
x: FStar.Stubs.Reflection.V2.Data.var
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.universe",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Data.var",
"FStar.Reflection.Typing.subst_term",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.ND",
"Prims.Nil",
"FStar.Stubs.Reflection.V2.Builtins.pack_ln",
"FStar.Stubs.Reflection.V2.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Pulse.Reflection.Util.mk_reveal",
"FStar.Reflection.Typing.var_as_term"
] | [] | false | false | false | true | false | let elim_exists_post_body (u: universe) (a p: term) (x: var) =
| let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [RT.ND x 0] | false |
|
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.return_stt_ghost_comp | val return_stt_ghost_comp (u: universe) (a e p: term) (x: var) : term | val return_stt_ghost_comp (u: universe) (a e p: term) (x: var) : term | let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x) | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 35,
"end_line": 109,
"start_col": 0,
"start_line": 106
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p)) | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
u90: FStar.Stubs.Reflection.Types.universe ->
a: FStar.Stubs.Reflection.Types.term ->
e: FStar.Stubs.Reflection.Types.term ->
p: FStar.Stubs.Reflection.Types.term ->
x: FStar.Stubs.Reflection.V2.Data.var
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.universe",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Data.var",
"Pulse.Reflection.Util.mk_stt_ghost_comp",
"FStar.Stubs.Reflection.V2.Builtins.pack_ln",
"FStar.Stubs.Reflection.V2.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Pulse.Steel.Wrapper.Typing.return_post_with_eq"
] | [] | false | false | false | true | false | let return_stt_ghost_comp (u: universe) (a e p: term) (x: var) : term =
| mk_stt_ghost_comp u a (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x) | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_post | val cswap_post:VSig.vale_post cswap_dom | val cswap_post:VSig.vale_post cswap_dom | let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 93,
"end_line": 66,
"start_col": 0,
"start_line": 58
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_post Vale.Inline.X64.Fswap_inline.cswap_dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Inline.X64.Fswap_inline.uint64",
"Vale.Inline.X64.Fswap_inline.b64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.Curve25519.X64.FastUtil.va_ens_Cswap2",
"FStar.UInt64.v",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.prop"
] | [] | false | false | false | true | false | let cswap_post:VSig.vale_post cswap_dom =
| fun
(c: V.va_code)
(bit: uint64)
(p0: b64)
(p1: b64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_dom | val cswap_dom:IX64.arity_ok 3 td | val cswap_dom:IX64.arity_ok 3 td | let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 44,
"start_col": 0,
"start_line": 41
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.X64.arity_ok 3 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.Inline.X64.Fswap_inline.tuint64",
"Vale.Inline.X64.Fswap_inline.t64_mod",
"Prims.Nil"
] | [] | false | false | false | false | false | let cswap_dom:IX64.arity_ok 3 td =
| let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y | false |
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.with_local_body_pre | val with_local_body_pre (pre a x init: term) : term | val with_local_body_pre (pre a x init: term) : term | let with_local_body_pre (pre:term) (a:term) (x:term) (init:term) : term =
let pts_to : term =
mk_pts_to a x full_perm_tm init in
mk_star pre pts_to | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 20,
"end_line": 348,
"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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*)
let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ]
let elim_exists_post (u:universe) (a:term) (p:term) (x:var) =
let erased_a = mk_erased u a in
mk_abs erased_a Q_Explicit (elim_exists_post_body u a p x)
val elim_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_elim_exists u a p)
(mk_stt_ghost_comp
u
(mk_erased u a)
(mk_exists u a p)
(elim_exists_post u a p x)))
(*
g |- a : Type u
g |- p : a -> vprop
g |- e : vprop
-------------------------------------------------------------------------
g |- intro_exists<u> #a p e : stt_ghost<0> unit empty (p e) (fun _ -> exists_ p)
*)
val intro_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#e:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
(e_typing:RT.ghost_typing g e a)
: GTot (RT.tot_typing g
(mk_intro_exists u a p e)
(mk_stt_ghost_comp uzero unit_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists u a p))))
(*
g |- a : Type u
g |- p : vprop
g |- q : a -> vprop
------------------------------------------
g |- stt_admit a p q : stt a p q
*)
val stt_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_admit u a p q)
(mk_stt_comp u a p q))
val stt_atomic_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_admit u a p q)
(mk_stt_atomic_comp neutral_fv u a emp_inames_tm p q))
val stt_ghost_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_admit u a p q)
(mk_stt_ghost_comp u a p q))
val rewrite_typing
(#g:env)
(#p:term)
(#q:term)
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q vprop_tm)
(equiv:RT.tot_typing g (`()) (stt_vprop_equiv p q))
: GTot (RT.tot_typing g
(mk_rewrite p q)
(mk_stt_ghost_comp
uzero
unit_tm
p
(mk_abs unit_tm Q_Explicit q))) | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
pre: FStar.Stubs.Reflection.Types.term ->
a: FStar.Stubs.Reflection.Types.term ->
x: FStar.Stubs.Reflection.Types.term ->
init: FStar.Stubs.Reflection.Types.term
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.term",
"Pulse.Reflection.Util.mk_star",
"Pulse.Reflection.Util.mk_pts_to",
"Pulse.Reflection.Util.full_perm_tm"
] | [] | false | false | false | true | false | let with_local_body_pre (pre a x init: term) : term =
| let pts_to:term = mk_pts_to a x full_perm_tm init in
mk_star pre pts_to | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap2_code_inline | val cswap2_code_inline: Prims.unit -> FStar.All.ML int | val cswap2_code_inline: Prims.unit -> FStar.All.ML int | let cswap2_code_inline () : FStar.All.ML int =
PR.print_inline "cswap2" 0 None (List.length cswap_dom) cswap_dom cswap_names code_cswap of_arg cswap_regs_modified cswap_comments | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 132,
"end_line": 174,
"start_col": 0,
"start_line": 173
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50"
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false
let cswap_xmms_modified = fun _ -> false
[@__reduce__]
let cswap_lemma'
(code:V.va_code)
(_win:bool)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
cswap_pre code bit p0 p1 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\
ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f)
(* Prove that cswap_lemma' has the required type *)
let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
let code_cswap = FU.va_code_Cswap2 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the cswap wrapper *)
[@__reduce__]
let lowstar_cswap_t =
assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
cswap_regs_modified
cswap_xmms_modified
code_cswap
cswap_dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
(* And here's the cswap wrapper itself *)
let lowstar_cswap : lowstar_cswap_t =
assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
cswap_regs_modified
cswap_xmms_modified
code_cswap
cswap_dom
(W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
let lowstar_cswap_normal_t : normal lowstar_cswap_t
= as_normal_t #lowstar_cswap_t lowstar_cswap
open Vale.AsLowStar.MemoryHelpers
let cswap2 bit p0 p1
= DV.length_eq (get_downview p0);
DV.length_eq (get_downview p1);
let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in
()
let cswap_comments : list string =
["Computes p1 <- bit ? p2 : p1 in constant time"]
let cswap_names (n:nat) : string =
match n with
| 0 -> "bit"
| 1 -> "p1"
| 2 -> "p2"
| _ -> "" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | _: Prims.unit -> FStar.All.ML Prims.int | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"Vale.X64.Print_Inline_s.print_inline",
"FStar.Pervasives.Native.None",
"Prims.string",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Vale.Inline.X64.Fswap_inline.cswap_dom",
"Vale.Inline.X64.Fswap_inline.cswap_names",
"Vale.Inline.X64.Fswap_inline.code_cswap",
"Vale.Inline.X64.Fswap_inline.of_arg",
"Vale.Inline.X64.Fswap_inline.cswap_regs_modified",
"Vale.Inline.X64.Fswap_inline.cswap_comments",
"Prims.int"
] | [] | false | true | false | false | false | let cswap2_code_inline () : FStar.All.ML int =
| PR.print_inline "cswap2" 0 None (List.length cswap_dom) cswap_dom cswap_names code_cswap of_arg
cswap_regs_modified cswap_comments | false |
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.with_localarray_body_post_body | val with_localarray_body_post_body (post a arr: term) : term | val with_localarray_body_post_body (post a arr: term) : term | let with_localarray_body_post_body (post:term) (a:term) (arr:term) : term =
// exists_ (A.pts_to arr full_perm)
let exists_tm =
mk_exists uzero (mk_seq uzero a)
(mk_abs (mk_seq uzero a) Q_Explicit
(mk_array_pts_to a arr full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 406,
"start_col": 0,
"start_line": 400
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*)
let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ]
let elim_exists_post (u:universe) (a:term) (p:term) (x:var) =
let erased_a = mk_erased u a in
mk_abs erased_a Q_Explicit (elim_exists_post_body u a p x)
val elim_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_elim_exists u a p)
(mk_stt_ghost_comp
u
(mk_erased u a)
(mk_exists u a p)
(elim_exists_post u a p x)))
(*
g |- a : Type u
g |- p : a -> vprop
g |- e : vprop
-------------------------------------------------------------------------
g |- intro_exists<u> #a p e : stt_ghost<0> unit empty (p e) (fun _ -> exists_ p)
*)
val intro_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#e:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
(e_typing:RT.ghost_typing g e a)
: GTot (RT.tot_typing g
(mk_intro_exists u a p e)
(mk_stt_ghost_comp uzero unit_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists u a p))))
(*
g |- a : Type u
g |- p : vprop
g |- q : a -> vprop
------------------------------------------
g |- stt_admit a p q : stt a p q
*)
val stt_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_admit u a p q)
(mk_stt_comp u a p q))
val stt_atomic_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_admit u a p q)
(mk_stt_atomic_comp neutral_fv u a emp_inames_tm p q))
val stt_ghost_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_admit u a p q)
(mk_stt_ghost_comp u a p q))
val rewrite_typing
(#g:env)
(#p:term)
(#q:term)
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q vprop_tm)
(equiv:RT.tot_typing g (`()) (stt_vprop_equiv p q))
: GTot (RT.tot_typing g
(mk_rewrite p q)
(mk_stt_ghost_comp
uzero
unit_tm
p
(mk_abs unit_tm Q_Explicit q)))
// mk_star pre (mk_pts_to a (RT.bound_var 0) full_perm_tm init
let with_local_body_pre (pre:term) (a:term) (x:term) (init:term) : term =
let pts_to : term =
mk_pts_to a x full_perm_tm init in
mk_star pre pts_to
//
// post has 0 db index free
//
let with_local_body_post_body (post:term) (a:term) (x:term) : term =
// exists_ (R.pts_to r full_perm)
let exists_tm =
mk_exists (pack_universe Uv_Zero) a
(mk_abs a Q_Explicit
(mk_pts_to a x full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm
let with_local_body_post (post:term) (a:term) (ret_t:term) (x:term) : term =
mk_abs ret_t Q_Explicit (with_local_body_post_body post a x)
val with_local_typing
(#g:env)
(#u:universe)
(#a:term)
(#init:term)
(#pre:term)
(#ret_t:term)
(#post:term) // post has db 0 free
(#body:term) // body has x free
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type (pack_universe Uv_Zero))))
(init_typing:RT.tot_typing g init a)
(pre_typing:RT.tot_typing g pre vprop_tm)
(ret_t_typing:RT.tot_typing g ret_t (pack_ln (Tv_Type u)))
(post_typing:RT.tot_typing g (RT.mk_abs ret_t Q_Explicit post)
(mk_arrow (ret_t, Q_Explicit) vprop_tm))
(body_typing:RT.tot_typing (RT.extend_env g x (mk_ref a))
body
(mk_stt_comp u ret_t
(with_local_body_pre pre a (RT.var_as_term x) init)
(with_local_body_post post a ret_t (RT.var_as_term x))))
: GTot (RT.tot_typing g (mk_withlocal u a init pre ret_t (RT.mk_abs ret_t Q_Explicit post)
(RT.mk_abs (mk_ref a) Q_Explicit (RT.close_term body x)))
(mk_stt_comp u ret_t pre (mk_abs ret_t Q_Explicit post)))
let with_localarray_body_pre (pre:term) (a:term) (arr:term) (init:term) (len:term) : term =
let pts_to : term =
mk_array_pts_to a arr full_perm_tm (mk_seq_create uzero a (mk_szv len) init) in
let len_vp : term =
mk_pure (mk_eq2 uzero nat_tm (mk_array_length a arr) (mk_szv len)) in
mk_star pre (mk_star pts_to len_vp)
//
// post has 0 db index free | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
post: FStar.Stubs.Reflection.Types.term ->
a: FStar.Stubs.Reflection.Types.term ->
arr: FStar.Stubs.Reflection.Types.term
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.term",
"Pulse.Reflection.Util.mk_star",
"Pulse.Reflection.Util.mk_exists",
"Pulse.Reflection.Util.uzero",
"Pulse.Reflection.Util.mk_seq",
"Pulse.Reflection.Util.mk_abs",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Pulse.Reflection.Util.mk_array_pts_to",
"Pulse.Reflection.Util.full_perm_tm",
"FStar.Reflection.Typing.bound_var"
] | [] | false | false | false | true | false | let with_localarray_body_post_body (post a arr: term) : term =
| let exists_tm =
mk_exists uzero
(mk_seq uzero a)
(mk_abs (mk_seq uzero a) Q_Explicit (mk_array_pts_to a arr full_perm_tm (RT.bound_var 0)))
in
mk_star post exists_tm | false |
Pulse.Steel.Wrapper.Typing.fsti | Pulse.Steel.Wrapper.Typing.with_local_body_post_body | val with_local_body_post_body (post a x: term) : term | val with_local_body_post_body (post a x: term) : term | let with_local_body_post_body (post:term) (a:term) (x:term) : term =
// exists_ (R.pts_to r full_perm)
let exists_tm =
mk_exists (pack_universe Uv_Zero) a
(mk_abs a Q_Explicit
(mk_pts_to a x full_perm_tm (RT.bound_var 0))) in
mk_star post exists_tm | {
"file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 359,
"start_col": 0,
"start_line": 353
} | (*
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.Steel.Wrapper.Typing
open FStar.Reflection.V2
open Pulse.Reflection.Util
module RT = FStar.Reflection.Typing
let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let eq2_tm = mk_eq2 u a x_tm e in
let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in
let star_tm = mk_star p_app_x (mk_pure eq2_tm) in
mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return u a e p)
(return_stt_comp u a e p x))
let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_return_noeq u a x p)
(return_stt_noeq_comp u a x p))
let neutral_fv = pack_ln (Tv_FVar (pack_fv neutral_lid))
let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_atomic_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.tot_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return u a e p)
(return_stt_atomic_comp u a e p x))
let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_atomic_comp neutral_fv u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_atomic_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.tot_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_return_noeq u a x p)
(return_stt_atomic_noeq_comp u a x p))
let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term =
mk_stt_ghost_comp u a
(pack_ln (Tv_App p (e, Q_Explicit)))
(return_post_with_eq u a e p x)
val return_stt_ghost_typing
(#g:env)
(#u:universe)
(#a:term)
(#e:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(e_typing:RT.ghost_typing g e a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return u a e p)
(return_stt_ghost_comp u a e p x))
let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term =
mk_stt_ghost_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p
val return_stt_ghost_noeq_typing
(#g:env)
(#u:universe)
(#a:term)
(#x:term)
(#p:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(x_typing:RT.ghost_typing g x a)
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_return_noeq u a x p)
(return_stt_ghost_noeq_comp u a x p))
(*
g |- inv : bool -> vprop
g |- cond : stt<0> bool (exists_ inv) inv
g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv)
-------------------------------------------------------------------------
g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false)
*)
val while_typing
(#g:env)
(#inv:term)
(#cond:term)
(#body:term)
(inv_typing:RT.tot_typing g
inv
(mk_arrow (bool_tm, Q_Explicit) vprop_tm))
(cond_typing:RT.tot_typing g
cond
(mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv))
(body_typing:RT.tot_typing g
body
(mk_stt_comp uzero unit_tm
(pack_ln (Tv_App inv (true_tm, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv))))
: RT.tot_typing g
(mk_while inv cond body)
(mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv)
(mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
let par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term =
let x_tm = RT.var_as_term x in
let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in
let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in
let post = mk_star postL postR in
RT.subst_term post [ RT.ND x 0 ]
val par_typing
(#g:env)
(#u:universe)
(#aL #aR:term)
(#preL #postL:term)
(#preR #postR:term)
(#eL #eR:term)
(x:var{None? (RT.lookup_bvar g x)})
(aL_typing:RT.tot_typing g aL (pack_ln (Tv_Type u)))
(aR_typing:RT.tot_typing g aR (pack_ln (Tv_Type u)))
(preL_typing:RT.tot_typing g preL vprop_tm)
(postL_typing:RT.tot_typing g postL (mk_arrow (aL, Q_Explicit) vprop_tm))
(preR_typing:RT.tot_typing g preR vprop_tm)
(postR_typing:RT.tot_typing g postR (mk_arrow (aR, Q_Explicit) vprop_tm))
(eL_typing:RT.tot_typing g eL (mk_stt_comp u aL preL postL))
(eR_typing:RT.tot_typing g eR (mk_stt_comp u aR preR postR))
: GTot (RT.tot_typing g
(mk_par u aL aR preL postL preR postR eL eR)
(mk_stt_comp u (mk_tuple2 u u aL aR)
(mk_star preL preR)
(mk_abs (mk_tuple2 u u aL aR) Q_Explicit (par_post u aL aR postL postR x))))
val exists_inversion
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(e_typing:RT.tot_typing g
(mk_exists u a p)
vprop_tm)
: GTot (RT.tot_typing g
p
(mk_arrow (a, Q_Explicit) vprop_tm))
(*
g |- a : Type u
g |- p : a -> vprop
----------------------------------------------------------------
g |- elim_exists<u> #a p : stt_ghost<u> a empty (exists_<u> p) (fun x -> p (reveal x))
*)
let elim_exists_post_body (u:universe) (a:term) (p:term) (x:var) =
let x_tm = RT.var_as_term x in
let reveal_x = mk_reveal u a x_tm in
let post = pack_ln (Tv_App p (reveal_x, Q_Explicit)) in
RT.subst_term post [ RT.ND x 0 ]
let elim_exists_post (u:universe) (a:term) (p:term) (x:var) =
let erased_a = mk_erased u a in
mk_abs erased_a Q_Explicit (elim_exists_post_body u a p x)
val elim_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(x:var{None? (RT.lookup_bvar g x)})
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_elim_exists u a p)
(mk_stt_ghost_comp
u
(mk_erased u a)
(mk_exists u a p)
(elim_exists_post u a p x)))
(*
g |- a : Type u
g |- p : a -> vprop
g |- e : vprop
-------------------------------------------------------------------------
g |- intro_exists<u> #a p e : stt_ghost<0> unit empty (p e) (fun _ -> exists_ p)
*)
val intro_exists_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#e:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm))
(e_typing:RT.ghost_typing g e a)
: GTot (RT.tot_typing g
(mk_intro_exists u a p e)
(mk_stt_ghost_comp uzero unit_tm
(pack_ln (Tv_App p (e, Q_Explicit)))
(mk_abs unit_tm Q_Explicit (mk_exists u a p))))
(*
g |- a : Type u
g |- p : vprop
g |- q : a -> vprop
------------------------------------------
g |- stt_admit a p q : stt a p q
*)
val stt_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_admit u a p q)
(mk_stt_comp u a p q))
val stt_atomic_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_atomic_admit u a p q)
(mk_stt_atomic_comp neutral_fv u a emp_inames_tm p q))
val stt_ghost_admit_typing
(#g:env)
(#u:universe)
(#a:term)
(#p:term)
(#q:term)
(a_typing:RT.tot_typing g a (pack_ln (Tv_Type u)))
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q (mk_arrow (a, Q_Explicit) vprop_tm))
: GTot (RT.tot_typing g
(mk_stt_ghost_admit u a p q)
(mk_stt_ghost_comp u a p q))
val rewrite_typing
(#g:env)
(#p:term)
(#q:term)
(p_typing:RT.tot_typing g p vprop_tm)
(q_typing:RT.tot_typing g q vprop_tm)
(equiv:RT.tot_typing g (`()) (stt_vprop_equiv p q))
: GTot (RT.tot_typing g
(mk_rewrite p q)
(mk_stt_ghost_comp
uzero
unit_tm
p
(mk_abs unit_tm Q_Explicit q)))
// mk_star pre (mk_pts_to a (RT.bound_var 0) full_perm_tm init
let with_local_body_pre (pre:term) (a:term) (x:term) (init:term) : term =
let pts_to : term =
mk_pts_to a x full_perm_tm init in
mk_star pre pts_to
//
// post has 0 db index free | {
"checked_file": "/",
"dependencies": [
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Steel.Wrapper.Typing.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Steel.Wrapper",
"short_module": null
},
{
"abbrev": 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 |
post: FStar.Stubs.Reflection.Types.term ->
a: FStar.Stubs.Reflection.Types.term ->
x: FStar.Stubs.Reflection.Types.term
-> FStar.Stubs.Reflection.Types.term | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.term",
"Pulse.Reflection.Util.mk_star",
"Pulse.Reflection.Util.mk_exists",
"FStar.Stubs.Reflection.V2.Builtins.pack_universe",
"FStar.Stubs.Reflection.V2.Data.Uv_Zero",
"Pulse.Reflection.Util.mk_abs",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Pulse.Reflection.Util.mk_pts_to",
"Pulse.Reflection.Util.full_perm_tm",
"FStar.Reflection.Typing.bound_var"
] | [] | false | false | false | true | false | let with_local_body_post_body (post a x: term) : term =
| let exists_tm =
mk_exists (pack_universe Uv_Zero)
a
(mk_abs a Q_Explicit (mk_pts_to a x full_perm_tm (RT.bound_var 0)))
in
mk_star post exists_tm | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_pre | val cswap_pre:VSig.vale_pre cswap_dom | val cswap_pre:VSig.vale_pre cswap_dom | let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 55,
"start_col": 0,
"start_line": 48
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] 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.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_pre Vale.Inline.X64.Fswap_inline.cswap_dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Inline.X64.Fswap_inline.uint64",
"Vale.Inline.X64.Fswap_inline.b64",
"Vale.X64.Decls.va_state",
"Vale.Curve25519.X64.FastUtil.va_req_Cswap2",
"FStar.UInt64.v",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.prop"
] | [] | false | false | false | true | false | let cswap_pre:VSig.vale_pre cswap_dom =
| fun (c: V.va_code) (bit: uint64) (p0: b64) (p1: b64) (va_s0: V.va_state) ->
FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.lowstar_cswap | val lowstar_cswap:lowstar_cswap_t | val lowstar_cswap:lowstar_cswap_t | let lowstar_cswap : lowstar_cswap_t =
assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
cswap_regs_modified
cswap_xmms_modified
code_cswap
cswap_dom
(W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 150,
"start_col": 0,
"start_line": 141
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50"
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false
let cswap_xmms_modified = fun _ -> false
[@__reduce__]
let cswap_lemma'
(code:V.va_code)
(_win:bool)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
cswap_pre code bit p0 p1 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\
ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f)
(* Prove that cswap_lemma' has the required type *)
let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
let code_cswap = FU.va_code_Cswap2 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the cswap wrapper *)
[@__reduce__]
let lowstar_cswap_t =
assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
cswap_regs_modified
cswap_xmms_modified
code_cswap
cswap_dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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.Inline.X64.Fswap_inline.lowstar_cswap_t | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.X64.wrap_weak",
"Vale.Inline.X64.Fswap_inline.arg_reg",
"Vale.Inline.X64.Fswap_inline.cswap_regs_modified",
"Vale.Inline.X64.Fswap_inline.cswap_xmms_modified",
"Vale.X64.Machine_s.reg_xmm",
"Vale.Inline.X64.Fswap_inline.code_cswap",
"Vale.Inline.X64.Fswap_inline.cswap_dom",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.Inline.X64.Fswap_inline.cswap_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Inline.X64.Fswap_inline.cswap_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Inline.X64.Fswap_inline.cswap_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 | false | let lowstar_cswap:lowstar_cswap_t =
| assert_norm (List.length cswap_dom + List.length ([] <: list arg) <= 3);
IX64.wrap_weak 3
arg_reg
cswap_regs_modified
cswap_xmms_modified
code_cswap
cswap_dom
(W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.arg_reg | val arg_reg:IX64.arg_reg_relation 3 | val arg_reg:IX64.arg_reg_relation 3 | let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 121,
"start_col": 0,
"start_line": 121
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50"
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false
let cswap_xmms_modified = fun _ -> false
[@__reduce__]
let cswap_lemma'
(code:V.va_code)
(_win:bool)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
cswap_pre code bit p0 p1 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\
ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f)
(* Prove that cswap_lemma' has the required type *)
let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
let code_cswap = FU.va_code_Cswap2 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | v:
Vale.Interop.X64.arg_reg_relation' 3
{ forall (r: Vale.X64.Machine_s.reg_64). {:pattern Rel?.of_reg v r}
Some? (Rel?.of_reg v r) ==> Rel?.of_arg v (Some?.v (Rel?.of_reg v r)) = r } | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.X64.Rel",
"Vale.Inline.X64.Fswap_inline.of_reg",
"Vale.Inline.X64.Fswap_inline.of_arg"
] | [] | false | false | false | false | false | let arg_reg:IX64.arg_reg_relation 3 =
| IX64.Rel of_reg of_arg | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold | val bn_exp_mont_vartime_threshold : Prims.int | let bn_exp_mont_vartime_threshold = 200 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 96,
"start_col": 0,
"start_line": 96
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime) | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let bn_exp_mont_vartime_threshold =
| 200 | false |
|
QuickSort.Array.fst | QuickSort.Array.qsort | val qsort: #a:eqtype -> f:tot_ord a -> x:array a -> ST unit
(requires (fun h -> Array.contains h x))
(ensures (fun h0 u h1 -> modifies (Array.only x) h0 h1
/\ Array.contains h1 x /\ sorted f (Array.sel h1 x) /\ permutation a (Array.sel h0 x) (Array.sel h1 x))) | val qsort: #a:eqtype -> f:tot_ord a -> x:array a -> ST unit
(requires (fun h -> Array.contains h x))
(ensures (fun h0 u h1 -> modifies (Array.only x) h0 h1
/\ Array.contains h1 x /\ sorted f (Array.sel h1 x) /\ permutation a (Array.sel h0 x) (Array.sel h1 x))) | let qsort #a f x =
let h0 = get() in
let len = Array.length x in
sort f 0 len x;
let h1 = get() in
cut (Seq.equal (Array.sel h0 x) (slice (Array.sel h0 x) 0 len));
cut (Seq.equal (Array.sel h1 x) (slice (Array.sel h1 x) 0 len)) | {
"file_name": "examples/algorithms/QuickSort.Array.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 65,
"end_line": 203,
"start_col": 0,
"start_line": 195
} | (*
Copyright 2008-2014 Nikhil Swamy and 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 QuickSort.Array
open FStar.Array
open FStar.Seq
open FStar.Heap
open FStar.ST
#set-options "--initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
(* 2016-11-22: Due to the QuickSort namespace being opened *after* the
FStar namespace,Array resolves to QuickSort.Array instead of
FStar.Array, so we have to fix this explicitly as a module abbrev. *)
module Array = FStar.Array
module Seq = FStar.Seq
type partition_inv (a:eqtype) (f:tot_ord a) (lo:seq a) (pv:a) (hi:seq a) =
((length hi) >= 0)
/\ (forall y. (mem y hi ==> f pv y) /\ (mem y lo ==> f y pv))
type partition_pre (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h:heap) =
(Array.contains h x
/\ ((let s = Array.sel h x in (len <= length s) /\ (partition_inv a f
(slice s start pivot)
(index s pivot)
(slice s (back + 1) len)))
))
type partition_post (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h0:heap) (i:nat) (h1:heap) =
(len <= length (Array.sel h0 x)
/\ Array.contains h1 x
/\ start <= i
/\ i < len
/\ (length (Array.sel h1 x) = length (Array.sel h0 x))
/\ (Array.sel h1 x == splice (Array.sel h0 x) start (Array.sel h1 x) len)
/\ (permutation a (slice (Array.sel h0 x) start len) (slice (Array.sel h1 x) start len))
/\ (partition_inv a f
(slice (Array.sel h1 x) start i)
(index (Array.sel h1 x) i)
(slice (Array.sel h1 x) i len)))
#reset-options "--z3rlimit 20 --initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
val partition: #a:eqtype -> f:tot_ord a
-> start:nat -> len:nat{start <= len}
-> pivot:nat{start <= pivot /\ pivot < len}
-> back:nat{pivot <= back /\ back < len}
-> x:array a -> ST nat
(requires (partition_pre a f start len pivot back x))
(ensures (fun h0 n h1 -> partition_post a f start len pivot back x h0 n h1 /\ modifies (Array.only x) h0 h1))
let rec partition #a f start len pivot back x =
let h0 = get() in
if pivot = back
then
begin
(*ghost*) (let s = Array.sel h0 x in
(*ghost*) lemma_slice_cons s pivot len;
(*ghost*) splice_refl s start len);
pivot
end
else
begin
let next = Array.index x (pivot + 1) in
let p = Array.index x pivot in
if f next p
then
begin
Array.swap x pivot (pivot + 1); (* the pivot moves forward *)
let h1 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) swap_frame_lo s start pivot (pivot + 1);
(* ghost *) swap_frame_hi s pivot (pivot + 1) (back + 1) len;
assume (pivot < length s');
//lemma_swap_splice s start (pivot + 1) back len;
(* need pivot < length s',
but only have pivot < length s *)
(* ghost *) lemma_ordering_lo_snoc f s' start pivot p in
let res = partition f start len (pivot + 1) back x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
else
begin
Array.swap x (pivot + 1) back; (* the back moves backward *)
let h1 = get () in
// (* ghost *) let s = Array.sel h0 x in
// (* ghost *) let s' = Array.sel h1 x in
// (* ghost *) swap_frame_lo' s start pivot (pivot + 1) back;
// (* ghost *) swap_frame_hi s (pivot + 1) back (back + 1) len;
// (* ghost *) lemma_ordering_hi_cons f s' back len p in
let res = partition f start len pivot (back - 1) x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start (pivot + 1) back len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start (pivot + 1) back len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
end
#reset-options
val lemma_slice_cons_pv: #a:Type -> s:seq a -> i:nat -> pivot:nat{i <= pivot} -> j:nat{pivot < j && j <= length s} -> pv:a
-> Lemma
(requires (pv == index s pivot))
(ensures (slice s i j == append (slice s i pivot) (cons pv (slice s (pivot + 1) j))))
let lemma_slice_cons_pv #a s i pivot j pv =
let lo = slice s i pivot in
let hi = slice s (pivot + 1) j in
cut (Seq.equal (slice s i j) (append lo (cons pv hi)))
#reset-options
#set-options "--initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0 --z3rlimit 50"
val sort: #a:eqtype -> f:tot_ord a -> i:nat -> j:nat{i <= j} -> x:array a
-> ST unit
(requires (fun h -> Array.contains h x /\ j <= length (Array.sel h x)))
(ensures (fun h0 u h1 -> (modifies (Array.only x) h0 h1
/\ j <= length (Array.sel h0 x) (* carrying this along from the requires clause *)
/\ Array.contains h1 x (* the array is still in the heap *)
/\ (length (Array.sel h0 x) = length (Array.sel h1 x)) (* its length has not changed *)
/\ sorted f (slice (Array.sel h1 x) i j) (* it is sorted between [i, j) *)
/\ (Array.sel h1 x == splice (Array.sel h0 x) i (Array.sel h1 x) j) (* the rest of it is unchanged *)
/\ permutation a (slice (Array.sel h0 x) i j) (slice (Array.sel h1 x) i j)))) (* the [i,j) sub-array is a permutation of the original one *)
let rec sort #a f i j x =
let h0 = ST.get () in
if i=j
then splice_refl (Array.sel h0 x) i j
else begin
let pivot = partition f i j i (j - 1) x in
(* ghost *) let h1 = get() in
sort f i pivot x;
(* ghost *) let h2 = get() in
let _ =
(* ghost *) lemma_seq_frame_hi (Array.sel h2 x) (Array.sel h1 x) i pivot pivot j;
(* ghost *) lemma_tail_slice (Array.sel h2 x) pivot j in
sort f (pivot + 1) j x;
(* ghost *) let h3 = get() in
(* ghost *) lemma_seq_frame_lo (Array.sel h3 x) (Array.sel h2 x) i pivot (pivot + 1) j;
(* ghost *) let lo = slice (Array.sel h3 x) i pivot in
(* ghost *) let hi = slice (Array.sel h3 x) (pivot + 1) j in
(* ghost *) let pv = index (Array.sel h1 x) pivot in
(* ghost *) Seq.sorted_concat_lemma f lo pv hi;
(* ghost *) lemma_slice_cons_pv (Array.sel h3 x) i pivot j pv;
(* ghost *) lemma_weaken_frame_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
(* ghost *) lemma_weaken_frame_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j;
(* ghost *) lemma_trans_frame (Array.sel h3 x) (Array.sel h2 x) (Array.sel h1 x) i j;
(* ghost *) lemma_trans_frame (Array.sel h3 x) (Array.sel h1 x) (Array.sel h0 x) i j;
(* ghost *) lemma_weaken_perm_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
(* ghost *) lemma_weaken_perm_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j
end
val qsort: #a:eqtype -> f:tot_ord a -> x:array a -> ST unit
(requires (fun h -> Array.contains h x))
(ensures (fun h0 u h1 -> modifies (Array.only x) h0 h1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked",
"FStar.Array.fsti.checked"
],
"interface_file": false,
"source_file": "QuickSort.Array.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Array",
"short_module": "Array"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: FStar.Seq.Properties.tot_ord a -> x: FStar.Array.array a -> FStar.ST.ST Prims.unit | FStar.ST.ST | [] | [] | [
"Prims.eqtype",
"FStar.Seq.Properties.tot_ord",
"FStar.Array.array",
"Prims.cut",
"FStar.Seq.Base.equal",
"FStar.Array.sel",
"FStar.Seq.Base.slice",
"Prims.unit",
"FStar.Monotonic.Heap.heap",
"FStar.ST.get",
"QuickSort.Array.sort",
"Prims.nat",
"FStar.Array.length"
] | [] | false | true | false | false | false | let qsort #a f x =
| let h0 = get () in
let len = Array.length x in
sort f 0 len x;
let h1 = get () in
cut (Seq.equal (Array.sel h0 x) (slice (Array.sel h0 x) 0 len));
cut (Seq.equal (Array.sel h1 x) (slice (Array.sel h1 x) 0 len)) | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold | val bn_exp_mont_consttime_threshold : Prims.int | let bn_exp_mont_consttime_threshold = 200 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 99,
"start_col": 0,
"start_line": 99
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200 | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let bn_exp_mont_consttime_threshold =
| 200 | false |
|
QuickSort.Array.fst | QuickSort.Array.lemma_slice_cons_pv | val lemma_slice_cons_pv: #a:Type -> s:seq a -> i:nat -> pivot:nat{i <= pivot} -> j:nat{pivot < j && j <= length s} -> pv:a
-> Lemma
(requires (pv == index s pivot))
(ensures (slice s i j == append (slice s i pivot) (cons pv (slice s (pivot + 1) j)))) | val lemma_slice_cons_pv: #a:Type -> s:seq a -> i:nat -> pivot:nat{i <= pivot} -> j:nat{pivot < j && j <= length s} -> pv:a
-> Lemma
(requires (pv == index s pivot))
(ensures (slice s i j == append (slice s i pivot) (cons pv (slice s (pivot + 1) j)))) | let lemma_slice_cons_pv #a s i pivot j pv =
let lo = slice s i pivot in
let hi = slice s (pivot + 1) j in
cut (Seq.equal (slice s i j) (append lo (cons pv hi))) | {
"file_name": "examples/algorithms/QuickSort.Array.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 141,
"start_col": 0,
"start_line": 138
} | (*
Copyright 2008-2014 Nikhil Swamy and 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 QuickSort.Array
open FStar.Array
open FStar.Seq
open FStar.Heap
open FStar.ST
#set-options "--initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
(* 2016-11-22: Due to the QuickSort namespace being opened *after* the
FStar namespace,Array resolves to QuickSort.Array instead of
FStar.Array, so we have to fix this explicitly as a module abbrev. *)
module Array = FStar.Array
module Seq = FStar.Seq
type partition_inv (a:eqtype) (f:tot_ord a) (lo:seq a) (pv:a) (hi:seq a) =
((length hi) >= 0)
/\ (forall y. (mem y hi ==> f pv y) /\ (mem y lo ==> f y pv))
type partition_pre (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h:heap) =
(Array.contains h x
/\ ((let s = Array.sel h x in (len <= length s) /\ (partition_inv a f
(slice s start pivot)
(index s pivot)
(slice s (back + 1) len)))
))
type partition_post (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h0:heap) (i:nat) (h1:heap) =
(len <= length (Array.sel h0 x)
/\ Array.contains h1 x
/\ start <= i
/\ i < len
/\ (length (Array.sel h1 x) = length (Array.sel h0 x))
/\ (Array.sel h1 x == splice (Array.sel h0 x) start (Array.sel h1 x) len)
/\ (permutation a (slice (Array.sel h0 x) start len) (slice (Array.sel h1 x) start len))
/\ (partition_inv a f
(slice (Array.sel h1 x) start i)
(index (Array.sel h1 x) i)
(slice (Array.sel h1 x) i len)))
#reset-options "--z3rlimit 20 --initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
val partition: #a:eqtype -> f:tot_ord a
-> start:nat -> len:nat{start <= len}
-> pivot:nat{start <= pivot /\ pivot < len}
-> back:nat{pivot <= back /\ back < len}
-> x:array a -> ST nat
(requires (partition_pre a f start len pivot back x))
(ensures (fun h0 n h1 -> partition_post a f start len pivot back x h0 n h1 /\ modifies (Array.only x) h0 h1))
let rec partition #a f start len pivot back x =
let h0 = get() in
if pivot = back
then
begin
(*ghost*) (let s = Array.sel h0 x in
(*ghost*) lemma_slice_cons s pivot len;
(*ghost*) splice_refl s start len);
pivot
end
else
begin
let next = Array.index x (pivot + 1) in
let p = Array.index x pivot in
if f next p
then
begin
Array.swap x pivot (pivot + 1); (* the pivot moves forward *)
let h1 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) swap_frame_lo s start pivot (pivot + 1);
(* ghost *) swap_frame_hi s pivot (pivot + 1) (back + 1) len;
assume (pivot < length s');
//lemma_swap_splice s start (pivot + 1) back len;
(* need pivot < length s',
but only have pivot < length s *)
(* ghost *) lemma_ordering_lo_snoc f s' start pivot p in
let res = partition f start len (pivot + 1) back x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
else
begin
Array.swap x (pivot + 1) back; (* the back moves backward *)
let h1 = get () in
// (* ghost *) let s = Array.sel h0 x in
// (* ghost *) let s' = Array.sel h1 x in
// (* ghost *) swap_frame_lo' s start pivot (pivot + 1) back;
// (* ghost *) swap_frame_hi s (pivot + 1) back (back + 1) len;
// (* ghost *) lemma_ordering_hi_cons f s' back len p in
let res = partition f start len pivot (back - 1) x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start (pivot + 1) back len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start (pivot + 1) back len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
end
#reset-options
val lemma_slice_cons_pv: #a:Type -> s:seq a -> i:nat -> pivot:nat{i <= pivot} -> j:nat{pivot < j && j <= length s} -> pv:a
-> Lemma
(requires (pv == index s pivot)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked",
"FStar.Array.fsti.checked"
],
"interface_file": false,
"source_file": "QuickSort.Array.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Array",
"short_module": "Array"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": 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: FStar.Seq.Base.seq a ->
i: Prims.nat ->
pivot: Prims.nat{i <= pivot} ->
j: Prims.nat{pivot < j && j <= FStar.Seq.Base.length s} ->
pv: a
-> FStar.Pervasives.Lemma (requires pv == FStar.Seq.Base.index s pivot)
(ensures
FStar.Seq.Base.slice s i j ==
FStar.Seq.Base.append (FStar.Seq.Base.slice s i pivot)
(FStar.Seq.Base.cons pv (FStar.Seq.Base.slice s (pivot + 1) j))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Prims.cut",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.append",
"FStar.Seq.Base.cons",
"Prims.op_Addition",
"Prims.unit"
] | [] | true | false | true | false | false | let lemma_slice_cons_pv #a s i pivot j pv =
| let lo = slice s i pivot in
let hi = slice s (pivot + 1) j in
cut (Seq.equal (slice s i j) (append lo (cons pv hi))) | false |
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.cond | val cond : Benton2004.exp Prims.bool | let cond = eop op_LessThan (evar i) (evar n) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 25,
"start_col": 0,
"start_line": 25
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | Benton2004.exp Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Benton2004.eop",
"Prims.int",
"Prims.bool",
"Prims.op_LessThan",
"Benton2004.evar",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Examples2.n"
] | [] | false | false | false | true | false | let cond =
| eop op_LessThan (evar i) (evar n) | false |
|
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_lemma | val cswap_lemma : Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fswap_inline.cswap_regs_modified
Vale.Inline.X64.Fswap_inline.cswap_xmms_modified
Vale.Inline.X64.Fswap_inline.cswap_pre
Vale.Inline.X64.Fswap_inline.cswap_post | let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 113,
"end_line": 106,
"start_col": 0,
"start_line": 106
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50"
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false
let cswap_xmms_modified = fun _ -> false
[@__reduce__]
let cswap_lemma'
(code:V.va_code)
(_win:bool)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
cswap_pre code bit p0 p1 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\
ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 Vale.Inline.X64.Fswap_inline.cswap_regs_modified
Vale.Inline.X64.Fswap_inline.cswap_xmms_modified
Vale.Inline.X64.Fswap_inline.cswap_pre
Vale.Inline.X64.Fswap_inline.cswap_post | Prims.Tot | [
"total"
] | [] | [
"Vale.Inline.X64.Fswap_inline.as_t",
"Vale.AsLowStar.ValeSig.vale_sig",
"Vale.Inline.X64.Fswap_inline.cswap_dom",
"Vale.Inline.X64.Fswap_inline.cswap_regs_modified",
"Vale.Inline.X64.Fswap_inline.cswap_xmms_modified",
"Vale.X64.Machine_s.reg_xmm",
"Vale.Inline.X64.Fswap_inline.cswap_pre",
"Vale.Inline.X64.Fswap_inline.cswap_post",
"Vale.Inline.X64.Fswap_inline.cswap_lemma'"
] | [] | false | false | false | true | false | let cswap_lemma =
| as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' | false |
|
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.asx_e | val asx_e : Benton2004.exp Prims.int | let asx_e = eop op_Addition (evar y) (const 1) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | Benton2004.exp Prims.int | Prims.Tot | [
"total"
] | [] | [
"Benton2004.eop",
"Prims.int",
"Prims.op_Addition",
"Benton2004.evar",
"Benton2004.RHL.Examples2.y",
"Benton2004.const"
] | [] | false | false | false | true | false | let asx_e =
| eop op_Addition (evar y) (const 1) | false |
|
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.asi_e | val asi_e : Benton2004.exp Prims.int | let asi_e = eop op_Addition (evar i) (evar x) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true)
let cond = eop op_LessThan (evar i) (evar n) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | Benton2004.exp Prims.int | Prims.Tot | [
"total"
] | [] | [
"Benton2004.eop",
"Prims.int",
"Prims.op_Addition",
"Benton2004.evar",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Examples2.x"
] | [] | false | false | false | true | false | let asi_e =
| eop op_Addition (evar i) (evar x) | false |
|
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.l | val l : Benton2004.computation | let l = while cond (seq (assign x asx_e) (assign i asi_e)) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true)
let cond = eop op_LessThan (evar i) (evar n)
let asx_e = eop op_Addition (evar y) (const 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | Benton2004.computation | Prims.Tot | [
"total"
] | [] | [
"Benton2004.while",
"Benton2004.RHL.Examples2.cond",
"Benton2004.seq",
"Benton2004.assign",
"Benton2004.RHL.Examples2.x",
"Benton2004.RHL.Examples2.asx_e",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Examples2.asi_e"
] | [] | false | false | false | true | false | let l =
| while cond (seq (assign x asx_e) (assign i asi_e)) | false |
|
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.r | val r : Benton2004.computation | let r = seq (assign x asx_e) (while cond (assign i asi_e)) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 29,
"start_col": 0,
"start_line": 29
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true)
let cond = eop op_LessThan (evar i) (evar n)
let asx_e = eop op_Addition (evar y) (const 1)
let asi_e = eop op_Addition (evar i) (evar x) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | Benton2004.computation | Prims.Tot | [
"total"
] | [] | [
"Benton2004.seq",
"Benton2004.assign",
"Benton2004.RHL.Examples2.x",
"Benton2004.RHL.Examples2.asx_e",
"Benton2004.while",
"Benton2004.RHL.Examples2.cond",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Examples2.asi_e"
] | [] | false | false | false | true | false | let r =
| seq (assign x asx_e) (while cond (assign i asi_e)) | false |
|
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.phi | val phi: Prims.unit -> GTot (gexp bool) | val phi: Prims.unit -> GTot (gexp bool) | let phi () : GTot (gexp bool) = gand (geq (gvar i Left) (gvar i Right)) (gand (geq (gvar n Left) (gvar n Right)) (geq (gvar y Left) (gvar y Right))) | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 148,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true)
let cond = eop op_LessThan (evar i) (evar n)
let asx_e = eop op_Addition (evar y) (const 1)
let asi_e = eop op_Addition (evar i) (evar x)
let l = while cond (seq (assign x asx_e) (assign i asi_e))
let r = seq (assign x asx_e) (while cond (assign i asi_e)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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 | _: Prims.unit -> Prims.GTot (Benton2004.RHL.gexp Prims.bool) | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.unit",
"Benton2004.RHL.gand",
"Benton2004.RHL.geq",
"Prims.int",
"Benton2004.RHL.gvar",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Left",
"Benton2004.RHL.Right",
"Benton2004.RHL.Examples2.n",
"Benton2004.RHL.Examples2.y",
"Benton2004.RHL.gexp",
"Prims.bool"
] | [] | false | false | false | false | false | let phi () : GTot (gexp bool) =
| gand (geq (gvar i Left) (gvar i Right))
(gand (geq (gvar n Left) (gvar n Right)) (geq (gvar y Left) (gvar y Right))) | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_mont_t | val bn_mont_t : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Type0 | let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n} | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 25,
"start_col": 0,
"start_line": 24
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain! | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v"
] | [] | false | false | false | false | true | let bn_mont_t (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len) =
| x: lbignum t len {bn_v x < bn_v n} | false |
|
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_payload_kind | val parse_deplen_payload_kind : min: Prims.nat -> max: Prims.nat{min <= max} -> k: LowParse.Spec.Base.parser_kind
-> LowParse.Spec.Base.parser_kind | let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 89,
"start_col": 0,
"start_line": 89
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | min: Prims.nat -> max: Prims.nat{min <= max} -> k: LowParse.Spec.Base.parser_kind
-> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.VLGen.parse_bounded_vlgen_payload_kind"
] | [] | false | false | false | false | false | let parse_deplen_payload_kind =
| parse_bounded_vlgen_payload_kind | false |
|
Steel.GhostPCMReference.fst | Steel.GhostPCMReference.recall | val recall (#o: _)
(#a:Type)
(#pcm:pcm a)
(fact:property a)
(r:ref a pcm)
(v:erased a)
(w:witnessed r fact)
: SteelAtomicU (erased a) o
(pts_to r v)
(fun v1 -> pts_to r v)
(requires fun _ -> True)
(ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1) | val recall (#o: _)
(#a:Type)
(#pcm:pcm a)
(fact:property a)
(r:ref a pcm)
(v:erased a)
(w:witnessed r fact)
: SteelAtomicU (erased a) o
(pts_to r v)
(fun v1 -> pts_to r v)
(requires fun _ -> True)
(ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1) | let recall (#o: _)
(#a:Type)
(#pcm:pcm a)
(fact:property a)
(r:ref a pcm)
(v:erased a)
(w:witnessed r fact)
= P.recall fact r v w | {
"file_name": "lib/steel/Steel.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 23,
"end_line": 133,
"start_col": 0,
"start_line": 126
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostPCMReference
(* A ghost variant of Steel.PCMReference *)
open FStar.PCM
open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Mem = Steel.Memory
module P = Steel.PCMReference
let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p)
/// Its selector is non-informative (it is unit)
[@@__reduce__]
let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a)
= to_vprop (Steel.Memory.pts_to r v)
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: SteelGhost
(ref a pcm) o
(emp)
(fun r -> pts_to r x)
(requires fun _ -> pcm.refine x)
(ensures fun _ _ _ -> True)
= rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ());
FStar.PCM.compatible_refl pcm x;
let r = as_atomic_action_ghost (alloc_action o x) in
r
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: SteelGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires fun _ -> True)
(ensures fun _ v _ -> compatible pcm v0 v)
= let v = as_atomic_action_ghost (sel_action o r v0) in
v
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ _ _ -> True)
= as_atomic_action_ghost (upd_action o r v0 v1)
let upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: SteelGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
= as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f)
let share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires fun _ ->
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ _ _ -> True)
= P.split r v v0 v1
let gather (#o:inames)
(#a:Type)
(#p:FStar.PCM.pcm a)
(r:ref a p)
(v0:a)
(v1:a)
: SteelGhostT (_:unit{composable p v0 v1}) o
(pts_to r v0 `star` pts_to r v1)
(fun _ -> pts_to r (op p v0 v1))
= P.gather r v0 v1
let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a)
: Type0
= Steel.Memory.witnessed r fact
let witness (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(fact:Steel.Preorder.stable_property pcm)
(v:erased a)
(_:squash (Steel.Preorder.fact_valid_compat fact v))
= P.witness r fact v () | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostPCMReference.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": 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 |
fact: Steel.Memory.property a ->
r: Steel.GhostPCMReference.ref a pcm ->
v: FStar.Ghost.erased a ->
w: Steel.GhostPCMReference.witnessed r fact
-> Steel.Effect.Atomic.SteelAtomicU (FStar.Ghost.erased a) | Steel.Effect.Atomic.SteelAtomicU | [] | [] | [
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.Memory.property",
"Steel.GhostPCMReference.ref",
"FStar.Ghost.erased",
"Steel.GhostPCMReference.witnessed",
"Steel.PCMReference.recall"
] | [] | false | true | false | false | false | let recall
(#o: _)
(#a: Type)
(#pcm: pcm a)
(fact: property a)
(r: ref a pcm)
(v: erased a)
(w: witnessed r fact)
=
| P.recall fact r v w | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st | val bn_exp_mont_st : t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0 | let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b)) | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 113,
"start_col": 0,
"start_line": 103
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200 | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Prims.l_True",
"Prims.eq2",
"Prims.nat",
"Lib.Exponentiation.Definition.pow",
"Lib.NatMod.nat_mod",
"Lib.Exponentiation.Definition.comm_monoid",
"Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC"
] | [] | false | false | false | false | true | let bn_exp_mont_st (t: limb_t) (len: BN.bn_len t) =
|
n: lbignum t len ->
mu: limb t {BM.bn_mont_pre n mu} ->
aM: bn_mont_t n ->
bBits: size_nat ->
b: lbignum t (blocks0 bBits (bits t)) {bn_v b < pow2 bBits}
-> Pure (bn_mont_t n)
(requires True)
(ensures
fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b)) | false |
|
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_mont_one | val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 51,
"start_col": 0,
"start_line": 47
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.one_st (Hacl.Spec.Bignum.MontExponentiation.bn_mont_t n)
(Hacl.Spec.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Prims.unit",
"Hacl.Spec.Bignum.Montgomery.bn_mont_one",
"Hacl.Spec.Bignum.Montgomery.bn_mont_one_lemma",
"Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n",
"Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n_lemma",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t"
] | [] | false | false | false | false | false | let bn_mont_one #t #len n mu _ =
| BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2 | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_mont_sqr | val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 75,
"start_col": 0,
"start_line": 73
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.sqr_st (Hacl.Spec.Bignum.MontExponentiation.bn_mont_t n)
(Hacl.Spec.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Hacl.Spec.Bignum.Montgomery.bn_mont_sqr",
"Prims.unit",
"Hacl.Spec.Bignum.Montgomery.bn_mont_sqr_lemma"
] | [] | false | false | false | false | false | let bn_mont_sqr #t #len n mu aM =
| BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_mont_mul | val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 63,
"start_col": 0,
"start_line": 61
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu) | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.mul_st (Hacl.Spec.Bignum.MontExponentiation.bn_mont_t n)
(Hacl.Spec.Bignum.MontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Hacl.Spec.Bignum.Montgomery.bn_mont_mul",
"Prims.unit",
"Hacl.Spec.Bignum.Montgomery.bn_mont_mul_lemma"
] | [] | false | false | false | false | false | let bn_mont_mul #t #len n mu aM bM =
| BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM | false |
CalcInference.fst | CalcInference.test2 | val test2: Prims.unit -> squash (2 == 1 + 1) | val test2: Prims.unit -> squash (2 == 1 + 1) | let test2 () : squash (2 == 1 + 1) =
calc (==) {
_;
== { lem () }
1 + 1;
} | {
"file_name": "examples/calc/CalcInference.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 17,
"start_col": 0,
"start_line": 12
} | module CalcInference
let lem () : squash (2 == 1 + 1) = ()
let test1 () : squash (2 == 1 + 1) =
calc (==) {
2;
== { lem () }
_;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "CalcInference.fst"
} | [
{
"abbrev": 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 | _: Prims.unit -> Prims.squash (2 == 1 + 1) | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"CalcInference.lem",
"Prims.squash"
] | [] | false | false | true | false | false | let test2 () : squash (2 == 1 + 1) =
| calc ( == ) {
_;
( == ) { lem () }
1 + 1;
} | false |
Vale.Inline.X64.Fswap_inline.fst | Vale.Inline.X64.Fswap_inline.cswap_lemma' | val cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires cswap_pre code bit p0 p1 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | val cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires cswap_pre code bit p0 p1 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) | let cswap_lemma'
(code:V.va_code)
(_win:bool)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
cswap_pre code bit p0 p1 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\
ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f) | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 103,
"start_col": 0,
"start_line": 78
} | module Vale.Inline.X64.Fswap_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let cswap_dom: IX64.arity_ok 3 td =
let y = [tuint64; t64_mod; t64_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let cswap_pre : VSig.vale_pre cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state) ->
FU.va_req_Cswap2 c va_s0
(UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
[@__reduce__]
let cswap_post : VSig.vale_post cswap_dom =
fun (c:V.va_code)
(bit:uint64)
(p0:b64)
(p1:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
#set-options "--z3rlimit 50"
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true
else false
let cswap_xmms_modified = fun _ -> false | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.FastUtil.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fswap_inline.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 ->
bit: Vale.Inline.X64.Fswap_inline.uint64 ->
p0: Vale.Inline.X64.Fswap_inline.b64 ->
p1: Vale.Inline.X64.Fswap_inline.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.Inline.X64.Fswap_inline.uint64",
"Vale.Inline.X64.Fswap_inline.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.FastUtil.va_lemma_Cswap2",
"FStar.UInt64.v",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Inline.X64.Fswap_inline.cswap_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions",
"Vale.Inline.X64.Fswap_inline.cswap_regs_modified",
"Vale.Inline.X64.Fswap_inline.cswap_xmms_modified",
"Vale.X64.Machine_s.reg_xmm",
"Vale.Inline.X64.Fswap_inline.cswap_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 cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires cswap_pre code bit p0 p1 va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\
cswap_post code bit p0 p1 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\
ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0))
(ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none))
(VS.vs_get_vale_heap va_s0)
(VS.vs_get_vale_heap va_s1))) =
| let va_s1, f =
FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1;
(va_s1, f) | false |
CalcInference.fst | CalcInference.test1 | val test1: Prims.unit -> squash (2 == 1 + 1) | val test1: Prims.unit -> squash (2 == 1 + 1) | let test1 () : squash (2 == 1 + 1) =
calc (==) {
2;
== { lem () }
_;
} | {
"file_name": "examples/calc/CalcInference.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 10,
"start_col": 0,
"start_line": 5
} | module CalcInference
let lem () : squash (2 == 1 + 1) = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "CalcInference.fst"
} | [
{
"abbrev": 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 | _: Prims.unit -> Prims.squash (2 == 1 + 1) | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"CalcInference.lem",
"Prims.squash",
"Prims.op_Addition"
] | [] | false | false | true | false | false | let test1 () : squash (2 == 1 + 1) =
| calc ( == ) {
2;
( == ) { lem () }
_;
} | false |
CalcInference.fst | CalcInference.test3 | val test3: Prims.unit -> squash (2 == 1 + 1) | val test3: Prims.unit -> squash (2 == 1 + 1) | let test3 () : squash (2 == 1 + 1) =
calc (==) {
_;
== { lem () }
_;
} | {
"file_name": "examples/calc/CalcInference.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 24,
"start_col": 0,
"start_line": 19
} | module CalcInference
let lem () : squash (2 == 1 + 1) = ()
let test1 () : squash (2 == 1 + 1) =
calc (==) {
2;
== { lem () }
_;
}
let test2 () : squash (2 == 1 + 1) =
calc (==) {
_;
== { lem () }
1 + 1;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "CalcInference.fst"
} | [
{
"abbrev": 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 | _: Prims.unit -> Prims.squash (2 == 1 + 1) | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"CalcInference.lem",
"Prims.squash",
"Prims.op_Addition"
] | [] | false | false | true | false | false | let test3 () : squash (2 == 1 + 1) =
| calc ( == ) {
_;
( == ) { lem () }
_;
} | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime | val bn_exp_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | val bn_exp_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | let bn_exp_mont_vartime #t #len n mu aM bBits b =
if bBits < bn_exp_mont_vartime_threshold then
bn_exp_mont_bm_vartime n mu aM bBits b
else
bn_exp_mont_fw 4 n mu aM bBits b | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 152,
"start_col": 0,
"start_line": 148
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200
noextract
let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b)
val bn_exp_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
LE.exp_mont_ladder_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_mont_st t len
let bn_exp_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b) l;
SE.exp_fw k1 aM bBits (bn_v b) l | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_bm_vartime",
"Prims.bool",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_fw"
] | [] | false | false | false | false | false | let bn_exp_mont_vartime #t #len n mu aM bBits b =
| if bBits < bn_exp_mont_vartime_threshold
then bn_exp_mont_bm_vartime n mu aM bBits b
else bn_exp_mont_fw 4 n mu aM bBits b | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_bm_consttime | val bn_exp_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | val bn_exp_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | let bn_exp_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
LE.exp_mont_ladder_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 131,
"start_col": 0,
"start_line": 126
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200
noextract
let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b) | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Spec.Exponentiation.exp_mont_ladder_swap",
"Prims.unit",
"Lib.Exponentiation.exp_mont_ladder_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Lib.Exponentiation.exp_mont_ladder_swap_lemma",
"Spec.Exponentiation.exp_mont_ladder_swap_lemma",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.MontExponentiation.mk_bn_mont_concrete_ops"
] | [] | false | false | false | false | false | let bn_exp_mont_bm_consttime #t #len n mu aM bBits b =
| let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
LE.exp_mont_ladder_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_fw | val bn_exp_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_mont_st t len | val bn_exp_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_mont_st t len | let bn_exp_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b) l;
SE.exp_fw k1 aM bBits (bn_v b) l | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 144,
"start_col": 0,
"start_line": 140
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200
noextract
let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b)
val bn_exp_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
LE.exp_mont_ladder_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_mont_st t len | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | l: Lib.IntTypes.size_pos{l < Lib.IntTypes.bits t /\ Prims.pow2 l * len <= Lib.IntTypes.max_size_t}
-> Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Lib.IntTypes.size_pos",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.bits",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Spec.Exponentiation.exp_fw",
"Prims.unit",
"Lib.Exponentiation.exp_fw_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Spec.Exponentiation.exp_fw_lemma",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.MontExponentiation.mk_bn_mont_concrete_ops"
] | [] | false | false | false | false | false | let bn_exp_mont_fw #t #len l n mu aM bBits b =
| let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b) l;
SE.exp_fw k1 aM bBits (bn_v b) l | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_bm_vartime | val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b) | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 122,
"start_col": 0,
"start_line": 118
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200
noextract
let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Spec.Exponentiation.exp_rl",
"Prims.unit",
"Lib.Exponentiation.exp_rl_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Spec.Exponentiation.exp_rl_lemma",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.MontExponentiation.mk_bn_mont_concrete_ops"
] | [] | false | false | false | false | false | let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
| let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b) | false |
Hacl.Spec.Bignum.MontExponentiation.fst | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime | val bn_exp_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | val bn_exp_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len | let bn_exp_mont_consttime #t #len n mu aM bBits b =
if bBits < bn_exp_mont_consttime_threshold then
bn_exp_mont_bm_consttime n mu aM bBits b
else
bn_exp_mont_fw 4 n mu aM bBits b | {
"file_name": "code/bignum/Hacl.Spec.Bignum.MontExponentiation.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 160,
"start_col": 0,
"start_line": 156
} | module Hacl.Spec.Bignum.MontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module M = Hacl.Spec.Montgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// All operations are performed in the Montgomery domain!
unfold
let bn_mont_t (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) =
x:lbignum t len{bn_v x < bn_v n}
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (bn_mont_t n) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = (fun (x:bn_mont_t n) -> bn_v x);
}
val bn_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_one #t #len n mu _ =
BM.bn_precomp_r2_mod_n_lemma 0 n;
let r2 = BM.bn_precomp_r2_mod_n 0 n in
BM.bn_mont_one_lemma n mu r2;
BM.bn_mont_one n mu r2
val bn_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_mul #t #len n mu aM bM =
BM.bn_mont_mul_lemma n mu aM bM;
BM.bn_mont_mul n mu aM bM
val bn_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (bn_mont_t n) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_mont_sqr #t #len n mu aM =
BM.bn_mont_sqr_lemma n mu aM;
BM.bn_mont_sqr n mu aM
let mk_bn_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (bn_mont_t n) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_mont_one #t #len n mu;
SE.mul = bn_mont_mul #t #len n mu;
SE.sqr = bn_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
//TODO: set _threshold properly and
//add `bn_get_window_size` (consttime and vartime)
inline_for_extraction noextract
let bn_exp_mont_vartime_threshold = 200
inline_for_extraction noextract
let bn_exp_mont_consttime_threshold = 200
noextract
let bn_exp_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (bn_mont_t n)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_rl k1 aM bBits (bn_v b)
val bn_exp_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
LE.exp_mont_ladder_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_mont_st t len
let bn_exp_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM) bBits (bn_v b) l;
SE.exp_fw k1 aM bBits (bn_v b) l
val bn_exp_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_mont_st t len
let bn_exp_mont_vartime #t #len n mu aM bBits b =
if bBits < bn_exp_mont_vartime_threshold then
bn_exp_mont_bm_vartime n mu aM bBits b
else
bn_exp_mont_fw 4 n mu aM bBits b | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Montgomery.Lemmas.fst.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.MontExponentiation.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Montgomery.Lemmas",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": 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 | Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_bm_consttime",
"Prims.bool",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_fw"
] | [] | false | false | false | false | false | let bn_exp_mont_consttime #t #len n mu aM bBits b =
| if bBits < bn_exp_mont_consttime_threshold
then bn_exp_mont_bm_consttime n mu aM bBits b
else bn_exp_mont_fw 4 n mu aM bBits b | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen | val parse_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps)) | val parse_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps)) | let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 41,
"end_line": 192,
"start_col": 0,
"start_line": 177
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hp: LowParse.Spec.Base.parser hk ht ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp
-> LowParse.Spec.Base.parser (LowParse.Spec.DepLen.parse_deplen_kind min max hk pk)
(LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Combinators.parse_tagged_union",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.DepLen.parse_deplen_payload",
"LowParse.Spec.DepLen.parse_deplen_kind"
] | [] | false | false | false | false | false | let parse_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps)) =
| parse_tagged_union hp (calc_tag_of_deplen_data min max dlf ps) (parse_deplen_payload min max dlf ps) | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.calc_tag_of_deplen_data | val calc_tag_of_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(x: parse_deplen_data_t min max dlf ps)
: GTot ht | val calc_tag_of_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(x: parse_deplen_data_t min max dlf ps)
: GTot ht | let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 7,
"end_line": 67,
"start_col": 0,
"start_line": 56
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
x: LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps
-> Prims.GTot ht | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"FStar.Pervasives.Native.fst"
] | [] | false | false | false | false | false | let calc_tag_of_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(x: parse_deplen_data_t min max dlf ps)
: GTot ht =
| fst x | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_data_t | val parse_deplen_data_t : min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp
-> Type | let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) } | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 74,
"end_line": 51,
"start_col": 0,
"start_line": 42
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp
-> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"FStar.Pervasives.Native.tuple2",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Pervasives.Native.fst",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"FStar.Pervasives.Native.snd"
] | [] | false | false | false | false | true | let parse_deplen_data_t
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
=
| x: (ht & pt){U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x))} | false |
|
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_kind | val parse_deplen_kind : min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hk: LowParse.Spec.Base.parser_kind ->
pk: LowParse.Spec.Base.parser_kind
-> LowParse.Spec.Base.parser_kind | let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 57,
"end_line": 172,
"start_col": 0,
"start_line": 167
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hk: LowParse.Spec.Base.parser_kind ->
pk: LowParse.Spec.Base.parser_kind
-> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Combinators.and_then_kind",
"LowParse.Spec.DepLen.parse_deplen_payload_kind"
] | [] | false | false | false | false | false | let parse_deplen_kind (min: nat) (max: nat{min <= max /\ max < 4294967296}) (hk pk: parser_kind) =
| and_then_kind hk (parse_deplen_payload_kind min max pk) | false |
|
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.modBits_t | val modBits_t : t: Hacl.Bignum.Definitions.limb_t -> Type0 | let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 117,
"end_line": 36,
"start_col": 0,
"start_line": 36
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t"
] | [] | false | false | false | true | true | let modBits_t (t: limb_t) =
| modBits: size_t{1 < v modBits /\ (2 * bits t) * SD.blocks (v modBits) (bits t) <= max_size_t} | false |
|
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_payload | val parse_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot
(parser (parse_deplen_payload_kind min max pk)
(refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)) | val parse_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot
(parser (parse_deplen_payload_kind min max pk)
(refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)) | let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 41,
"end_line": 119,
"start_col": 0,
"start_line": 94
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht
-> LowParse.Spec.Base.parser (LowParse.Spec.DepLen.parse_deplen_payload_kind min max pk)
(LowParse.Spec.Base.refine_with_tag (LowParse.Spec.DepLen.calc_tag_of_deplen_data min
max
dlf
ps)
h) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Combinators.fail_parser",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"Prims.bool",
"LowParse.Spec.Base.weaken",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data",
"Prims.op_BarBar",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.UInt.uint_t",
"FStar.UInt32.v"
] | [] | false | false | false | false | false | let parse_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot
(parser (parse_deplen_payload_kind min max pk)
(refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)) =
| let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz ||
(match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz)
in
if bounds_off
then
fail_parser (parse_deplen_payload_kind min max pk)
(refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
((parse_fldata_strong ps sz) `parse_synth` (synth_deplen_data min max dlf ps h)) | false |
Steel.GhostPCMReference.fst | Steel.GhostPCMReference.witness | val witness (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(fact:Steel.Preorder.stable_property pcm)
(v:erased a)
(_:squash (Steel.Preorder.fact_valid_compat fact v))
: SteelAtomicUT (witnessed r fact) o
(pts_to r v)
(fun _ -> pts_to r v) | val witness (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(fact:Steel.Preorder.stable_property pcm)
(v:erased a)
(_:squash (Steel.Preorder.fact_valid_compat fact v))
: SteelAtomicUT (witnessed r fact) o
(pts_to r v)
(fun _ -> pts_to r v) | let witness (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(fact:Steel.Preorder.stable_property pcm)
(v:erased a)
(_:squash (Steel.Preorder.fact_valid_compat fact v))
= P.witness r fact v () | {
"file_name": "lib/steel/Steel.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 124,
"start_col": 0,
"start_line": 117
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostPCMReference
(* A ghost variant of Steel.PCMReference *)
open FStar.PCM
open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Mem = Steel.Memory
module P = Steel.PCMReference
let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p)
/// Its selector is non-informative (it is unit)
[@@__reduce__]
let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a)
= to_vprop (Steel.Memory.pts_to r v)
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: SteelGhost
(ref a pcm) o
(emp)
(fun r -> pts_to r x)
(requires fun _ -> pcm.refine x)
(ensures fun _ _ _ -> True)
= rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ());
FStar.PCM.compatible_refl pcm x;
let r = as_atomic_action_ghost (alloc_action o x) in
r
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: SteelGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires fun _ -> True)
(ensures fun _ v _ -> compatible pcm v0 v)
= let v = as_atomic_action_ghost (sel_action o r v0) in
v
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ _ _ -> True)
= as_atomic_action_ghost (upd_action o r v0 v1)
let upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: SteelGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
= as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f)
let share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires fun _ ->
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ _ _ -> True)
= P.split r v v0 v1
let gather (#o:inames)
(#a:Type)
(#p:FStar.PCM.pcm a)
(r:ref a p)
(v0:a)
(v1:a)
: SteelGhostT (_:unit{composable p v0 v1}) o
(pts_to r v0 `star` pts_to r v1)
(fun _ -> pts_to r (op p v0 v1))
= P.gather r v0 v1
let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a)
: Type0
= Steel.Memory.witnessed r fact | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostPCMReference.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": 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.GhostPCMReference.ref a pcm ->
fact: Steel.Preorder.stable_property pcm ->
v: FStar.Ghost.erased a ->
_: Prims.squash (Steel.Preorder.fact_valid_compat fact (FStar.Ghost.reveal v))
-> Steel.Effect.Atomic.SteelAtomicUT (Steel.GhostPCMReference.witnessed r fact) | Steel.Effect.Atomic.SteelAtomicUT | [] | [] | [
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.GhostPCMReference.ref",
"Steel.Preorder.stable_property",
"FStar.Ghost.erased",
"Prims.squash",
"Steel.Preorder.fact_valid_compat",
"FStar.Ghost.reveal",
"Steel.PCMReference.witness",
"Steel.Memory.witnessed",
"Steel.Memory.ref",
"Steel.GhostPCMReference.witnessed"
] | [] | false | true | false | false | false | let witness
(#o: inames)
(#a: Type)
(#pcm: pcm a)
(r: ref a pcm)
(fact: Steel.Preorder.stable_property pcm)
(v: erased a)
(_: squash (Steel.Preorder.fact_valid_compat fact v))
=
| P.witness r fact v () | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.synth_deplen_data | val synth_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) | val synth_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) | let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 8,
"end_line": 84,
"start_col": 0,
"start_line": 72
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht ->
x: LowParse.Spec.FLData.parse_fldata_strong_t ps (FStar.UInt32.v (dlf h))
-> LowParse.Spec.Base.refine_with_tag (LowParse.Spec.DepLen.calc_tag_of_deplen_data min max dlf ps
)
h | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"FStar.UInt32.v",
"FStar.Pervasives.Native.Mktuple2",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data"
] | [] | false | false | false | false | false | let synth_deplen_data
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) =
| (h, x) | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.serialize_deplen_payload_unfold | val serialize_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input ==
serialize ps (synth_deplen_data_recip min max dlf ps h input)) | val serialize_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input ==
serialize ps (synth_deplen_data_recip min max dlf ps h input)) | let serialize_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input == serialize ps (synth_deplen_data_recip min max dlf ps h input))
= let sz = U32.v (dlf h) in
serialize_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
input | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 9,
"end_line": 364,
"start_col": 0,
"start_line": 344
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*)
let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* a stronger version that further unfolds the payload *)
let parse_deplen_unfold2
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in
match parse pp input' with
| None -> None
| Some (t, consumed') ->
if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then
Some ((h, t), consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* serializer spec *)
let synth_deplen_data_recip
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h)))
= snd x
let serialize_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h))
= let sz = U32.v (dlf h) in
let bounds_off =
pk.parser_kind_low > sz ||
( match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_serializer (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) (fun _ -> ())
else
serialize_weaken (parse_deplen_payload_kind min max pk)
(serialize_synth
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
)
(* the lemma says serializing the payload from the data (header + payload) is the same as serializing only the payload *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht ->
input:
LowParse.Spec.Base.refine_with_tag (LowParse.Spec.DepLen.calc_tag_of_deplen_data min
max
dlf
ps)
h
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serialize (LowParse.Spec.DepLen.serialize_deplen_payload min max dlf ps h)
input ==
LowParse.Spec.Base.serialize ps
(LowParse.Spec.DepLen.synth_deplen_data_recip min max dlf ps h input)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"LowParse.Spec.Combinators.serialize_synth_eq",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data",
"LowParse.Spec.FLData.serialize_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data_recip",
"FStar.UInt.uint_t",
"FStar.UInt32.v",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.DepLen.parse_deplen_payload",
"LowParse.Spec.DepLen.serialize_deplen_payload",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let serialize_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input ==
serialize ps (synth_deplen_data_recip min max dlf ps h input)) =
| let sz = U32.v (dlf h) in
serialize_synth_eq (parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
input | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.serialize_deplen_unfold | val serialize_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: parse_deplen_data_t min max dlf ps)
: Lemma
(serialize (serialize_deplen min max hs dlf ps) input ==
(let sh = serialize hs (fst input) in
let sp = serialize ps (snd input) in
sh `Seq.append` sp)) | val serialize_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: parse_deplen_data_t min max dlf ps)
: Lemma
(serialize (serialize_deplen min max hs dlf ps) input ==
(let sh = serialize hs (fst input) in
let sp = serialize ps (snd input) in
sh `Seq.append` sp)) | let serialize_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp { hk.parser_kind_subkind == Some ParserStrong } )
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: parse_deplen_data_t min max dlf ps)
: Lemma
(serialize (serialize_deplen min max hs dlf ps) input == (
let sh = serialize hs (fst input) in
let sp = serialize ps (snd input) in
sh `Seq.append` sp
))
= serialize_tagged_union_eq
hs
(calc_tag_of_deplen_data min max dlf ps)
(serialize_deplen_payload min max dlf ps)
input;
let h : ht = calc_tag_of_deplen_data min max dlf ps input in
serialize_deplen_payload_unfold min max dlf ps h input | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 56,
"end_line": 411,
"start_col": 0,
"start_line": 386
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*)
let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* a stronger version that further unfolds the payload *)
let parse_deplen_unfold2
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in
match parse pp input' with
| None -> None
| Some (t, consumed') ->
if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then
Some ((h, t), consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* serializer spec *)
let synth_deplen_data_recip
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h)))
= snd x
let serialize_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h))
= let sz = U32.v (dlf h) in
let bounds_off =
pk.parser_kind_low > sz ||
( match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_serializer (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) (fun _ -> ())
else
serialize_weaken (parse_deplen_payload_kind min max pk)
(serialize_synth
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
)
(* the lemma says serializing the payload from the data (header + payload) is the same as serializing only the payload *)
let serialize_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input == serialize ps (synth_deplen_data_recip min max dlf ps h input))
= let sz = U32.v (dlf h) in
serialize_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
input
let serialize_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp { hk.parser_kind_subkind == Some ParserStrong } )
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (serializer (parse_deplen min max hp dlf ps))
= serialize_tagged_union
hs
(calc_tag_of_deplen_data min max dlf ps)
(serialize_deplen_payload min max dlf ps)
(* the lemma says serializing the data is the same as first serializing the header then the payload *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hs:
LowParse.Spec.Base.serializer hp
{ Mkparser_kind'?.parser_kind_subkind hk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
input: LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serialize (LowParse.Spec.DepLen.serialize_deplen min max hs dlf ps) input ==
(let sh = LowParse.Spec.Base.serialize hs (FStar.Pervasives.Native.fst input) in
let sp = LowParse.Spec.Base.serialize ps (FStar.Pervasives.Native.snd input) in
FStar.Seq.Base.append sh sp)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.serialize_deplen_payload_unfold",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"Prims.unit",
"LowParse.Spec.Combinators.serialize_tagged_union_eq",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.DepLen.parse_deplen_payload",
"LowParse.Spec.DepLen.serialize_deplen_payload",
"Prims.l_True",
"Prims.squash",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.DepLen.parse_deplen_kind",
"LowParse.Spec.DepLen.parse_deplen",
"LowParse.Spec.DepLen.serialize_deplen",
"FStar.Seq.Base.append",
"LowParse.Bytes.bytes",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.fst",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let serialize_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: parse_deplen_data_t min max dlf ps)
: Lemma
(serialize (serialize_deplen min max hs dlf ps) input ==
(let sh = serialize hs (fst input) in
let sp = serialize ps (snd input) in
sh `Seq.append` sp)) =
| serialize_tagged_union_eq hs
(calc_tag_of_deplen_data min max dlf ps)
(serialize_deplen_payload min max dlf ps)
input;
let h:ht = calc_tag_of_deplen_data min max dlf ps input in
serialize_deplen_payload_unfold min max dlf ps h input | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.synth_deplen_data_recip | val synth_deplen_data_recip
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h))) | val synth_deplen_data_recip
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h))) | let synth_deplen_data_recip
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h)))
= snd x | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 7,
"end_line": 309,
"start_col": 0,
"start_line": 297
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*)
let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* a stronger version that further unfolds the payload *)
let parse_deplen_unfold2
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in
match parse pp input' with
| None -> None
| Some (t, consumed') ->
if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then
Some ((h, t), consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* serializer spec *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht ->
x:
LowParse.Spec.Base.refine_with_tag (LowParse.Spec.DepLen.calc_tag_of_deplen_data min
max
dlf
ps)
h
-> LowParse.Spec.FLData.parse_fldata_strong_t ps (FStar.UInt32.v (dlf h)) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"FStar.Pervasives.Native.snd",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"FStar.UInt32.v"
] | [] | false | false | false | false | false | let synth_deplen_data_recip
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(x: refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h))) =
| snd x | false |
Benton2004.RHL.Examples2.fst | Benton2004.RHL.Examples2.proof | val proof: Prims.unit -> Lemma (related l r (phi ()) (phi ())) | val proof: Prims.unit -> Lemma (related l r (phi ()) (phi ())) | let proof () : Lemma
(related l r (phi ()) (phi ()))
=
let phi = phi () in
let phi1 = gand phi (geq (gvar x Right) (gop op_Addition (gvar y Right) (gconst 1))) in
let phi2 = gand phi1 (geq (gvar x Left) (gvar x Right)) in
hyp;
assert (related (assign x asx_e) skip phi1 phi2); // by r_dassl
lemma_included_helper (); //prove the precondition of r_ass
assert (related (assign i asi_e) (assign i asi_e) phi2 phi2); // by r_ass
d_su1' (assign x asx_e) (assign i asi_e) (assign i asi_e) phi1 phi2 phi2;
r_while cond cond (seq (assign x asx_e) (assign i asi_e)) (assign i asi_e) phi1;
assert (related skip (assign x asx_e) phi phi1); // by r_dassr
assert (related l (while cond (assign i asi_e)) phi1 phi); // by d_sub
d_su1'_flip l (assign x asx_e) (while cond (assign i asi_e)) phi phi1 phi | {
"file_name": "examples/rel/Benton2004.RHL.Examples2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 75,
"end_line": 56,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Benton2004.RHL.Examples2
include Benton2004.RHL.Derived
assume val i: var
assume val n: var
assume val x: var
assume val y: var
assume val hyp : squash (List.Tot.noRepeats [i; n; x; y] == true)
let cond = eop op_LessThan (evar i) (evar n)
let asx_e = eop op_Addition (evar y) (const 1)
let asi_e = eop op_Addition (evar i) (evar x)
let l = while cond (seq (assign x asx_e) (assign i asi_e))
let r = seq (assign x asx_e) (while cond (assign i asi_e))
let phi () : GTot (gexp bool) = gand (geq (gvar i Left) (gvar i Right)) (gand (geq (gvar n Left) (gvar n Right)) (geq (gvar y Left) (gvar y Right)))
let lemma_included_helper ()
: Lemma (let phi = phi () in
let phi1 = gand phi (geq (gvar x Right) (gop op_Addition (gvar y Right) (gconst 1))) in
let phi2 = gand phi1 (geq (gvar x Left) (gvar x Right)) in
included phi2 (gsubst (gsubst phi2 i Left (exp_to_gexp asi_e Left)) i Right (exp_to_gexp asi_e Right)))
= ()
#set-options "--max_fuel 3 --max_ifuel 0 --initial_fuel 3 --z3rlimit_factor 4" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"Benton2004.RHL.Derived.fst.checked"
],
"interface_file": false,
"source_file": "Benton2004.RHL.Examples2.fst"
} | [
{
"abbrev": false,
"full_module": "Benton2004.RHL.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": false,
"full_module": "Benton2004.RHL",
"short_module": null
},
{
"abbrev": 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": 3,
"initial_ifuel": 1,
"max_fuel": 3,
"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": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
Benton2004.RHL.Derived.related Benton2004.RHL.Examples2.l
Benton2004.RHL.Examples2.r
(Benton2004.RHL.Examples2.phi ())
(Benton2004.RHL.Examples2.phi ())) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"Benton2004.RHL.Derived.d_su1'_flip",
"Benton2004.RHL.Examples2.l",
"Benton2004.assign",
"Benton2004.RHL.Examples2.x",
"Benton2004.RHL.Examples2.asx_e",
"Benton2004.while",
"Benton2004.RHL.Examples2.cond",
"Benton2004.RHL.Examples2.i",
"Benton2004.RHL.Examples2.asi_e",
"Prims._assert",
"Benton2004.RHL.Derived.related",
"Benton2004.skip",
"Benton2004.RHL.r_while",
"Benton2004.seq",
"Benton2004.RHL.d_su1'",
"Benton2004.RHL.Examples2.lemma_included_helper",
"Benton2004.RHL.Examples2.hyp",
"Benton2004.RHL.gexp",
"Prims.bool",
"Benton2004.RHL.gand",
"Benton2004.RHL.geq",
"Prims.int",
"Benton2004.RHL.gvar",
"Benton2004.RHL.Left",
"Benton2004.RHL.Right",
"Benton2004.RHL.gop",
"Prims.op_Addition",
"Benton2004.RHL.Examples2.y",
"Benton2004.RHL.gconst",
"Benton2004.RHL.Examples2.phi",
"Prims.l_True",
"Prims.squash",
"Benton2004.RHL.Examples2.r",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let proof () : Lemma (related l r (phi ()) (phi ())) =
| let phi = phi () in
let phi1 = gand phi (geq (gvar x Right) (gop op_Addition (gvar y Right) (gconst 1))) in
let phi2 = gand phi1 (geq (gvar x Left) (gvar x Right)) in
hyp;
assert (related (assign x asx_e) skip phi1 phi2);
lemma_included_helper ();
assert (related (assign i asi_e) (assign i asi_e) phi2 phi2);
d_su1' (assign x asx_e) (assign i asi_e) (assign i asi_e) phi1 phi2 phi2;
r_while cond cond (seq (assign x asx_e) (assign i asi_e)) (assign i asi_e) phi1;
assert (related skip (assign x asx_e) phi phi1);
assert (related l (while cond (assign i asi_e)) phi1 phi);
d_su1'_flip l (assign x asx_e) (while cond (assign i asi_e)) phi phi1 phi | false |
Normalization.fst | Normalization.add_2 | val add_2 (x: int) : int | val add_2 (x: int) : int | let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x))) | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 77,
"end_line": 53,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let add_2 (x: int) : int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (normalize [primops; delta] (add_1 (add_1 x)))) | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.serialize_deplen_payload | val serialize_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h)) | val serialize_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h)) | let serialize_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h))
= let sz = U32.v (dlf h) in
let bounds_off =
pk.parser_kind_low > sz ||
( match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_serializer (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) (fun _ -> ())
else
serialize_weaken (parse_deplen_payload_kind min max pk)
(serialize_synth
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 7,
"end_line": 340,
"start_col": 0,
"start_line": 311
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*)
let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* a stronger version that further unfolds the payload *)
let parse_deplen_unfold2
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in
match parse pp input' with
| None -> None
| Some (t, consumed') ->
if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then
Some ((h, t), consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* serializer spec *)
let synth_deplen_data_recip
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h)))
= snd x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht
-> LowParse.Spec.Base.serializer (LowParse.Spec.DepLen.parse_deplen_payload min max dlf ps h) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Combinators.fail_serializer",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"Prims.unit",
"Prims.bool",
"LowParse.Spec.Combinators.serialize_weaken",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.FLData.serialize_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data_recip",
"LowParse.Spec.DepLen.parse_deplen_payload",
"Prims.op_BarBar",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.UInt.uint_t",
"FStar.UInt32.v"
] | [] | false | false | false | false | false | let serialize_deplen_payload
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h)) =
| let sz = U32.v (dlf h) in
let bounds_off =
pk.parser_kind_low > sz ||
(match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz)
in
if bounds_off
then
fail_serializer (parse_deplen_payload_kind min max pk)
(refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
(fun _ -> ())
else
serialize_weaken (parse_deplen_payload_kind min max pk)
(serialize_synth (parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()) | false |
Normalization.fst | Normalization.normalize | val normalize (#t: Type) (steps: list norm_step) (x: t) : Tac unit | val normalize (#t: Type) (steps: list norm_step) (x: t) : Tac unit | let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl () | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 10,
"end_line": 28,
"start_col": 0,
"start_line": 24
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | steps: Prims.list FStar.Pervasives.norm_step -> x: t -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.list",
"FStar.Pervasives.norm_step",
"FStar.Tactics.V2.Derived.trefl",
"Prims.unit",
"FStar.Stubs.Tactics.V2.Builtins.norm",
"FStar.Tactics.V2.Derived.exact",
"FStar.Tactics.NamedView.term",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Tactics.V2.Builtins.dup"
] | [] | false | true | false | false | false | let normalize (#t: Type) (steps: list norm_step) (x: t) : Tac unit =
| dup ();
exact (quote x);
norm steps;
trefl () | false |
Normalization.fst | Normalization.add_1 | val add_1 (x: int) : int | val add_1 (x: int) : int | let add_1 (x:int) : int = x + 1 | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let add_1 (x: int) : int =
| x + 1 | false |
Normalization.fst | Normalization.four | val four:int | val four:int | let four : int = _ by (normalize [primops; delta] (add_2 2)) | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 60,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1
(* add_2 is defined to be (x + 1) + 1 *)
let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let four:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (normalize [primops; delta] (add_2 2))) | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.serialize_deplen | val serialize_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (serializer (parse_deplen min max hp dlf ps)) | val serialize_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (serializer (parse_deplen min max hp dlf ps)) | let serialize_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp { hk.parser_kind_subkind == Some ParserStrong } )
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (serializer (parse_deplen min max hp dlf ps))
= serialize_tagged_union
hs
(calc_tag_of_deplen_data min max dlf ps)
(serialize_deplen_payload min max dlf ps) | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 45,
"end_line": 382,
"start_col": 0,
"start_line": 366
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*)
let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* a stronger version that further unfolds the payload *)
let parse_deplen_unfold2
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in
match parse pp input' with
| None -> None
| Some (t, consumed') ->
if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then
Some ((h, t), consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz
(* serializer spec *)
let synth_deplen_data_recip
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Tot (parse_fldata_strong_t ps (U32.v (dlf h)))
= snd x
let serialize_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (serializer (parse_deplen_payload min max dlf ps h))
= let sz = U32.v (dlf h) in
let bounds_off =
pk.parser_kind_low > sz ||
( match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_serializer (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) (fun _ -> ())
else
serialize_weaken (parse_deplen_payload_kind min max pk)
(serialize_synth
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
)
(* the lemma says serializing the payload from the data (header + payload) is the same as serializing only the payload *)
let serialize_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input : refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
: Lemma
(serialize (serialize_deplen_payload min max dlf ps h) input == serialize ps (synth_deplen_data_recip min max dlf ps h input))
= let sz = U32.v (dlf h) in
serialize_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
(serialize_fldata_strong ps sz)
(synth_deplen_data_recip min max dlf ps h)
()
input | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hs:
LowParse.Spec.Base.serializer hp
{ Mkparser_kind'?.parser_kind_subkind hk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp
-> LowParse.Spec.Base.serializer (LowParse.Spec.DepLen.parse_deplen min max hp dlf ps) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.serialize_tagged_union",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.DepLen.parse_deplen_payload",
"LowParse.Spec.DepLen.serialize_deplen_payload",
"LowParse.Spec.DepLen.parse_deplen_kind",
"LowParse.Spec.DepLen.parse_deplen"
] | [] | false | false | false | false | false | let serialize_deplen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(#hp: parser hk ht)
(hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong})
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (serializer (parse_deplen min max hp dlf ps)) =
| serialize_tagged_union hs
(calc_tag_of_deplen_data min max dlf ps)
(serialize_deplen_payload min max dlf ps) | false |
Normalization.fst | Normalization.does_not_normalize | val does_not_normalize (#t: Type) (x: t) : t | val does_not_normalize (#t: Type) (x: t) : t | let does_not_normalize (#t:Type) (x:t) : t =
_ by (normalize [primops; delta] x) | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 95,
"start_col": 0,
"start_line": 94
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1
(* add_2 is defined to be (x + 1) + 1 *)
let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x)))
(* `four` is defined as `4` ... *)
let four : int = _ by (normalize [primops; delta] (add_2 2))
(* .. as we can check by inspecting its definition *)
let _ = assert True
by (let t = def_of four in
if compare_term t (`4) = FStar.Order.Eq
then ()
else fail "Test 1")
(* GM, 2023/11/09: this is now no longer true. The unifier does trigger
primitive steps computations, and the trefl() call above
will instantiate the RHS with the WHNF of the LHS, which is also 4. *)
(* If we only allow for Delta steps, then there's no primitive computation and we
* end up with (2 + 1) + 1 *)
(* let four' : int = _ by (normalize [delta] (add_2 2)) *)
(* let _ = assert True *)
(* by (let t = def_of four' in *)
(* if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq *)
(* then () *)
(* else fail "Test 2") *)
(* Here, we allow for primitive computation but don't allow for `add_2` to be expanded to
* its definition, so the final result is `add_2 1` *)
let unfold_add_1: norm_step = delta_only ["Normalization.add_1"]
let three : int = _ by (normalize [delta; unfold_add_1; primops] (add_2 (add_1 0)))
let _ = assert True
by (let t = def_of three in
if compare_term t (`(add_2 1)) = FStar.Order.Eq
then ()
else fail "Test 3")
(* Writing a function that normalizes its argument does not work! The tactic runs
* when this definition is type-checked, and not when it's called. So, this function is just an | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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: t -> t | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let does_not_normalize (#t: Type) (x: t) : t =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (normalize [primops; delta] x)) | false |
Normalization.fst | Normalization.four'' | val four'':int | val four'':int | let four'' : int = does_not_normalize (2+2) | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 97,
"start_col": 0,
"start_line": 97
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1
(* add_2 is defined to be (x + 1) + 1 *)
let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x)))
(* `four` is defined as `4` ... *)
let four : int = _ by (normalize [primops; delta] (add_2 2))
(* .. as we can check by inspecting its definition *)
let _ = assert True
by (let t = def_of four in
if compare_term t (`4) = FStar.Order.Eq
then ()
else fail "Test 1")
(* GM, 2023/11/09: this is now no longer true. The unifier does trigger
primitive steps computations, and the trefl() call above
will instantiate the RHS with the WHNF of the LHS, which is also 4. *)
(* If we only allow for Delta steps, then there's no primitive computation and we
* end up with (2 + 1) + 1 *)
(* let four' : int = _ by (normalize [delta] (add_2 2)) *)
(* let _ = assert True *)
(* by (let t = def_of four' in *)
(* if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq *)
(* then () *)
(* else fail "Test 2") *)
(* Here, we allow for primitive computation but don't allow for `add_2` to be expanded to
* its definition, so the final result is `add_2 1` *)
let unfold_add_1: norm_step = delta_only ["Normalization.add_1"]
let three : int = _ by (normalize [delta; unfold_add_1; primops] (add_2 (add_1 0)))
let _ = assert True
by (let t = def_of three in
if compare_term t (`(add_2 1)) = FStar.Order.Eq
then ()
else fail "Test 3")
(* Writing a function that normalizes its argument does not work! The tactic runs
* when this definition is type-checked, and not when it's called. So, this function is just an
* identity function with no special semantics. *)
let does_not_normalize (#t:Type) (x:t) : t =
_ by (normalize [primops; delta] x) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | Prims.int | Prims.Tot | [
"total"
] | [] | [
"Normalization.does_not_normalize",
"Prims.int",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let four'':int =
| does_not_normalize (2 + 2) | false |
QuickSort.Array.fst | QuickSort.Array.sort | val sort: #a:eqtype -> f:tot_ord a -> i:nat -> j:nat{i <= j} -> x:array a
-> ST unit
(requires (fun h -> Array.contains h x /\ j <= length (Array.sel h x)))
(ensures (fun h0 u h1 -> (modifies (Array.only x) h0 h1
/\ j <= length (Array.sel h0 x) (* carrying this along from the requires clause *)
/\ Array.contains h1 x (* the array is still in the heap *)
/\ (length (Array.sel h0 x) = length (Array.sel h1 x)) (* its length has not changed *)
/\ sorted f (slice (Array.sel h1 x) i j) (* it is sorted between [i, j) *)
/\ (Array.sel h1 x == splice (Array.sel h0 x) i (Array.sel h1 x) j) (* the rest of it is unchanged *)
/\ permutation a (slice (Array.sel h0 x) i j) (slice (Array.sel h1 x) i j)))) | val sort: #a:eqtype -> f:tot_ord a -> i:nat -> j:nat{i <= j} -> x:array a
-> ST unit
(requires (fun h -> Array.contains h x /\ j <= length (Array.sel h x)))
(ensures (fun h0 u h1 -> (modifies (Array.only x) h0 h1
/\ j <= length (Array.sel h0 x) (* carrying this along from the requires clause *)
/\ Array.contains h1 x (* the array is still in the heap *)
/\ (length (Array.sel h0 x) = length (Array.sel h1 x)) (* its length has not changed *)
/\ sorted f (slice (Array.sel h1 x) i j) (* it is sorted between [i, j) *)
/\ (Array.sel h1 x == splice (Array.sel h0 x) i (Array.sel h1 x) j) (* the rest of it is unchanged *)
/\ permutation a (slice (Array.sel h0 x) i j) (slice (Array.sel h1 x) i j)))) | let rec sort #a f i j x =
let h0 = ST.get () in
if i=j
then splice_refl (Array.sel h0 x) i j
else begin
let pivot = partition f i j i (j - 1) x in
(* ghost *) let h1 = get() in
sort f i pivot x;
(* ghost *) let h2 = get() in
let _ =
(* ghost *) lemma_seq_frame_hi (Array.sel h2 x) (Array.sel h1 x) i pivot pivot j;
(* ghost *) lemma_tail_slice (Array.sel h2 x) pivot j in
sort f (pivot + 1) j x;
(* ghost *) let h3 = get() in
(* ghost *) lemma_seq_frame_lo (Array.sel h3 x) (Array.sel h2 x) i pivot (pivot + 1) j;
(* ghost *) let lo = slice (Array.sel h3 x) i pivot in
(* ghost *) let hi = slice (Array.sel h3 x) (pivot + 1) j in
(* ghost *) let pv = index (Array.sel h1 x) pivot in
(* ghost *) Seq.sorted_concat_lemma f lo pv hi;
(* ghost *) lemma_slice_cons_pv (Array.sel h3 x) i pivot j pv;
(* ghost *) lemma_weaken_frame_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
(* ghost *) lemma_weaken_frame_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j;
(* ghost *) lemma_trans_frame (Array.sel h3 x) (Array.sel h2 x) (Array.sel h1 x) i j;
(* ghost *) lemma_trans_frame (Array.sel h3 x) (Array.sel h1 x) (Array.sel h0 x) i j;
(* ghost *) lemma_weaken_perm_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
(* ghost *) lemma_weaken_perm_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j
end | {
"file_name": "examples/algorithms/QuickSort.Array.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 188,
"start_col": 0,
"start_line": 155
} | (*
Copyright 2008-2014 Nikhil Swamy and 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 QuickSort.Array
open FStar.Array
open FStar.Seq
open FStar.Heap
open FStar.ST
#set-options "--initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
(* 2016-11-22: Due to the QuickSort namespace being opened *after* the
FStar namespace,Array resolves to QuickSort.Array instead of
FStar.Array, so we have to fix this explicitly as a module abbrev. *)
module Array = FStar.Array
module Seq = FStar.Seq
type partition_inv (a:eqtype) (f:tot_ord a) (lo:seq a) (pv:a) (hi:seq a) =
((length hi) >= 0)
/\ (forall y. (mem y hi ==> f pv y) /\ (mem y lo ==> f y pv))
type partition_pre (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h:heap) =
(Array.contains h x
/\ ((let s = Array.sel h x in (len <= length s) /\ (partition_inv a f
(slice s start pivot)
(index s pivot)
(slice s (back + 1) len)))
))
type partition_post (a:eqtype) (f:tot_ord a) (start:nat) (len:nat{start <= len} )
(pivot:nat{start <= pivot /\ pivot < len})
(back:nat{pivot <= back /\ back < len})
(x:array a) (h0:heap) (i:nat) (h1:heap) =
(len <= length (Array.sel h0 x)
/\ Array.contains h1 x
/\ start <= i
/\ i < len
/\ (length (Array.sel h1 x) = length (Array.sel h0 x))
/\ (Array.sel h1 x == splice (Array.sel h0 x) start (Array.sel h1 x) len)
/\ (permutation a (slice (Array.sel h0 x) start len) (slice (Array.sel h1 x) start len))
/\ (partition_inv a f
(slice (Array.sel h1 x) start i)
(index (Array.sel h1 x) i)
(slice (Array.sel h1 x) i len)))
#reset-options "--z3rlimit 20 --initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0"
val partition: #a:eqtype -> f:tot_ord a
-> start:nat -> len:nat{start <= len}
-> pivot:nat{start <= pivot /\ pivot < len}
-> back:nat{pivot <= back /\ back < len}
-> x:array a -> ST nat
(requires (partition_pre a f start len pivot back x))
(ensures (fun h0 n h1 -> partition_post a f start len pivot back x h0 n h1 /\ modifies (Array.only x) h0 h1))
let rec partition #a f start len pivot back x =
let h0 = get() in
if pivot = back
then
begin
(*ghost*) (let s = Array.sel h0 x in
(*ghost*) lemma_slice_cons s pivot len;
(*ghost*) splice_refl s start len);
pivot
end
else
begin
let next = Array.index x (pivot + 1) in
let p = Array.index x pivot in
if f next p
then
begin
Array.swap x pivot (pivot + 1); (* the pivot moves forward *)
let h1 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) swap_frame_lo s start pivot (pivot + 1);
(* ghost *) swap_frame_hi s pivot (pivot + 1) (back + 1) len;
assume (pivot < length s');
//lemma_swap_splice s start (pivot + 1) back len;
(* need pivot < length s',
but only have pivot < length s *)
(* ghost *) lemma_ordering_lo_snoc f s' start pivot p in
let res = partition f start len (pivot + 1) back x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start pivot (pivot + 1) len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
else
begin
Array.swap x (pivot + 1) back; (* the back moves backward *)
let h1 = get () in
// (* ghost *) let s = Array.sel h0 x in
// (* ghost *) let s' = Array.sel h1 x in
// (* ghost *) swap_frame_lo' s start pivot (pivot + 1) back;
// (* ghost *) swap_frame_hi s (pivot + 1) back (back + 1) len;
// (* ghost *) lemma_ordering_hi_cons f s' back len p in
let res = partition f start len pivot (back - 1) x in
let h2 = get () in
let _ =
(* ghost *) let s = Array.sel h0 x in
(* ghost *) let s' = Array.sel h1 x in
(* ghost *) let s'' = Array.sel h2 x in
(* ghost *) lemma_swap_splice s start (pivot + 1) back len;
(* ghost *) lemma_trans_frame s'' s' s start len;
(* ghost *) lemma_swap_permutes_slice s start (pivot + 1) back len;
(* ghost *) lemma_trans_perm s s' s'' start len in
res
end
end
#reset-options
val lemma_slice_cons_pv: #a:Type -> s:seq a -> i:nat -> pivot:nat{i <= pivot} -> j:nat{pivot < j && j <= length s} -> pv:a
-> Lemma
(requires (pv == index s pivot))
(ensures (slice s i j == append (slice s i pivot) (cons pv (slice s (pivot + 1) j))))
let lemma_slice_cons_pv #a s i pivot j pv =
let lo = slice s i pivot in
let hi = slice s (pivot + 1) j in
cut (Seq.equal (slice s i j) (append lo (cons pv hi)))
#reset-options
#set-options "--initial_fuel 1 --initial_ifuel 0 --max_fuel 1 --max_ifuel 0 --z3rlimit 50"
val sort: #a:eqtype -> f:tot_ord a -> i:nat -> j:nat{i <= j} -> x:array a
-> ST unit
(requires (fun h -> Array.contains h x /\ j <= length (Array.sel h x)))
(ensures (fun h0 u h1 -> (modifies (Array.only x) h0 h1
/\ j <= length (Array.sel h0 x) (* carrying this along from the requires clause *)
/\ Array.contains h1 x (* the array is still in the heap *)
/\ (length (Array.sel h0 x) = length (Array.sel h1 x)) (* its length has not changed *)
/\ sorted f (slice (Array.sel h1 x) i j) (* it is sorted between [i, j) *)
/\ (Array.sel h1 x == splice (Array.sel h0 x) i (Array.sel h1 x) j) (* the rest of it is unchanged *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked",
"FStar.Array.fsti.checked"
],
"interface_file": false,
"source_file": "QuickSort.Array.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Array",
"short_module": "Array"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "QuickSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: FStar.Seq.Properties.tot_ord a -> i: Prims.nat -> j: Prims.nat{i <= j} -> x: FStar.Array.array a
-> FStar.ST.ST Prims.unit | FStar.ST.ST | [] | [] | [
"Prims.eqtype",
"FStar.Seq.Properties.tot_ord",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Array.array",
"Prims.op_Equality",
"FStar.Seq.Properties.splice_refl",
"FStar.Array.sel",
"Prims.unit",
"Prims.bool",
"FStar.Seq.Properties.lemma_weaken_perm_left",
"Prims.op_Addition",
"FStar.Seq.Properties.lemma_weaken_perm_right",
"FStar.Seq.Properties.lemma_trans_frame",
"FStar.Seq.Properties.lemma_weaken_frame_left",
"FStar.Seq.Properties.lemma_weaken_frame_right",
"QuickSort.Array.lemma_slice_cons_pv",
"FStar.Seq.Properties.sorted_concat_lemma",
"FStar.Seq.Base.index",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"FStar.Seq.Properties.lemma_seq_frame_lo",
"FStar.Monotonic.Heap.heap",
"FStar.ST.get",
"QuickSort.Array.sort",
"FStar.Seq.Properties.lemma_tail_slice",
"FStar.Seq.Properties.lemma_seq_frame_hi",
"QuickSort.Array.partition",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | true | false | false | false | let rec sort #a f i j x =
| let h0 = ST.get () in
if i = j
then splice_refl (Array.sel h0 x) i j
else
let pivot = partition f i j i (j - 1) x in
let h1 = get () in
sort f i pivot x;
let h2 = get () in
let _ =
lemma_seq_frame_hi (Array.sel h2 x) (Array.sel h1 x) i pivot pivot j;
lemma_tail_slice (Array.sel h2 x) pivot j
in
sort f (pivot + 1) j x;
let h3 = get () in
lemma_seq_frame_lo (Array.sel h3 x) (Array.sel h2 x) i pivot (pivot + 1) j;
let lo = slice (Array.sel h3 x) i pivot in
let hi = slice (Array.sel h3 x) (pivot + 1) j in
let pv = index (Array.sel h1 x) pivot in
Seq.sorted_concat_lemma f lo pv hi;
lemma_slice_cons_pv (Array.sel h3 x) i pivot j pv;
lemma_weaken_frame_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
lemma_weaken_frame_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j;
lemma_trans_frame (Array.sel h3 x) (Array.sel h2 x) (Array.sel h1 x) i j;
lemma_trans_frame (Array.sel h3 x) (Array.sel h1 x) (Array.sel h0 x) i j;
lemma_weaken_perm_right (Array.sel h2 x) (Array.sel h1 x) i pivot j;
lemma_weaken_perm_left (Array.sel h3 x) (Array.sel h2 x) i (pivot + 1) j | false |
Normalization.fst | Normalization.unfold_add_1 | val unfold_add_1:norm_step | val unfold_add_1:norm_step | let unfold_add_1: norm_step = delta_only ["Normalization.add_1"] | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 64,
"end_line": 81,
"start_col": 0,
"start_line": 81
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1
(* add_2 is defined to be (x + 1) + 1 *)
let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x)))
(* `four` is defined as `4` ... *)
let four : int = _ by (normalize [primops; delta] (add_2 2))
(* .. as we can check by inspecting its definition *)
let _ = assert True
by (let t = def_of four in
if compare_term t (`4) = FStar.Order.Eq
then ()
else fail "Test 1")
(* GM, 2023/11/09: this is now no longer true. The unifier does trigger
primitive steps computations, and the trefl() call above
will instantiate the RHS with the WHNF of the LHS, which is also 4. *)
(* If we only allow for Delta steps, then there's no primitive computation and we
* end up with (2 + 1) + 1 *)
(* let four' : int = _ by (normalize [delta] (add_2 2)) *)
(* let _ = assert True *)
(* by (let t = def_of four' in *)
(* if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq *)
(* then () *)
(* else fail "Test 2") *)
(* Here, we allow for primitive computation but don't allow for `add_2` to be expanded to | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.norm_step | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.delta_only",
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | false | false | false | true | false | let unfold_add_1:norm_step =
| delta_only ["Normalization.add_1"] | false |
Normalization.fst | Normalization.three | val three:int | val three:int | let three : int = _ by (normalize [delta; unfold_add_1; primops] (add_2 (add_1 0))) | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 83,
"end_line": 83,
"start_col": 0,
"start_line": 83
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl ()
(* This tactic also depends on said behaviour of quote, and returns the definition of a top-level fvar *)
let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar"
let add_1 (x:int) : int = x + 1
(* add_2 is defined to be (x + 1) + 1 *)
let add_2 (x:int) : int = _ by (normalize [primops; delta] (add_1 (add_1 x)))
(* `four` is defined as `4` ... *)
let four : int = _ by (normalize [primops; delta] (add_2 2))
(* .. as we can check by inspecting its definition *)
let _ = assert True
by (let t = def_of four in
if compare_term t (`4) = FStar.Order.Eq
then ()
else fail "Test 1")
(* GM, 2023/11/09: this is now no longer true. The unifier does trigger
primitive steps computations, and the trefl() call above
will instantiate the RHS with the WHNF of the LHS, which is also 4. *)
(* If we only allow for Delta steps, then there's no primitive computation and we
* end up with (2 + 1) + 1 *)
(* let four' : int = _ by (normalize [delta] (add_2 2)) *)
(* let _ = assert True *)
(* by (let t = def_of four' in *)
(* if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq *)
(* then () *)
(* else fail "Test 2") *)
(* Here, we allow for primitive computation but don't allow for `add_2` to be expanded to
* its definition, so the final result is `add_2 1` *)
let unfold_add_1: norm_step = delta_only ["Normalization.add_1"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | Prims.int | Prims.Tot | [
"total"
] | [] | [
"Normalization.add_2"
] | [] | false | false | false | true | false | let three:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(normalize [delta; unfold_add_1; primops] (add_2 (add_1 0)))) | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn_st | val rsapss_sign_msg_to_bn_st : t: Hacl.Bignum.Definitions.limb_t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 114,
"end_line": 104,
"start_col": 0,
"start_line": 90
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Sequence.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Hacl.Spec.RSAPSS.rsapss_sign_pre",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.bits",
"Hacl.Spec.RSAPSS.rsapss_sign_msg_to_bn",
"Lib.IntTypes.int_t",
"Prims.int",
"Lib.IntTypes.range",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.IntTypes.mk_int",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size"
] | [] | false | false | false | false | true | let rsapss_sign_msg_to_bn_st
(t: limb_t)
(a: Hash.hash_alg{S.hash_is_supported a})
(modBits: modBits_t t)
=
| let len = blocks modBits (size (bits t)) in
saltLen: size_t ->
salt: lbuffer uint8 saltLen ->
msgLen: size_t ->
msg: lbuffer uint8 msgLen ->
m: lbignum t len
-> Stack unit
(requires
fun h ->
live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\
disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures
fun h0 _ h1 ->
modifies (loc m) h0 h1 /\
as_seq h1 m ==
LS.rsapss_sign_msg_to_bn a
(v modBits)
(v saltLen)
(as_seq h0 salt)
(v msgLen)
(as_seq h0 msg)) | false |
|
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_unfold | val parse_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
if (U32.v (dlf h) + consumed) > (Seq.length input)
then None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some (x, consumed') ->
if consumed' = U32.v (dlf h) then Some (x, consumed + (U32.v (dlf h))) else None)) | val parse_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
if (U32.v (dlf h) + consumed) > (Seq.length input)
then None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some (x, consumed') ->
if consumed' = U32.v (dlf h) then Some (x, consumed + (U32.v (dlf h))) else None)) | let parse_deplen_unfold
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input : bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
begin
if (U32.v (dlf h) + consumed) > (Seq.length input) then
None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some(x, consumed') ->
if consumed' = U32.v (dlf h) then
Some (x, consumed + (U32.v (dlf h)))
else
None
end)
)
= parse_tagged_union_eq
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz then
()
else
Seq.slice_slice input consumed (Seq.length input) 0 sz | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 60,
"end_line": 243,
"start_col": 0,
"start_line": 198
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*)
let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input
(* metadata for dependent length parser
@min :
@max : integer bounds
@hk : header metadata
@pk : payload metadata
*)
let parse_deplen_kind
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(hk : parser_kind)
(pk : parser_kind)
= and_then_kind hk (parse_deplen_payload_kind min max pk)
(* parse spec for dependent length structures *)
let parse_deplen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
: Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps))
= parse_tagged_union
hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
(* This lemma says using the parser above is equivalent to using the header parser and then
the deplen_payload parser
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hp: LowParse.Spec.Base.parser hk ht ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.parse (LowParse.Spec.DepLen.parse_deplen min max hp dlf ps) input ==
(match LowParse.Spec.Base.parse hp input with
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ h consumed) ->
(match FStar.UInt32.v (dlf h) + consumed > FStar.Seq.Base.length input with
| true -> FStar.Pervasives.Native.None
| _ ->
let input' = FStar.Seq.Base.slice input consumed (FStar.Seq.Base.length input) in
(match
LowParse.Spec.Base.parse (LowParse.Spec.DepLen.parse_deplen_payload min
max
dlf
ps
h)
input'
with
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None
| FStar.Pervasives.Native.Some
#_
(FStar.Pervasives.Native.Mktuple2 #_ #_ x consumed') ->
(match consumed' = FStar.UInt32.v (dlf h) with
| true -> FStar.Pervasives.Native.Some (x, consumed + FStar.UInt32.v (dlf h))
| _ -> FStar.Pervasives.Native.None)
<:
FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min
max
dlf
ps *
LowParse.Spec.Base.consumed_length input))
<:
FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min
max
dlf
ps *
LowParse.Spec.Base.consumed_length input))
<:
FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps *
LowParse.Spec.Base.consumed_length input))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Base.consumed_length",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.op_Addition",
"Prims.bool",
"FStar.Seq.Properties.slice_slice",
"Prims.unit",
"FStar.UInt.uint_t",
"FStar.UInt32.v",
"LowParse.Spec.DepLen.parse_deplen_payload_unfold",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"LowParse.Spec.Combinators.parse_tagged_union_eq",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"LowParse.Spec.DepLen.parse_deplen_payload_kind",
"LowParse.Spec.DepLen.parse_deplen_payload",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.DepLen.parse_deplen",
"FStar.Pervasives.Native.None",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.refine_with_tag",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let parse_deplen_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(#pp: parser pk pt)
(ps: serializer pp)
(input: bytes)
: Lemma
(parse (parse_deplen min max hp dlf ps) input ==
(match parse hp input with
| None -> None
| Some (h, consumed) ->
if (U32.v (dlf h) + consumed) > (Seq.length input)
then None
else
let input' = Seq.slice input consumed (Seq.length input) in
match parse (parse_deplen_payload min max dlf ps h) input' with
| None -> None
| Some (x, consumed') ->
if consumed' = U32.v (dlf h) then Some (x, consumed + (U32.v (dlf h))) else None)) =
| parse_tagged_union_eq hp
(calc_tag_of_deplen_data min max dlf ps)
(parse_deplen_payload min max dlf ps)
input;
match parse hp input with
| None -> ()
| Some (h, consumed) ->
let input' = Seq.slice input consumed (Seq.length input) in
parse_deplen_payload_unfold min max dlf ps h input';
let sz = (U32.v (dlf h)) in
if Seq.length input < consumed + sz
then ()
else Seq.slice_slice input consumed (Seq.length input) 0 sz | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.empty_decreaser | val empty_decreaser (#a: Type u#a) (x: a) : Tot (acc_classical (empty_relation #a) x) (decreases x) | val empty_decreaser (#a: Type u#a) (x: a) : Tot (acc_classical (empty_relation #a) x) (decreases x) | let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 47,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a
-> Prims.Tot (FStar.WellFoundedRelation.acc_classical FStar.WellFoundedRelation.empty_relation x) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.empty_relation",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.empty_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
| let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y = empty_decreaser y in
AccClassicalIntro smaller | false |
LowParse.Spec.DepLen.fst | LowParse.Spec.DepLen.parse_deplen_payload_unfold | val parse_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input ==
(match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed))) | val parse_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input ==
(match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed))) | let parse_deplen_payload_unfold
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed)))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then ()
else
parse_synth_eq
(parse_fldata_strong ps sz)
(synth_deplen_data min max dlf ps h)
input | {
"file_name": "src/lowparse/LowParse.Spec.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 157,
"start_col": 0,
"start_line": 128
} | module LowParse.Spec.DepLen
(* LowParse specification module for parsing structures with dependent length
Example:
struct {
uint len;
uint foo;
uint buf[len];
};
*)
include LowParse.Spec.Combinators
include LowParse.Spec.AllIntegers
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module Seq = FStar.Seq
(* arguments
@min :
@max : integer bounds
@ht : header type
@hk : header parser metadata
@hp : header parser
@h : header data
@dlf : dependent length function
@pt : payload type
@pk : payload parser metadata
@pp : payload parser
@ps : payload serializer
@x : data
*)
(* data type of the dependent length parser, which is a pair of the header and the payload *)
let parse_deplen_data_t
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
= x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) }
(* the tag for a piece of dependent length data is just its header *)
let calc_tag_of_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(x : parse_deplen_data_t min max dlf ps)
: GTot ht
= fst x
(* synth put the header and the payload together to get the data *)
let synth_deplen_data
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
(x : parse_fldata_strong_t ps (U32.v (dlf h)))
: Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
= (h, x)
(* metadata of the payload, reuse bounded_vlgen_payload *)
let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind
(* parser spec for the dependent length payload which attaches the header to generate the data *)
let parse_deplen_payload
(min : nat)
(max : nat { min <= max /\ max < 4294967296 } )
(#ht : Type)
(#pt : Type)
(dlf : ht -> Tot (bounded_int32 min max) )
(#pk : parser_kind)
(#pp : parser pk pt)
(ps : serializer pp)
(h : ht)
: Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h))
= let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz || (
match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz
)
in
if bounds_off
then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)
else
weaken (parse_deplen_payload_kind min max pk)
(parse_fldata_strong ps sz
`parse_synth`
synth_deplen_data min max dlf ps h)
(* unfold is a more human readable version and do double-check of the definition
This lemma says using the parser defined above is equivalent to using a fixed-length
parser with the calculated size and then attach the header
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.AllIntegers.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.AllIntegers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
ps: LowParse.Spec.Base.serializer pp ->
h: ht ->
input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.parse (LowParse.Spec.DepLen.parse_deplen_payload min max dlf ps h) input ==
(match
LowParse.Spec.Base.parse (LowParse.Spec.FLData.parse_fldata_strong ps
(FStar.UInt32.v (dlf h)))
input
with
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ x consumed) ->
FStar.Pervasives.Native.Some
(LowParse.Spec.DepLen.synth_deplen_data min max dlf ps h x,
consumed))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.Bytes.bytes",
"Prims.bool",
"LowParse.Spec.Combinators.parse_synth_eq",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.Spec.Base.refine_with_tag",
"LowParse.Spec.DepLen.parse_deplen_data_t",
"LowParse.Spec.DepLen.calc_tag_of_deplen_data",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.DepLen.synth_deplen_data",
"Prims.unit",
"Prims.op_BarBar",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.UInt.uint_t",
"FStar.UInt32.v",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.DepLen.parse_deplen_payload",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let parse_deplen_payload_unfold
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#ht #pt: Type)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pp: parser pk pt)
(ps: serializer pp)
(h: ht)
(input: bytes)
: Lemma
(parse (parse_deplen_payload min max dlf ps h) input ==
(match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with
| None -> None
| Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed))) =
| let sz = (U32.v (dlf h)) in
let bounds_off =
pk.parser_kind_low > sz ||
(match pk.parser_kind_high with
| None -> false
| Some pkmax -> pkmax < sz)
in
if bounds_off
then ()
else parse_synth_eq (parse_fldata_strong ps sz) (synth_deplen_data min max dlf ps h) input | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.default_decreaser | val default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) | val default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) | let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 32,
"start_col": 0,
"start_line": 27
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a
-> Prims.Tot
(FStar.WellFoundedRelation.acc_classical FStar.WellFoundedRelation.default_relation x) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.default_relation",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.default_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
| let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.default_wfr | val default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) | val default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) | let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 80,
"end_line": 40,
"start_col": 0,
"start_line": 34
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type
-> wfr:
FStar.WellFoundedRelation.wfr_t a
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.default_relation} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.WellFoundedRelation.default_relation",
"FStar.WellFoundedRelation.default_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller",
"FStar.WellFoundedRelation.wfr_t",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let default_wfr (a: Type u#a) : (wfr: wfr_t a {wfr.relation == default_relation}) =
| let proof (x1 x2: a)
: Lemma (requires default_relation x1 x2) (ensures default_decreaser x1 << default_decreaser x2)
=
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof } | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.empty_wfr | val empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) | val empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) | let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 76,
"end_line": 54,
"start_col": 0,
"start_line": 49
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type
-> wfr:
FStar.WellFoundedRelation.wfr_t a
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.empty_relation} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.WellFoundedRelation.empty_relation",
"FStar.WellFoundedRelation.empty_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller",
"FStar.WellFoundedRelation.wfr_t",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let empty_wfr (a: Type u#a) : (wfr: wfr_t a {wfr.relation == empty_relation}) =
| let proof (x1 x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof } | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.acc_decreaser | val acc_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(f: WF.well_founded r {forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) | val acc_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(f: WF.well_founded r {forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) | let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 68,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) ->
f:
FStar.WellFounded.well_founded r
{forall (x1: a) (x2: a) (p: r x1 x2). AccIntro?.access_smaller (f x2) x1 p == f x1} ->
x: a
-> Prims.Tot
(FStar.WellFoundedRelation.acc_classical (FStar.WellFoundedRelation.acc_relation r) x) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFounded.well_founded",
"Prims.l_Forall",
"Prims.eq2",
"FStar.WellFounded.acc",
"FStar.WellFounded.__proj__AccIntro__item__access_smaller",
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.acc_relation",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.acc_decreaser",
"Prims.unit",
"FStar.Classical.Sugar.exists_elim",
"Prims.l_True",
"Prims.precedes",
"Prims.squash",
"Prims._assert"
] | [
"recursion"
] | false | false | false | false | false | let rec acc_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(f: WF.well_founded r {forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
| let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) =
(eliminate exists (p: r y x).
True
returns f y << f x
with _.
assert ((f x).access_smaller y p == f y);
acc_decreaser r f y)
in
AccClassicalIntro smaller | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg_st | val rsapss_verify_bn_to_msg_st : t: Hacl.Bignum.Definitions.limb_t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
saltLen:size_t
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 103,
"end_line": 353,
"start_col": 0,
"start_line": 342
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey))
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in
if b then
rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt
else
false
inline_for_extraction noextract
val bn_lt_pow2:
#t:limb_t
-> modBits:size_t{1 < v modBits}
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h -> live h m)
(ensures fun h0 r h1 -> h0 == h1 /\
r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true
else begin
let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in
BB.unsafe_bool_of_limb0 get_bit end
inline_for_extraction noextract
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> m_def:lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h pkey /\ live h m_def /\ live h s /\
disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\
(r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
inline_for_extraction noextract
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@inline_let] let bits = size (bits t) in
let nLen = blocks modBits bits in
let eLen = blocks eBits bits in
let n = sub pkey 0ul nLen in
let r2 = sub pkey nLen nLen in
let e = sub pkey (nLen +! nLen) eLen in
let mask = BN.bn_lt_mask nLen s n in
let h = ST.get () in
SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n);
let res =
if BB.unsafe_bool_of_limb mask then begin
Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits);
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n);
let h0 = ST.get () in
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def;
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 m_def)
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
if bn_lt_pow2 modBits m_def then true
else false end
else false in
res | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Hacl.Spec.RSAPSS.rsapss_verify_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.RSAPSS.rsapss_verify_bn_to_msg"
] | [] | false | false | false | false | true | let rsapss_verify_bn_to_msg_st
(t: limb_t)
(a: Hash.hash_alg{S.hash_is_supported a})
(modBits: modBits_t t)
=
|
saltLen: size_t ->
msgLen: size_t ->
msg: lbuffer uint8 msgLen ->
m: lbignum t (blocks modBits (size (bits t)))
-> Stack bool
(requires
fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures
fun h0 r h1 ->
modifies0 h0 h1 /\
r ==
LS.rsapss_verify_bn_to_msg a
(v modBits)
(v saltLen)
(v msgLen)
(as_seq h0 msg)
(as_seq h0 m)) | false |
|
Normalization.fst | Normalization.def_of | val def_of (#t: Type) (x: t) : Tac term | val def_of (#t: Type) (x: t) : Tac term | let def_of (#t:Type) (x:t) : Tac term =
let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv -> begin
let se = match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
match inspect_sigelt se with
| Sg_Let {lbs} -> begin
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
end
| _ -> fail "not a sig_let"
end
| _ -> fail "not an fvar" | {
"file_name": "examples/tactics/Normalization.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 48,
"start_col": 0,
"start_line": 31
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Normalization
open FStar.Tactics.V2
(* A tactic that returns its argument after some steps of normalization *)
(* NOTE: This is relying on our unusual quote, which can inspect the shape of `x`
* when the function is applied. This could be avoided by taking a `term` instead
* and calling the tactic it with `quote` *)
let normalize (#t:Type) (steps : list norm_step) (x:t) : Tac unit =
dup ();
exact (quote x);
norm steps;
trefl () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Order.fst.checked"
],
"interface_file": false,
"source_file": "Normalization.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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: t -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.Types.fv",
"FStar.Stubs.Reflection.V2.Data.universes",
"Prims.bool",
"Prims.list",
"FStar.Tactics.NamedView.letbinding",
"FStar.Tactics.NamedView.__proj__Mkletbinding__item__lb_def",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.V2.SyntaxHelpers.lookup_lb",
"FStar.Stubs.Reflection.V2.Builtins.inspect_fv",
"FStar.Tactics.NamedView.named_sigelt_view",
"FStar.Tactics.V2.Derived.fail",
"FStar.Tactics.NamedView.inspect_sigelt",
"FStar.Stubs.Reflection.Types.sigelt",
"FStar.Stubs.Reflection.V2.Builtins.lookup_typ",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.NamedView.inspect",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.Types.env",
"FStar.Tactics.V2.Derived.cur_env"
] | [] | false | true | false | false | false | let def_of (#t: Type) (x: t) : Tac term =
| let e = cur_env () in
let t = quote x in
match inspect t with
| Tv_UInst fv _
| Tv_FVar fv ->
let se =
match lookup_typ e (inspect_fv fv) with
| None -> fail "Not found..?"
| Some se -> se
in
(match inspect_sigelt se with
| Sg_Let { lbs = lbs } ->
let lbv = lookup_lb lbs (inspect_fv fv) in
lbv.lb_def
| _ -> fail "not a sig_let")
| _ -> fail "not an fvar" | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.t64_no_mod | val t64_no_mod : Vale.Interop.Base.td | let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 105,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.Arch.HeapTypes_s.Secret"
] | [] | false | false | false | true | false | let t64_no_mod =
| TD_Buffer TUInt64 TUInt64 ({ modified = false; strict_disjointness = false; taint = MS.Secret }) | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.add1_xmms_modified | val add1_xmms_modified : _: _ -> Prims.bool | let add1_xmms_modified = fun _ -> false | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | _: _ -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.bool"
] | [] | false | false | false | true | false | let add1_xmms_modified =
| fun _ -> false | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.uint64 | val uint64 : Prims.eqtype | let uint64 = UInt64.t | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.t"
] | [] | false | false | false | true | false | let uint64 =
| UInt64.t | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.tuint64 | val tuint64 : Vale.Interop.Base.td | let tuint64 = TD_Base TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Base",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | false | false | false | true | false | let tuint64 =
| TD_Base TUInt64 | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.of_reg | val of_reg (r: MS.reg_64) : option (IX64.reg_nat 3) | val of_reg (r: MS.reg_64) : option (IX64.reg_nat 3) | let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 115,
"start_col": 0,
"start_line": 111
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 () | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | r: Vale.X64.Machine_s.reg_64 -> FStar.Pervasives.Native.option (Vale.Interop.X64.reg_nat 3) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.reg_64",
"FStar.Pervasives.Native.Some",
"Vale.Interop.X64.reg_nat",
"Prims.int",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let of_reg (r: MS.reg_64) : option (IX64.reg_nat 3) =
| match r with
| 5 -> Some 0
| 4 -> Some 1
| 3 -> Some 2
| _ -> None | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.b64 | val b64 : Type0 | let b64 = buf_t TUInt64 TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 34,
"start_col": 0,
"start_line": 34
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.buf_t",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | false | false | false | true | true | let b64 =
| buf_t TUInt64 TUInt64 | false |
|
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.acc_to_wfr | val acc_to_wfr (#a: Type u#a) (r: a -> a -> Type0) (f: FStar.WellFounded.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) | val acc_to_wfr (#a: Type u#a) (r: a -> a -> Type0) (f: FStar.WellFounded.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) | let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 78,
"end_line": 86,
"start_col": 0,
"start_line": 78
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) -> f: FStar.WellFounded.well_founded r
-> wfr:
FStar.WellFoundedRelation.wfr_t a
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.acc_relation r} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFounded.binrel",
"FStar.WellFounded.well_founded",
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.WellFoundedRelation.acc_relation",
"FStar.WellFoundedRelation.acc_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller",
"FStar.WellFounded.acc",
"FStar.WellFounded.Util.lift_binrel_as_well_founded_relation",
"Prims.Mkdtuple2",
"FStar.WellFoundedRelation.eta_expand_well_founded",
"FStar.WellFoundedRelation.wfr_t",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a {wfr.relation == acc_relation r}) =
| let f = eta_expand_well_founded r f in
let proof (x1 x2: a)
: Lemma (requires acc_relation r x1 x2) (ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof } | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.subrelation_to_wfr | val subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) | val subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) | let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 75,
"end_line": 104,
"start_col": 0,
"start_line": 96
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) ->
wfr:
FStar.WellFoundedRelation.wfr_t a
{forall (x1: a) (x2: a). r x1 x2 ==> Mkwfr_t?.relation wfr x1 x2}
-> wfr': FStar.WellFoundedRelation.wfr_t a {Mkwfr_t?.relation wfr' == r} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation",
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.WellFoundedRelation.subrelation_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller"
] | [] | false | false | false | false | false | let subrelation_to_wfr
(#a: Type u#a)
(r: (a -> a -> Type0))
(wfr: wfr_t a {forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a {wfr'.relation == r}) =
| let proof (x1 x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof } | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.code_add1 | val code_add1 : Vale.X64.Decls.va_code | let code_add1 = FU.va_code_Fast_add1 () | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 109,
"start_col": 0,
"start_line": 109
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.Curve25519.X64.FastUtil.va_code_Fast_add1"
] | [] | false | false | false | true | false | let code_add1 =
| FU.va_code_Fast_add1 () | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.t64_mod | val t64_mod : Vale.Interop.Base.td | let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 36,
"start_col": 0,
"start_line": 36
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Vale.Interop.Base.default_bq"
] | [] | false | false | false | true | false | let t64_mod =
| TD_Buffer TUInt64 TUInt64 default_bq | false |
|
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.subrelation_decreaser | val subrelation_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(wfr: wfr_t a {forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) | val subrelation_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(wfr: wfr_t a {forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) | let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 94,
"start_col": 0,
"start_line": 88
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) ->
wfr:
FStar.WellFoundedRelation.wfr_t a
{forall (x1: a) (x2: a). r x1 x2 ==> Mkwfr_t?.relation wfr x1 x2} ->
x: a
-> Prims.Tot (FStar.WellFoundedRelation.acc_classical r x) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation",
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.subrelation_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec subrelation_decreaser
(#a: Type u#a)
(r: (a -> a -> Type0))
(wfr: wfr_t a {forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
| let smaller (y: a{r y x}) : (acc_classical r y) = subrelation_decreaser r wfr y in
AccClassicalIntro smaller | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.inverse_image_to_wfr | val inverse_image_to_wfr
(#a: Type u#a)
(#b: Type u#b)
(r: a -> a -> Type0)
(f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) | val inverse_image_to_wfr
(#a: Type u#a)
(#b: Type u#b)
(r: a -> a -> Type0)
(f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) | let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 79,
"end_line": 124,
"start_col": 0,
"start_line": 115
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) ->
f: (_: a -> b) ->
wfr:
FStar.WellFoundedRelation.wfr_t b
{forall (x1: a) (x2: a). r x1 x2 ==> Mkwfr_t?.relation wfr (f x1) (f x2)}
-> wfr': FStar.WellFoundedRelation.wfr_t a {Mkwfr_t?.relation wfr' == r} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation",
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.WellFoundedRelation.inverse_image_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller"
] | [] | false | false | false | false | false | let inverse_image_to_wfr
(#a: Type u#a)
(#b: Type u#b)
(r: (a -> a -> Type0))
(f: (a -> b))
(wfr: wfr_t b {forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a {wfr'.relation == r}) =
| let proof (x1 x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof } | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.inverse_image_decreaser | val inverse_image_decreaser
(#a: Type u#a)
(#b: Type u#b)
(r: (a -> a -> Type0))
(f: (a -> b))
(wfr: wfr_t b {forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) | val inverse_image_decreaser
(#a: Type u#a)
(#b: Type u#b)
(r: (a -> a -> Type0))
(f: (a -> b))
(wfr: wfr_t b {forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) | let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 113,
"start_col": 0,
"start_line": 106
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> Type0) ->
f: (_: a -> b) ->
wfr:
FStar.WellFoundedRelation.wfr_t b
{forall (x1: a) (x2: a). r x1 x2 ==> Mkwfr_t?.relation wfr (f x1) (f x2)} ->
x: a
-> Prims.Tot (FStar.WellFoundedRelation.acc_classical r x) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation",
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.inverse_image_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec inverse_image_decreaser
(#a: Type u#a)
(#b: Type u#b)
(r: (a -> a -> Type0))
(f: (a -> b))
(wfr: wfr_t b {forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
| let smaller (y: a{r y x}) : (acc_classical r y) = inverse_image_decreaser r f wfr y in
AccClassicalIntro smaller | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.lex_nondep_wfr | val lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} | val lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} | let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} =
let proof (xy1: a * b) (xy2: a * b)
: Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2)
(ensures lex_nondep_decreaser wfr_a wfr_b xy1 <<
lex_nondep_decreaser wfr_a wfr_b xy2) =
assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 ==
lex_nondep_decreaser wfr_a wfr_b xy1)
in
{ relation = lex_nondep_relation wfr_a wfr_b;
decreaser = lex_nondep_decreaser wfr_a wfr_b;
proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 147,
"start_col": 0,
"start_line": 136
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller
let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; }
let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) =
let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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 | wfr_a: FStar.WellFoundedRelation.wfr_t a -> wfr_b: FStar.WellFoundedRelation.wfr_t b
-> wfr:
FStar.WellFoundedRelation.wfr_t (a * b)
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.lex_nondep_relation wfr_a wfr_b} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"FStar.WellFoundedRelation.Mkwfr_t",
"FStar.Pervasives.Native.tuple2",
"FStar.WellFoundedRelation.lex_nondep_relation",
"FStar.WellFoundedRelation.lex_nondep_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b) {wfr.relation == lex_nondep_relation wfr_a wfr_b} =
| let proof (xy1 xy2: a * b)
: Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2)
(ensures lex_nondep_decreaser wfr_a wfr_b xy1 << lex_nondep_decreaser wfr_a wfr_b xy2) =
assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 ==
lex_nondep_decreaser wfr_a wfr_b xy1)
in
{
relation = lex_nondep_relation wfr_a wfr_b;
decreaser = lex_nondep_decreaser wfr_a wfr_b;
proof = proof
} | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.fadd_xmms_modified | val fadd_xmms_modified : _: _ -> Prims.bool | let fadd_xmms_modified = fun _ -> false | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 213,
"start_col": 0,
"start_line": 213
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x
let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"]
let add1_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> ""
let add1_code_inline () : FStar.All.ML int =
PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
[@__reduce__]
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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 50"
let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | _: _ -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.bool"
] | [] | false | false | false | true | false | let fadd_xmms_modified =
| fun _ -> false | false |
|
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.add1_names | val add1_names : n: Prims.nat -> Prims.string | let add1_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> "" | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 172,
"start_col": 0,
"start_line": 167
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x
let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | n: Prims.nat -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.int",
"Prims.string"
] | [] | false | false | false | true | false | let add1_names (n: nat) =
| match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> "" | false |
|
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.lex_nondep_decreaser | val lex_nondep_decreaser
(#a: Type u#a)
(#b: Type u#b)
(wfr_a: wfr_t a)
(wfr_b: wfr_t b)
(xy: (a * b))
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy);wfr_b.decreaser (snd xy)]) | val lex_nondep_decreaser
(#a: Type u#a)
(#b: Type u#b)
(wfr_a: wfr_t a)
(wfr_b: wfr_t b)
(xy: (a * b))
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy);wfr_b.decreaser (snd xy)]) | let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) =
let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 134,
"start_col": 0,
"start_line": 126
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller
let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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 | wfr_a: FStar.WellFoundedRelation.wfr_t a -> wfr_b: FStar.WellFoundedRelation.wfr_t b -> xy: (a * b)
-> Prims.Tot
(FStar.WellFoundedRelation.acc_classical (FStar.WellFoundedRelation.lex_nondep_relation wfr_a
wfr_b)
xy) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"FStar.Pervasives.Native.tuple2",
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.lex_nondep_relation",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.lex_nondep_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec lex_nondep_decreaser
(#a: Type u#a)
(#b: Type u#b)
(wfr_a: wfr_t a)
(wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy);wfr_b.decreaser (snd xy)]) =
| let smaller (xy': (a * b) {lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.add1_comments | val add1_comments:list string | val add1_comments:list string | let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 97,
"end_line": 165,
"start_col": 0,
"start_line": 164
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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 | Prims.list Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | false | false | false | true | false | let add1_comments:list string =
| ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.bool_wfr | val bool_wfr: (wfr: wfr_t bool{wfr.relation == bool_relation}) | val bool_wfr: (wfr: wfr_t bool{wfr.relation == bool_relation}) | let bool_wfr: (wfr: wfr_t bool{wfr.relation == bool_relation}) =
inverse_image_to_wfr #bool #nat bool_relation (fun b -> if b then 1 else 0) (default_wfr nat) | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 95,
"end_line": 174,
"start_col": 0,
"start_line": 173
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller
let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; }
let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) =
let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller
let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} =
let proof (xy1: a * b) (xy2: a * b)
: Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2)
(ensures lex_nondep_decreaser wfr_a wfr_b xy1 <<
lex_nondep_decreaser wfr_a wfr_b xy2) =
assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 ==
lex_nondep_decreaser wfr_a wfr_b xy1)
in
{ relation = lex_nondep_relation wfr_a wfr_b;
decreaser = lex_nondep_decreaser wfr_a wfr_b;
proof = proof; }
let rec lex_dep_decreaser (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x))) (xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy); (a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) =
let smaller (xy': (x: a & b x){lex_dep_relation wfr_a a_to_wfr_b xy' xy})
: (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy') =
lex_dep_decreaser wfr_a a_to_wfr_b xy'
in
AccClassicalIntro smaller
let lex_dep_wfr (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
: wfr: wfr_t (x: a & b x){wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} =
let proof (xy1: (x: a & b x)) (xy2: (x: a & b x))
: Lemma (requires lex_dep_relation wfr_a a_to_wfr_b xy1 xy2)
(ensures lex_dep_decreaser wfr_a a_to_wfr_b xy1 <<
lex_dep_decreaser wfr_a a_to_wfr_b xy2) =
assert ((lex_dep_decreaser wfr_a a_to_wfr_b xy2).access_smaller xy1 ==
lex_dep_decreaser wfr_a a_to_wfr_b xy1)
in
{ relation = lex_dep_relation wfr_a a_to_wfr_b;
decreaser = lex_dep_decreaser wfr_a a_to_wfr_b;
proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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 | wfr:
FStar.WellFoundedRelation.wfr_t Prims.bool
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.bool_relation} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.inverse_image_to_wfr",
"Prims.bool",
"Prims.nat",
"FStar.WellFoundedRelation.bool_relation",
"FStar.WellFoundedRelation.default_wfr",
"FStar.WellFoundedRelation.wfr_t",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let bool_wfr:(wfr: wfr_t bool {wfr.relation == bool_relation}) =
| inverse_image_to_wfr #bool #nat bool_relation (fun b -> if b then 1 else 0) (default_wfr nat) | false |
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.lex_dep_decreaser | val lex_dep_decreaser
(#a: Type u#a)
(#b: (a -> Type u#b))
(wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
(xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy);(a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) | val lex_dep_decreaser
(#a: Type u#a)
(#b: (a -> Type u#b))
(wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
(xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy);(a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) | let rec lex_dep_decreaser (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x))) (xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy); (a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) =
let smaller (xy': (x: a & b x){lex_dep_relation wfr_a a_to_wfr_b xy' xy})
: (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy') =
lex_dep_decreaser wfr_a a_to_wfr_b xy'
in
AccClassicalIntro smaller | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 157,
"start_col": 0,
"start_line": 149
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller
let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; }
let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) =
let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller
let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} =
let proof (xy1: a * b) (xy2: a * b)
: Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2)
(ensures lex_nondep_decreaser wfr_a wfr_b xy1 <<
lex_nondep_decreaser wfr_a wfr_b xy2) =
assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 ==
lex_nondep_decreaser wfr_a wfr_b xy1)
in
{ relation = lex_nondep_relation wfr_a wfr_b;
decreaser = lex_nondep_decreaser wfr_a wfr_b;
proof = proof; } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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 |
wfr_a: FStar.WellFoundedRelation.wfr_t a ->
a_to_wfr_b: (x: a -> FStar.WellFoundedRelation.wfr_t (b x)) ->
xy: Prims.dtuple2 a (fun x -> b x)
-> Prims.Tot
(FStar.WellFoundedRelation.acc_classical (FStar.WellFoundedRelation.lex_dep_relation wfr_a
a_to_wfr_b)
xy) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"Prims.dtuple2",
"FStar.WellFoundedRelation.AccClassicalIntro",
"FStar.WellFoundedRelation.lex_dep_relation",
"FStar.WellFoundedRelation.acc_classical",
"FStar.WellFoundedRelation.lex_dep_decreaser"
] | [
"recursion"
] | false | false | false | false | false | let rec lex_dep_decreaser
(#a: Type u#a)
(#b: (a -> Type u#b))
(wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
(xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy);(a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) =
| let smaller (xy': (x: a & b x){lex_dep_relation wfr_a a_to_wfr_b xy' xy})
: (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy') =
lex_dep_decreaser wfr_a a_to_wfr_b xy'
in
AccClassicalIntro smaller | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.fadd_post | val fadd_post:VSig.vale_post fadd_dom | val fadd_post:VSig.vale_post fadd_dom | 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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 97,
"end_line": 204,
"start_col": 0,
"start_line": 196
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
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 PR = Vale.X64.Print_Inline_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 *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
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 code va_s0 (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;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x
let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"]
let add1_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> ""
let add1_code_inline () : FStar.All.ML int =
PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
[@__reduce__]
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__]
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 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.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.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",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"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.Print_Inline_s",
"short_module": "PR"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"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": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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.Inline.X64.Fadd_inline.fadd_dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Inline.X64.Fadd_inline.b64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.Curve25519.X64.FastHybrid.va_ens_Fadd",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.prop"
] | [] | false | false | false | true | false | 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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_verify_st | val rsapss_verify_st : t: Hacl.Bignum.Definitions.limb_t ->
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgntLen:size_t
-> sgnt:lbuffer uint8 sgntLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 488,
"start_col": 0,
"start_line": 471
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey))
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in
if b then
rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt
else
false
inline_for_extraction noextract
val bn_lt_pow2:
#t:limb_t
-> modBits:size_t{1 < v modBits}
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h -> live h m)
(ensures fun h0 r h1 -> h0 == h1 /\
r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true
else begin
let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in
BB.unsafe_bool_of_limb0 get_bit end
inline_for_extraction noextract
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> m_def:lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h pkey /\ live h m_def /\ live h s /\
disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\
(r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
inline_for_extraction noextract
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@inline_let] let bits = size (bits t) in
let nLen = blocks modBits bits in
let eLen = blocks eBits bits in
let n = sub pkey 0ul nLen in
let r2 = sub pkey nLen nLen in
let e = sub pkey (nLen +! nLen) eLen in
let mask = BN.bn_lt_mask nLen s n in
let h = ST.get () in
SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n);
let res =
if BB.unsafe_bool_of_limb mask then begin
Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits);
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n);
let h0 = ST.get () in
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def;
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 m_def)
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
if bn_lt_pow2 modBits m_def then true
else false end
else false in
res
inline_for_extraction noextract
let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
saltLen:size_t
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_verify_bn_to_msg:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_bn_to_msg_st t a modBits
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits == v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let m1 = sub m 0ul mLen in
BN.bn_to_bytes_be emLen m1 em;
let res = RP.pss_verify a saltLen msgLen msg emBits em in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> m:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h pkey /\ live h m /\
disjoint m sgnt /\ disjoint m pkey /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_verify_compute_msg:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_verify_compute_msg_st t ke modBits
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_from_bytes_be k sgnt s;
let b = rsapss_verify_bn #t ke modBits eBits pkey m s in
pop_frame ();
b
inline_for_extraction noextract
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits
let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in
let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in
pop_frame ();
res | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.pkey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Prims.eq2",
"Prims.l_or",
"Prims.int",
"Lib.IntTypes.range",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"FStar.Mul.op_Star",
"Hacl.Spec.Bignum.Definitions.blocks",
"Prims.op_LessThan",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Hacl.Spec.RSAPSS.rsapss_pkey_pre",
"Lib.Buffer.as_seq",
"Lib.Buffer.modifies0",
"Hacl.Spec.RSAPSS.rsapss_verify",
"Lib.IntTypes.int_t",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.IntTypes.mk_int"
] | [] | false | false | false | false | true | let rsapss_verify_st
(t: limb_t)
(ke: BE.exp t)
(a: Hash.hash_alg{S.hash_is_supported a})
(modBits: modBits_t t)
=
| let len = blocks modBits (size (bits t)) in
eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} ->
pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) ->
saltLen: size_t ->
sgntLen: size_t ->
sgnt: lbuffer uint8 sgntLen ->
msgLen: size_t ->
msg: lbuffer uint8 msgLen
-> Stack bool
(requires
fun h ->
len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\
disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures
fun h0 r h1 ->
modifies0 h0 h1 /\
r ==
LS.rsapss_verify a
(v modBits)
(v eBits)
(as_seq h0 pkey)
(v saltLen)
(v sgntLen)
(as_seq h0 sgnt)
(v msgLen)
(as_seq h0 msg)) | false |
|
FStar.WellFoundedRelation.fst | FStar.WellFoundedRelation.lex_dep_wfr | val lex_dep_wfr (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
: wfr: wfr_t (x: a & b x){wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} | val lex_dep_wfr (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
: wfr: wfr_t (x: a & b x){wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} | let lex_dep_wfr (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
: wfr: wfr_t (x: a & b x){wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} =
let proof (xy1: (x: a & b x)) (xy2: (x: a & b x))
: Lemma (requires lex_dep_relation wfr_a a_to_wfr_b xy1 xy2)
(ensures lex_dep_decreaser wfr_a a_to_wfr_b xy1 <<
lex_dep_decreaser wfr_a a_to_wfr_b xy2) =
assert ((lex_dep_decreaser wfr_a a_to_wfr_b xy2).access_smaller xy1 ==
lex_dep_decreaser wfr_a a_to_wfr_b xy1)
in
{ relation = lex_dep_relation wfr_a a_to_wfr_b;
decreaser = lex_dep_decreaser wfr_a a_to_wfr_b;
proof = proof; } | {
"file_name": "ulib/FStar.WellFoundedRelation.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 171,
"start_col": 0,
"start_line": 159
} | (*
Copyright 2022 Jay Lorch and Nikhil Swamy, 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.
*)
(* This library is intended to simplify using well-founded relations
in decreases clauses.
*)
module FStar.WellFoundedRelation
open FStar.Universe
module WF = FStar.WellFounded
module WFU = FStar.WellFounded.Util
let rec default_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (default_relation #a) x) (decreases x) =
let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y =
default_decreaser y
in
AccClassicalIntro smaller
let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires default_relation x1 x2)
(ensures default_decreaser x1 << default_decreaser x2) =
assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1)
in
{ relation = default_relation; decreaser = default_decreaser; proof = proof; }
let rec empty_decreaser (#a: Type u#a) (x: a)
: Tot (acc_classical (empty_relation #a) x) (decreases x) =
let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y =
empty_decreaser y
in
AccClassicalIntro smaller
let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) =
let proof (x1: a) (x2: a)
: Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) =
assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1)
in
{ relation = empty_relation; decreaser = empty_decreaser; proof = proof; }
let rec acc_decreaser
(#a: Type u#a)
(r: a -> a -> Type0)
(f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1})
(x: a)
: Tot (acc_classical (acc_relation r) x) (decreases (f x)) =
let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = (
eliminate exists (p: r y x). True
returns f y << f x
with _. assert ((f x).access_smaller y p == f y);
acc_decreaser r f y
) in
AccClassicalIntro smaller
let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a)
: Tot (WF.acc r x)
(decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)})
= WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y =
WFU.intro_lift_binrel r y x;
eta_expand_well_founded r wf_r y
in g_smaller)
let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r)
: (wfr: wfr_t a{wfr.relation == acc_relation r}) =
let f = eta_expand_well_founded r f in
let proof (x1: a) (x2: a)
: Lemma (requires acc_relation r x1 x2)
(ensures acc_decreaser r f x1 << acc_decreaser r f x2) =
assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1)
in
{ relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; }
let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser x) =
let smaller (y: a{r y x}) : (acc_classical r y) =
subrelation_decreaser r wfr y
in
AccClassicalIntro smaller
let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0)
(wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) =
assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1)
in
{ relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; }
let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
(x: a)
: Tot (acc_classical r x) (decreases wfr.decreaser (f x)) =
let smaller (y: a{r y x}) : (acc_classical r y) =
inverse_image_decreaser r f wfr y
in
AccClassicalIntro smaller
let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b)
(wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)})
: (wfr': wfr_t a{wfr'.relation == r}) =
let proof (x1: a) (x2: a)
: Lemma (requires r x1 x2)
(ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) =
assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 ==
inverse_image_decreaser r f wfr x1)
in
{ relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; }
let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
(xy: a * b)
: Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy)
(decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) =
let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy})
: (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') =
lex_nondep_decreaser wfr_a wfr_b xy'
in
AccClassicalIntro smaller
let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b)
: wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} =
let proof (xy1: a * b) (xy2: a * b)
: Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2)
(ensures lex_nondep_decreaser wfr_a wfr_b xy1 <<
lex_nondep_decreaser wfr_a wfr_b xy2) =
assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 ==
lex_nondep_decreaser wfr_a wfr_b xy1)
in
{ relation = lex_nondep_relation wfr_a wfr_b;
decreaser = lex_nondep_decreaser wfr_a wfr_b;
proof = proof; }
let rec lex_dep_decreaser (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x))) (xy: (x: a & b x))
: Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy)
(decreases %[wfr_a.decreaser (dfst xy); (a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) =
let smaller (xy': (x: a & b x){lex_dep_relation wfr_a a_to_wfr_b xy' xy})
: (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy') =
lex_dep_decreaser wfr_a a_to_wfr_b xy'
in
AccClassicalIntro smaller | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.WellFounded.Util.fsti.checked",
"FStar.WellFounded.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.WellFoundedRelation.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.WellFounded.Util",
"short_module": "WFU"
},
{
"abbrev": true,
"full_module": "FStar.WellFounded",
"short_module": "WF"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": 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 |
wfr_a: FStar.WellFoundedRelation.wfr_t a ->
a_to_wfr_b: (x: a -> FStar.WellFoundedRelation.wfr_t (b x))
-> wfr:
FStar.WellFoundedRelation.wfr_t (Prims.dtuple2 a (fun x -> b x))
{Mkwfr_t?.relation wfr == FStar.WellFoundedRelation.lex_dep_relation wfr_a a_to_wfr_b} | Prims.Tot | [
"total"
] | [] | [
"FStar.WellFoundedRelation.wfr_t",
"FStar.WellFoundedRelation.Mkwfr_t",
"Prims.dtuple2",
"FStar.WellFoundedRelation.lex_dep_relation",
"FStar.WellFoundedRelation.lex_dep_decreaser",
"Prims.unit",
"Prims.squash",
"Prims.precedes",
"FStar.WellFoundedRelation.acc_classical",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.eq2",
"FStar.WellFoundedRelation.__proj__AccClassicalIntro__item__access_smaller",
"FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation"
] | [] | false | false | false | false | false | let lex_dep_wfr
(#a: Type u#a)
(#b: (a -> Type u#b))
(wfr_a: wfr_t a)
(a_to_wfr_b: (x: a -> wfr_t (b x)))
: wfr: wfr_t (x: a & b x) {wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} =
| let proof (xy1 xy2: (x: a & b x))
: Lemma (requires lex_dep_relation wfr_a a_to_wfr_b xy1 xy2)
(ensures lex_dep_decreaser wfr_a a_to_wfr_b xy1 << lex_dep_decreaser wfr_a a_to_wfr_b xy2) =
assert ((lex_dep_decreaser wfr_a a_to_wfr_b xy2).access_smaller xy1 ==
lex_dep_decreaser wfr_a a_to_wfr_b xy1)
in
{
relation = lex_dep_relation wfr_a a_to_wfr_b;
decreaser = lex_dep_decreaser wfr_a a_to_wfr_b;
proof = proof
} | false |