effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val state_theta_inner_C (s: state) (i: size_nat{i < 5}) (_C: lseq uint64 5) : Tot (lseq uint64 5) | [
{
"abbrev": false,
"full_module": "Spec.SHA3.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) =
_C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 | val state_theta_inner_C (s: state) (i: size_nat{i < 5}) (_C: lseq uint64 5) : Tot (lseq uint64 5)
let state_theta_inner_C (s: state) (i: size_nat{i < 5}) (_C: lseq uint64 5) : Tot (lseq uint64 5) = | false | null | false | _C.[ i ] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 | {
"checked_file": "Spec.SHA3.fst.checked",
"dependencies": [
"Spec.SHA3.Constants.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.fst"
} | [
"total"
] | [
"Spec.SHA3.state",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Lib.Sequence.op_String_Assignment",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA3.get"
] | [] | module Spec.SHA3
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open FStar.Mul
open Lib.LoopCombinators
open Spec.SHA3.Constants
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
unfold
type state = lseq uint64 25
unfold
type index = n:size_nat{n < 5}
let get (s:state) (x:index) (y:index) : Tot uint64 =
s.[x + 5 * y]
let set (s:state) (x:index) (y:index) (v:uint64) : Tot state =
s.[x + 5 * y] <- v
let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 =
rotate_left a b | false | false | Spec.SHA3.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_theta_inner_C (s: state) (i: size_nat{i < 5}) (_C: lseq uint64 5) : Tot (lseq uint64 5) | [] | Spec.SHA3.state_theta_inner_C | {
"file_name": "specs/Spec.SHA3.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Spec.SHA3.state -> i: Lib.IntTypes.size_nat{i < 5} -> _C: Lib.Sequence.lseq Lib.IntTypes.uint64 5
-> Lib.Sequence.lseq Lib.IntTypes.uint64 5 | {
"end_col": 73,
"end_line": 29,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | val storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200) | [
{
"abbrev": false,
"full_module": "Spec.SHA3.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) =
update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) | val storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200)
let storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200) = | false | null | false | update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[ j ]) | {
"checked_file": "Spec.SHA3.fst.checked",
"dependencies": [
"Spec.SHA3.Constants.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.fst"
} | [
"total"
] | [
"Spec.SHA3.state",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.update_sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.IntTypes.U64",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.uint64"
] | [] | module Spec.SHA3
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open FStar.Mul
open Lib.LoopCombinators
open Spec.SHA3.Constants
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
unfold
type state = lseq uint64 25
unfold
type index = n:size_nat{n < 5}
let get (s:state) (x:index) (y:index) : Tot uint64 =
s.[x + 5 * y]
let set (s:state) (x:index) (y:index) (v:uint64) : Tot state =
s.[x + 5 * y] <- v
let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 =
rotate_left a b
let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) =
_C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4
let state_theta0 (s:state) (_C:lseq uint64 5) =
repeati 5 (state_theta_inner_C s) _C
let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state =
set s x y (get s x y ^. _D)
let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state =
let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in
repeati 5 (state_theta_inner_s_inner x _D) s
let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state =
repeati 5 (state_theta_inner_s _C) s
let state_theta (s:state) : Tot state =
let _C = create 5 (u64 0) in
let _C = state_theta0 s _C in
state_theta1 s _C
let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) =
let r = keccak_rotc.[i] in
let _Y = v keccak_piln.[i] in
let temp = s.[_Y] in
let s = s.[_Y] <- rotl current r in
let current = temp in
current, s
val state_pi_rho_s: i:size_nat{i <= 24} -> Type0
let state_pi_rho_s i = uint64 & state
let state_pi_rho (s_theta:state) : Tot state =
let current = get s_theta 1 0 in
let _, s_pi_rho = repeat_gen 24 state_pi_rho_s
state_pi_rho_inner (current, s_theta) in
s_pi_rho
let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state =
set s x y
(get s_pi_rho x y ^.
((lognot (get s_pi_rho ((x + 1) % 5) y)) &.
get s_pi_rho ((x + 2) % 5) y))
let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state =
repeati 5 (state_chi_inner0 s_pi_rho y) s
let state_chi (s_pi_rho:state) : Tot state =
repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho
let state_iota (s:state) (round:size_nat{round < 24}) : Tot state =
set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round])
let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state =
let s_theta = state_theta s in
let s_pi_rho = state_pi_rho s_theta in
let s_chi = state_chi s_pi_rho in
let s_iota = state_iota s_chi round in
s_iota
let state_permute (s:state) : Tot state =
repeati 24 state_permute1 s
let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state =
s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8)
let loadState
(rateInBytes:size_nat{rateInBytes <= 200})
(input:lbytes rateInBytes)
(s:state) :
Tot state =
let block = create 200 (u8 0) in
let block = update_sub block 0 rateInBytes input in
repeati 25 (loadState_inner block) s | false | false | Spec.SHA3.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200) | [] | Spec.SHA3.storeState_inner | {
"file_name": "specs/Spec.SHA3.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Spec.SHA3.state -> j: Lib.IntTypes.size_nat{j < 25} -> block: Lib.ByteSequence.lbytes 200
-> Lib.ByteSequence.lbytes 200 | {
"end_col": 58,
"end_line": 106,
"start_col": 2,
"start_line": 106
} |
Prims.Tot | val amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction | val amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs
let amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs = | false | null | false | AM.bn_almost_mont_mul bn_inst areduction | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.AlmostMontgomery.bn_almost_mont_mul",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst",
"Hacl.Bignum256_32.areduction"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs | [] | Hacl.Bignum256_32.amont_mul | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.AlmostMontgomery.bn_almost_mont_mul_st Hacl.Bignum256_32.t_limbs
Hacl.Bignum256_32.n_limbs | {
"end_col": 42,
"end_line": 90,
"start_col": 2,
"start_line": 90
} |
Prims.Tot | val from:BM.bn_from_mont_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction | val from:BM.bn_from_mont_st t_limbs n_limbs
let from:BM.bn_from_mont_st t_limbs n_limbs = | false | null | false | BM.bn_from_mont bn_inst reduction | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Montgomery.bn_from_mont",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst",
"Hacl.Bignum256_32.reduction"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val from:BM.bn_from_mont_st t_limbs n_limbs | [] | Hacl.Bignum256_32.from | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Montgomery.bn_from_mont_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 35,
"end_line": 62,
"start_col": 2,
"start_line": 62
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bn_inst:BN.bn t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
} | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bn_inst:BN.bn t_limbs
[@@ FStar.Tactics.Typeclasses.tcinstance]
let bn_inst:BN.bn t_limbs = | false | null | false | {
BN.len = n_limbs;
BN.add = add;
BN.sub = sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul = mul;
BN.sqr = sqr
} | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Mkbn",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.add",
"Hacl.Bignum256_32.sub",
"Hacl.Bignum256_32.add_mod",
"Hacl.Bignum256_32.sub_mod",
"Hacl.Bignum256_32.mul",
"Hacl.Bignum256_32.sqr"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bn_inst:BN.bn t_limbs | [] | Hacl.Bignum256_32.bn_inst | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn Hacl.Bignum256_32.t_limbs | {
"end_col": 8,
"end_line": 41,
"start_col": 2,
"start_line": 35
} |
Prims.Tot | val bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst | val bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs
let bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs = | false | null | false | BR.bn_mod_slow_precomp almost_mont_inst | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.ModReduction.bn_mod_slow_precomp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.almost_mont_inst"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.bn_slow_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.ModReduction.bn_mod_slow_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 41,
"end_line": 110,
"start_col": 2,
"start_line": 110
} |
Prims.Tot | [@@ FStar.Tactics.Typeclasses.tcinstance]
val almost_mont_inst:AM.almost_mont t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
} | [@@ FStar.Tactics.Typeclasses.tcinstance]
val almost_mont_inst:AM.almost_mont t_limbs
[@@ FStar.Tactics.Typeclasses.tcinstance]
let almost_mont_inst:AM.almost_mont t_limbs = | false | null | false | {
AM.bn = bn_inst;
AM.mont_check = mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to = to;
AM.from = from;
AM.mul = amont_mul;
AM.sqr = amont_sqr
} | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.AlmostMontgomery.Mkalmost_mont",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst",
"Hacl.Bignum256_32.mont_check",
"Hacl.Bignum256_32.precompr2",
"Hacl.Bignum256_32.areduction",
"Hacl.Bignum256_32.to",
"Hacl.Bignum256_32.from",
"Hacl.Bignum256_32.amont_mul",
"Hacl.Bignum256_32.amont_sqr"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | [@@ FStar.Tactics.Typeclasses.tcinstance]
val almost_mont_inst:AM.almost_mont t_limbs | [] | Hacl.Bignum256_32.almost_mont_inst | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.AlmostMontgomery.almost_mont Hacl.Bignum256_32.t_limbs | {
"end_col": 21,
"end_line": 105,
"start_col": 2,
"start_line": 98
} |
Prims.Tot | val new_bn_from_bytes_be: BS.new_bn_from_bytes_be_st t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let new_bn_from_bytes_be = BS.new_bn_from_bytes_be | val new_bn_from_bytes_be: BS.new_bn_from_bytes_be_st t_limbs
let new_bn_from_bytes_be = | false | null | false | BS.new_bn_from_bytes_be | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.SafeAPI.new_bn_from_bytes_be",
"Hacl.Bignum256_32.t_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val new_bn_from_bytes_be: BS.new_bn_from_bytes_be_st t_limbs | [] | Hacl.Bignum256_32.new_bn_from_bytes_be | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.new_bn_from_bytes_be_st Hacl.Bignum256_32.t_limbs | {
"end_col": 50,
"end_line": 163,
"start_col": 27,
"start_line": 163
} |
Prims.Tot | val mont_check:BM.bn_check_modulus_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus | val mont_check:BM.bn_check_modulus_st t_limbs n_limbs
let mont_check:BM.bn_check_modulus_st t_limbs n_limbs = | false | null | false | BM.bn_check_modulus | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Montgomery.bn_check_modulus",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mont_check:BM.bn_check_modulus_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mont_check | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Montgomery.bn_check_modulus_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 21,
"end_line": 46,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | val lt_mask: BN.bn_lt_mask_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lt_mask = BN.bn_lt_mask n_limbs | val lt_mask: BN.bn_lt_mask_st t_limbs n_limbs
let lt_mask = | false | null | false | BN.bn_lt_mask n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_lt_mask",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
let new_bn_from_bytes_le = BS.new_bn_from_bytes_le
let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes
let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lt_mask: BN.bn_lt_mask_st t_limbs n_limbs | [] | Hacl.Bignum256_32.lt_mask | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_lt_mask_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 35,
"end_line": 171,
"start_col": 14,
"start_line": 171
} |
Prims.Tot | val exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs | val exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs
let exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs = | false | null | false | BE.bn_check_mod_exp n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Exponentiation.bn_check_mod_exp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.exp_check | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Exponentiation.bn_check_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 29,
"end_line": 116,
"start_col": 2,
"start_line": 116
} |
Prims.Tot | val to:BM.bn_to_mont_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction | val to:BM.bn_to_mont_st t_limbs n_limbs
let to:BM.bn_to_mont_st t_limbs n_limbs = | false | null | false | BM.bn_to_mont bn_inst reduction | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Montgomery.bn_to_mont",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst",
"Hacl.Bignum256_32.reduction"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to:BM.bn_to_mont_st t_limbs n_limbs | [] | Hacl.Bignum256_32.to | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Montgomery.bn_to_mont_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 33,
"end_line": 58,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | val sub: BN.bn_sub_eq_len_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs | val sub: BN.bn_sub_eq_len_st t_limbs n_limbs
let sub:BN.bn_sub_eq_len_st t_limbs n_limbs = | false | null | false | BN.bn_sub_eq_len n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_sub_eq_len",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_sub_eq_len_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub: BN.bn_sub_eq_len_st t_limbs n_limbs | [] | Hacl.Bignum256_32.sub | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_sub_eq_len_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 26,
"end_line": 18,
"start_col": 2,
"start_line": 18
} |
Prims.Tot | val amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction | val amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs
let amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs = | false | null | false | AM.bn_almost_mont_sqr bn_inst areduction | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.AlmostMontgomery.bn_almost_mont_sqr",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst",
"Hacl.Bignum256_32.areduction"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs | [] | Hacl.Bignum256_32.amont_sqr | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.AlmostMontgomery.bn_almost_mont_sqr_st Hacl.Bignum256_32.t_limbs
Hacl.Bignum256_32.n_limbs | {
"end_col": 42,
"end_line": 94,
"start_col": 2,
"start_line": 94
} |
Prims.Tot | val mont_ctx_init: MA.bn_field_init_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n | val mont_ctx_init: MA.bn_field_init_st t_limbs n_limbs
let mont_ctx_init r n = | false | null | false | MA.bn_field_init n_limbs precompr2 r n | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.MontArithmetic.bn_field_init",
"Hacl.Bignum256_32.precompr2",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mont_ctx_init: MA.bn_field_init_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mont_ctx_init | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.MontArithmetic.bn_field_init_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 40,
"end_line": 145,
"start_col": 2,
"start_line": 145
} |
Prims.Tot | val mont_ctx_free: MA.bn_field_free_st t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mont_ctx_free k =
MA.bn_field_free k | val mont_ctx_free: MA.bn_field_free_st t_limbs
let mont_ctx_free k = | false | null | false | MA.bn_field_free k | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum.MontArithmetic.bn_field_free",
"Prims.unit"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mont_ctx_free: MA.bn_field_free_st t_limbs | [] | Hacl.Bignum256_32.mont_ctx_free | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.MontArithmetic.bn_field_free_st Hacl.Bignum256_32.t_limbs | {
"end_col": 20,
"end_line": 148,
"start_col": 2,
"start_line": 148
} |
Prims.Tot | val mod_inv_prime_vartime_precomp: BS.bn_mod_inv_prime_ctx_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res | val mod_inv_prime_vartime_precomp: BS.bn_mod_inv_prime_ctx_st t_limbs n_limbs
let mod_inv_prime_vartime_precomp k a res = | false | null | false | BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp)
k
a
res | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.SafeAPI.mk_bn_mod_inv_prime_ctx",
"FStar.Ghost.hide",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.ModInv.mk_bn_mod_inv_prime_precomp",
"Hacl.Bignum256_32.exp_vartime_precomp",
"Prims.unit"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_inv_prime_vartime_precomp: BS.bn_mod_inv_prime_ctx_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_inv_prime_vartime_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_inv_prime_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 72,
"end_line": 161,
"start_col": 2,
"start_line": 160
} |
Prims.Tot | val mod_exp_vartime: BS.bn_mod_exp_safe_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime | val mod_exp_vartime: BS.bn_mod_exp_safe_st t_limbs n_limbs
let mod_exp_vartime = | false | null | false | BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.SafeAPI.mk_bn_mod_exp_safe",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.exp_check",
"Hacl.Bignum256_32.exp_vartime"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_exp_vartime: BS.bn_mod_exp_safe_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_exp_vartime | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_exp_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 73,
"end_line": 138,
"start_col": 22,
"start_line": 138
} |
Prims.Tot | val add: BN.bn_add_eq_len_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs | val add: BN.bn_add_eq_len_st t_limbs n_limbs
let add:BN.bn_add_eq_len_st t_limbs n_limbs = | false | null | false | BN.bn_add_eq_len n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_add_eq_len",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_add_eq_len_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add: BN.bn_add_eq_len_st t_limbs n_limbs | [] | Hacl.Bignum256_32.add | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_add_eq_len_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 26,
"end_line": 15,
"start_col": 2,
"start_line": 15
} |
Prims.Tot | val mod_inv_prime_vartime: BS.bn_mod_inv_prime_safe_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime | val mod_inv_prime_vartime: BS.bn_mod_inv_prime_safe_st t_limbs n_limbs
let mod_inv_prime_vartime = | false | null | false | BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.SafeAPI.mk_bn_mod_inv_prime_safe",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.exp_vartime"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_inv_prime_vartime: BS.bn_mod_inv_prime_safe_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_inv_prime_vartime | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_inv_prime_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 75,
"end_line": 142,
"start_col": 28,
"start_line": 142
} |
Prims.Tot | val mod_exp_consttime: BS.bn_mod_exp_safe_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime | val mod_exp_consttime: BS.bn_mod_exp_safe_st t_limbs n_limbs
let mod_exp_consttime = | false | null | false | BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.SafeAPI.mk_bn_mod_exp_safe",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.exp_check",
"Hacl.Bignum256_32.exp_consttime"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_exp_consttime: BS.bn_mod_exp_safe_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_exp_consttime | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_exp_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 77,
"end_line": 140,
"start_col": 24,
"start_line": 140
} |
Prims.Tot | val new_bn_from_bytes_le: BS.new_bn_from_bytes_le_st t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let new_bn_from_bytes_le = BS.new_bn_from_bytes_le | val new_bn_from_bytes_le: BS.new_bn_from_bytes_le_st t_limbs
let new_bn_from_bytes_le = | false | null | false | BS.new_bn_from_bytes_le | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.SafeAPI.new_bn_from_bytes_le",
"Hacl.Bignum256_32.t_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val new_bn_from_bytes_le: BS.new_bn_from_bytes_le_st t_limbs | [] | Hacl.Bignum256_32.new_bn_from_bytes_le | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.new_bn_from_bytes_le_st Hacl.Bignum256_32.t_limbs | {
"end_col": 50,
"end_line": 165,
"start_col": 27,
"start_line": 165
} |
Prims.Tot | val exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp | val exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs
let exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs = | false | null | false | BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Exponentiation.mk_bn_mod_exp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.precompr2",
"Hacl.Bignum256_32.exp_vartime_precomp"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.exp_vartime | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Exponentiation.bn_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 56,
"end_line": 132,
"start_col": 2,
"start_line": 132
} |
Prims.Tot | val precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst | val precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs
let precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = | false | null | false | BM.bn_precomp_r2_mod_n bn_inst | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs | [] | Hacl.Bignum256_32.precompr2 | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 32,
"end_line": 50,
"start_col": 2,
"start_line": 50
} |
Prims.Tot | val exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp | val exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs
let exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs = | false | null | false | BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Exponentiation.mk_bn_mod_exp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum256_32.precompr2",
"Hacl.Bignum256_32.exp_consttime_precomp"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.exp_consttime | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Exponentiation.bn_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 58,
"end_line": 136,
"start_col": 2,
"start_line": 136
} |
Prims.Tot | val eq_mask: BN.bn_eq_mask_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eq_mask = BN.bn_eq_mask n_limbs | val eq_mask: BN.bn_eq_mask_st t_limbs n_limbs
let eq_mask = | false | null | false | BN.bn_eq_mask n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_eq_mask",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
let new_bn_from_bytes_le = BS.new_bn_from_bytes_le
let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes
let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes
let lt_mask = BN.bn_lt_mask n_limbs | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq_mask: BN.bn_eq_mask_st t_limbs n_limbs | [] | Hacl.Bignum256_32.eq_mask | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_eq_mask_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 35,
"end_line": 173,
"start_col": 14,
"start_line": 173
} |
Prims.Tot | val sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs | val sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs
let sub_mod:BN.bn_sub_mod_n_st t_limbs n_limbs = | false | null | false | BN.bn_sub_mod_n n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_sub_mod_n",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_sub_mod_n_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs | [] | Hacl.Bignum256_32.sub_mod | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_sub_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 25,
"end_line": 24,
"start_col": 2,
"start_line": 24
} |
Prims.Tot | val add_mod: BN.bn_add_mod_n_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs | val add_mod: BN.bn_add_mod_n_st t_limbs n_limbs
let add_mod:BN.bn_add_mod_n_st t_limbs n_limbs = | false | null | false | BN.bn_add_mod_n n_limbs | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.bn_add_mod_n",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_add_mod_n_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_mod: BN.bn_add_mod_n_st t_limbs n_limbs | [] | Hacl.Bignum256_32.add_mod | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.bn_add_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 25,
"end_line": 21,
"start_col": 2,
"start_line": 21
} |
Prims.Tot | val exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) | val exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
let exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs = | false | null | false | BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Exponentiation.bn_mod_exp_consttime_precomp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.Exponentiation.bn_mod_exp_amm_bm_consttime_precomp",
"Hacl.Bignum256_32.almost_mont_inst",
"Hacl.Bignum.Exponentiation.bn_mod_exp_amm_fw_consttime_precomp",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.exp_consttime_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Exponentiation.bn_mod_exp_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 65,
"end_line": 128,
"start_col": 2,
"start_line": 126
} |
Prims.Tot | val mod_exp_vartime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res | val mod_exp_vartime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
let mod_exp_vartime_precomp k a bBits b res = | false | null | false | BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum256_32.n_limbs",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.blocks0",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Bignum.SafeAPI.mk_bn_mod_exp_ctx",
"FStar.Ghost.hide",
"Hacl.Bignum.meta_len",
"Hacl.Bignum256_32.exp_vartime_precomp",
"Prims.unit"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_exp_vartime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_exp_vartime_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_exp_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 66,
"end_line": 154,
"start_col": 2,
"start_line": 154
} |
Prims.Tot | val mod: BS.bn_mod_slow_safe_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res | val mod: BS.bn_mod_slow_safe_st t_limbs n_limbs
let mod n a res = | false | null | false | BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.SafeAPI.mk_bn_mod_slow_safe",
"Hacl.Bignum.ModReduction.mk_bn_mod_slow",
"Hacl.Bignum256_32.precompr2",
"Hacl.Bignum256_32.bn_slow_precomp",
"Prims.bool"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod: BS.bn_mod_slow_safe_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_slow_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 94,
"end_line": 113,
"start_col": 2,
"start_line": 113
} |
Prims.Tot | val mod_precomp: BS.bn_mod_slow_ctx_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res | val mod_precomp: BS.bn_mod_slow_ctx_st t_limbs n_limbs
let mod_precomp k a res = | false | null | false | BS.bn_mod_ctx n_limbs bn_slow_precomp k a res | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.SafeAPI.bn_mod_ctx",
"FStar.Ghost.hide",
"Hacl.Bignum.meta_len",
"Hacl.Bignum256_32.bn_slow_precomp",
"Prims.unit"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_precomp: BS.bn_mod_slow_ctx_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_slow_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 47,
"end_line": 151,
"start_col": 2,
"start_line": 151
} |
Prims.Tot | val exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) | val exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
let exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs = | false | null | false | BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Exponentiation.bn_mod_exp_vartime_precomp",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.Exponentiation.bn_mod_exp_amm_bm_vartime_precomp",
"Hacl.Bignum256_32.almost_mont_inst",
"Hacl.Bignum.Exponentiation.bn_mod_exp_amm_fw_vartime_precomp",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs | [] | Hacl.Bignum256_32.exp_vartime_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Exponentiation.bn_mod_exp_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 63,
"end_line": 122,
"start_col": 2,
"start_line": 120
} |
Prims.Tot | val mod_exp_consttime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res | val mod_exp_consttime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
let mod_exp_consttime_precomp k a bBits b res = | false | null | false | BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum256_32.n_limbs",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.blocks0",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Bignum.SafeAPI.mk_bn_mod_exp_ctx",
"FStar.Ghost.hide",
"Hacl.Bignum.meta_len",
"Hacl.Bignum256_32.exp_consttime_precomp",
"Prims.unit"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_exp_consttime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs | [] | Hacl.Bignum256_32.mod_exp_consttime_precomp | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.SafeAPI.bn_mod_exp_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 68,
"end_line": 157,
"start_col": 2,
"start_line": 157
} |
Prims.Tot | val reduction:BM.bn_mont_reduction_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst | val reduction:BM.bn_mont_reduction_st t_limbs n_limbs
let reduction:BM.bn_mont_reduction_st t_limbs n_limbs = | false | null | false | BM.bn_mont_reduction bn_inst | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Montgomery.bn_mont_reduction",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reduction:BM.bn_mont_reduction_st t_limbs n_limbs | [] | Hacl.Bignum256_32.reduction | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Montgomery.bn_mont_reduction_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs | {
"end_col": 30,
"end_line": 54,
"start_col": 2,
"start_line": 54
} |
Prims.Tot | val sqr: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_sqr_st t_limbs n_limbs a | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a | val sqr: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_sqr_st t_limbs n_limbs a
let sqr (a: lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = | false | null | false | BN.bn_sqr n_limbs a | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum256_32.lbignum",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_sqr",
"Hacl.Bignum.bn_karatsuba_sqr_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a | false | false | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sqr: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_sqr_st t_limbs n_limbs a | [] | Hacl.Bignum256_32.sqr | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Bignum256_32.lbignum Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
-> Hacl.Bignum.bn_karatsuba_sqr_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs a | {
"end_col": 21,
"end_line": 30,
"start_col": 2,
"start_line": 30
} |
Prims.Tot | val mul: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_mul_st t_limbs n_limbs a | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a | val mul: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_mul_st t_limbs n_limbs a
let mul (a: lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = | false | null | false | BN.bn_mul n_limbs n_limbs a | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum256_32.lbignum",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_limbs",
"Hacl.Bignum.bn_mul",
"Hacl.Bignum.bn_karatsuba_mul_st"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs | false | false | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_mul_st t_limbs n_limbs a | [] | Hacl.Bignum256_32.mul | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Bignum256_32.lbignum Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
-> Hacl.Bignum.bn_karatsuba_mul_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs a | {
"end_col": 29,
"end_line": 27,
"start_col": 2,
"start_line": 27
} |
Prims.Tot | val areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst | val areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs
let areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs = | false | null | false | AM.bn_almost_mont_reduction bn_inst | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.AlmostMontgomery.bn_almost_mont_reduction",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.bn_inst"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline] | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs | [] | Hacl.Bignum256_32.areduction | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.AlmostMontgomery.bn_almost_mont_reduction_st Hacl.Bignum256_32.t_limbs
Hacl.Bignum256_32.n_limbs | {
"end_col": 37,
"end_line": 86,
"start_col": 2,
"start_line": 86
} |
Prims.Tot | val bn_to_bytes_le: Hacl.Bignum.Convert.bn_to_bytes_le_st t_limbs n_bytes | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes | val bn_to_bytes_le: Hacl.Bignum.Convert.bn_to_bytes_le_st t_limbs n_bytes
let bn_to_bytes_le = | false | null | false | Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Convert.mk_bn_to_bytes_le",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_bytes"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
let new_bn_from_bytes_le = BS.new_bn_from_bytes_le
let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_le: Hacl.Bignum.Convert.bn_to_bytes_le_st t_limbs n_bytes | [] | Hacl.Bignum256_32.bn_to_bytes_le | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Convert.bn_to_bytes_le_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_bytes | {
"end_col": 71,
"end_line": 169,
"start_col": 21,
"start_line": 169
} |
Prims.Tot | val bn_to_bytes_be: Hacl.Bignum.Convert.bn_to_bytes_be_st t_limbs n_bytes | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModInv",
"short_module": "BI"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.ModReduction",
"short_module": "BR"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.SafeAPI",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes | val bn_to_bytes_be: Hacl.Bignum.Convert.bn_to_bytes_be_st t_limbs n_bytes
let bn_to_bytes_be = | false | null | false | Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes | {
"checked_file": "Hacl.Bignum256_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.ModReduction.fst.checked",
"Hacl.Bignum.ModInv.fst.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum256_32.fst"
} | [
"total"
] | [
"Hacl.Bignum.Convert.mk_bn_to_bytes_be",
"Hacl.Bignum256_32.t_limbs",
"Hacl.Bignum256_32.n_bytes"
] | [] | module Hacl.Bignum256_32
open FStar.Mul
module BN = Hacl.Bignum
module BM = Hacl.Bignum.Montgomery
module AM = Hacl.Bignum.AlmostMontgomery
module BE = Hacl.Bignum.Exponentiation
module BR = Hacl.Bignum.ModReduction
module BI = Hacl.Bignum.ModInv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let add: BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
//BN.bn_mul n_limbs n_limbs a a
inline_for_extraction noextract
instance bn_inst: BN.bn t_limbs = {
BN.len = n_limbs;
BN.add;
BN.sub;
BN.add_mod_n = add_mod;
BN.sub_mod_n = sub_mod;
BN.mul;
BN.sqr
}
[@CInline]
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
[@CInline]
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
[@CInline]
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
[@CInline]
let to: BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
[@CInline]
let from: BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
// [@CInline]
// let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs =
// BM.bn_mont_mul bn_inst reduction
// [@CInline]
// let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs =
// BM.bn_mont_sqr bn_inst reduction
// inline_for_extraction noextract
// instance mont_inst: BM.mont t_limbs = {
// BM.bn = bn_inst;
// BM.mont_check;
// BM.precomp = precompr2;
// BM.reduction;
// BM.to;
// BM.from;
// BM.mul = mont_mul;
// BM.sqr = mont_sqr;
// }
[@CInline]
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
[@CInline]
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
[@CInline]
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
inline_for_extraction noextract
instance almost_mont_inst: AM.almost_mont t_limbs = {
AM.bn = bn_inst;
AM.mont_check;
AM.precomp = precompr2;
AM.reduction = areduction;
AM.to;
AM.from;
AM.mul = amont_mul;
AM.sqr = amont_sqr;
}
[@CInline]
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
[@CInline]
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs
(BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst)
(BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
[@CInline]
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
[@CInline]
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
let mont_ctx_free k =
MA.bn_field_free k
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs
(BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
let new_bn_from_bytes_le = BS.new_bn_from_bytes_le | false | true | Hacl.Bignum256_32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be: Hacl.Bignum.Convert.bn_to_bytes_be_st t_limbs n_bytes | [] | Hacl.Bignum256_32.bn_to_bytes_be | {
"file_name": "code/bignum/Hacl.Bignum256_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Convert.bn_to_bytes_be_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_bytes | {
"end_col": 71,
"end_line": 167,
"start_col": 21,
"start_line": 167
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL | let is_felem_zero_vartime5 (f0, f1, f2, f3, f4: felem5) : bool = | false | null | false | let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_felem_zero_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | [] | Hacl.Spec.K256.Field52.is_felem_zero_vartime5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | {
"end_col": 25,
"end_line": 58,
"start_col": 2,
"start_line": 53
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL | let is_felem_ge_prime_vartime5 (f0, f1, f2, f3, f4: felem5) : bool = | false | null | false | let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Greater_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Lib.IntTypes.op_Equals_Dot",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_felem_ge_prime_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | [] | Hacl.Spec.K256.Field52.is_felem_ge_prime_vartime5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | {
"end_col": 38,
"end_line": 68,
"start_col": 2,
"start_line": 63
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4) | let add5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) : felem5 = | false | null | false | let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0, o1, o2, o3, o4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.add5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 38,
"start_col": 73,
"start_line": 32
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4 | let is_felem_eq_vartime5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) : bool = | false | null | false | let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4 | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_felem_eq_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Prims.bool | [] | Hacl.Spec.K256.Field52.is_felem_eq_vartime5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Prims.bool | {
"end_col": 38,
"end_line": 111,
"start_col": 2,
"start_line": 106
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end | let is_felem_lt_prime_minus_order_vartime5 (f0, f1, f2, f3, f4: felem5) : bool = | false | null | false | let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL
then false
else
if u64_to_UInt64 f3 >. 0uL
then false
else
if u64_to_UInt64 f2 <. 0x1455123uL
then true
else
if u64_to_UInt64 f2 >. 0x1455123uL
then false
else
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL
then true
else
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL
then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Greater_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool",
"Lib.IntTypes.op_Less_Dot"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_felem_lt_prime_minus_order_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | [] | Hacl.Spec.K256.Field52.is_felem_lt_prime_minus_order_vartime5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool | {
"end_col": 5,
"end_line": 101,
"start_col": 2,
"start_line": 84
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4) | let normalize_weak5 (t0, t1, t2, t3, t4: felem5) : felem5 = | false | null | false | let x, (t0, t1, t2, t3, t4) = minus_x_mul_pow2_256 (t0, t1, t2, t3, t4) in
plus_x_mul_pow2_256_minus_prime x (t0, t1, t2, t3, t4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize_weak5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.normalize_weak5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 52,
"end_line": 138,
"start_col": 56,
"start_line": 136
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsub5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) (x:uint64) : felem5 =
let (r0,r1,r2,r3,r4) = fnegate5 (b0,b1,b2,b3,b4) x in
add5 (a0,a1,a2,a3,a4) (r0,r1,r2,r3,r4) | let fsub5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) (x: uint64) : felem5 = | false | null | false | let r0, r1, r2, r3, r4 = fnegate5 (b0, b1, b2, b3, b4) x in
add5 (a0, a1, a2, a3, a4) (r0, r1, r2, r3, r4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Hacl.Spec.K256.Field52.add5",
"FStar.Pervasives.Native.Mktuple5",
"Hacl.Spec.K256.Field52.fnegate5"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
inline_for_extraction noextract
let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide a0 b3
+. mul64_wide a1 b2
+. mul64_wide a2 b1
+. mul64_wide a3 b0 in
let c0 = mul64_wide a4 b4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let d3 = d2
+. mul64_wide a0 b4
+. mul64_wide a1 b3
+. mul64_wide a2 b2
+. mul64_wide a3 b1
+. mul64_wide a4 b0 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 b0 in
let d6 = d5
+. mul64_wide a1 b4
+. mul64_wide a2 b3
+. mul64_wide a3 b2
+. mul64_wide a4 b1 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let c5 = c4
+. mul64_wide a0 b1
+. mul64_wide a1 b0 in
let d8 = d7
+. mul64_wide a2 b4
+. mul64_wide a3 b3
+. mul64_wide a4 b2 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7
+. mul64_wide a0 b2
+. mul64_wide a1 b1
+. mul64_wide a2 b0 in
let d10 = d9
+. mul64_wide a3 b4
+. mul64_wide a4 b3 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4)
inline_for_extraction noextract
let fsqr5 ((a0,a1,a2,a3,a4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in
let c0 = mul64_wide a4 a4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let a4 = a4 *. u64 2 in
let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 a0 in
let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let a0 = a0 *. u64 2 in
let c5 = c4 +. mul64_wide a0 a1 in
let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in
let d10 = d9 +. mul64_wide a3 a4 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4)
inline_for_extraction noextract
let fnegate5 ((a0,a1,a2,a3,a4):felem5) (m:uint64) : felem5 =
let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in
let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in
let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in
let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in
let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in
(r0,r1,r2,r3,r4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsub5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 ->
_: Hacl.Spec.K256.Field52.Definitions.felem5 ->
x: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.fsub5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
_: Hacl.Spec.K256.Field52.Definitions.felem5 ->
_: Hacl.Spec.K256.Field52.Definitions.felem5 ->
x: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 40,
"end_line": 266,
"start_col": 83,
"start_line": 264
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4) | let mul15 (f0, f1, f2, f3, f4: felem5) (c: uint64) : felem5 = | false | null | false | let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0, o1, o2, o3, o4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Dot"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul15 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> c: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.mul15 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> c: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 48,
"start_col": 58,
"start_line": 42
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4) | let minus_x_mul_pow2_256 (t0, t1, t2, t3, t4: felem5) : uint64 & felem5 = | false | null | false | let x = t4 >>. 48ul in
let t4 = t4 &. mask48 in
x, (t0, t1, t2, t3, t4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask48",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4 | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val minus_x_mul_pow2_256 : _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Lib.IntTypes.uint64 * Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.minus_x_mul_pow2_256 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Lib.IntTypes.uint64 * Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 21,
"end_line": 117,
"start_col": 70,
"start_line": 115
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4) | let plus_x_mul_pow2_256_minus_prime (x: uint64) (t0, t1, t2, t3, t4: felem5) : felem5 = | false | null | false | let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0, t1, t2, t3, t4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64",
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Hacl.Spec.K256.Field52.carry_round5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val plus_x_mul_pow2_256_minus_prime : x: Lib.IntTypes.uint64 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Lib.IntTypes.uint64 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 31,
"end_line": 132,
"start_col": 83,
"start_line": 130
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3) | let store_felem5 (f0, f1, f2, f3, f4: felem5) : felem4 = | false | null | false | let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0, o1, o2, o3) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Less_Less_Dot",
"Hacl.Spec.K256.Field52.Definitions.felem4"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_felem5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem4 | [] | Hacl.Spec.K256.Field52.store_felem5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem4 | {
"end_col": 15,
"end_line": 28,
"start_col": 54,
"start_line": 23
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4) | let load_felem5 (s0, s1, s2, s3: felem4) : felem5 = | false | null | false | let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0, f1, f2, f3, f4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem4",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Hacl.Spec.K256.Field52.Definitions.felem5"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_felem5 : _: Hacl.Spec.K256.Field52.Definitions.felem4 -> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.load_felem5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem4 -> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 19,
"start_col": 50,
"start_line": 13
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m | let is_felem_ge_prime5 (t0, t1, t2, t3, t4: felem5) : uint64 = | false | null | false | let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.gte_mask",
"Lib.IntTypes.u64",
"Lib.IntTypes.eq_mask",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Hacl.Spec.K256.Field52.Definitions.mask48"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_felem_ge_prime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64 | [] | Hacl.Spec.K256.Field52.is_felem_ge_prime5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64 | {
"end_col": 3,
"end_line": 79,
"start_col": 60,
"start_line": 72
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4) | let carry_round5 (t0, t1, t2, t3, t4: felem5) : felem5 = | false | null | false | let t1 = t1 +. (t0 >>. 52ul) in
let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in
let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in
let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in
let t3 = t3 &. mask52 in
(t0, t1, t2, t3, t4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val carry_round5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.carry_round5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 126,
"start_col": 53,
"start_line": 121
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4) | let normalize5 (f0, f1, f2, f3, f4: felem5) : felem5 = | false | null | false | let t0, t1, t2, t3, t4 = normalize_weak5 (f0, f1, f2, f3, f4) in
let x, (r0, r1, r2, r3, r4) = minus_x_mul_pow2_256 (t0, t1, t2, t3, t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0, r1, r2, r3, r4) in
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let s0, s1, s2, s3, s4 = plus_x_mul_pow2_256_minus_prime x1 (r0, r1, r2, r3, r4) in
let x2, (k0, k1, k2, k3, k4) = minus_x_mul_pow2_256 (s0, s1, s2, s3, s4) in
(k0, k1, k2, k3, k4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Field52.minus_x_mul_pow2_256",
"Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Field52.is_felem_ge_prime5",
"Hacl.Spec.K256.Field52.normalize_weak5"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normalize5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.normalize5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 150,
"start_col": 51,
"start_line": 142
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fnegate5 ((a0,a1,a2,a3,a4):felem5) (m:uint64) : felem5 =
let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in
let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in
let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in
let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in
let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in
(r0,r1,r2,r3,r4) | let fnegate5 (a0, a1, a2, a3, a4: felem5) (m: uint64) : felem5 = | false | null | false | let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in
let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in
let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in
let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in
let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in
(r0, r1, r2, r3, r4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
inline_for_extraction noextract
let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide a0 b3
+. mul64_wide a1 b2
+. mul64_wide a2 b1
+. mul64_wide a3 b0 in
let c0 = mul64_wide a4 b4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let d3 = d2
+. mul64_wide a0 b4
+. mul64_wide a1 b3
+. mul64_wide a2 b2
+. mul64_wide a3 b1
+. mul64_wide a4 b0 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 b0 in
let d6 = d5
+. mul64_wide a1 b4
+. mul64_wide a2 b3
+. mul64_wide a3 b2
+. mul64_wide a4 b1 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let c5 = c4
+. mul64_wide a0 b1
+. mul64_wide a1 b0 in
let d8 = d7
+. mul64_wide a2 b4
+. mul64_wide a3 b3
+. mul64_wide a4 b2 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7
+. mul64_wide a0 b2
+. mul64_wide a1 b1
+. mul64_wide a2 b0 in
let d10 = d9
+. mul64_wide a3 b4
+. mul64_wide a4 b3 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4)
inline_for_extraction noextract
let fsqr5 ((a0,a1,a2,a3,a4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in
let c0 = mul64_wide a4 a4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let a4 = a4 *. u64 2 in
let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 a0 in
let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let a0 = a0 *. u64 2 in
let c5 = c4 +. mul64_wide a0 a1 in
let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in
let d10 = d9 +. mul64_wide a3 a4 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fnegate5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> m: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.fnegate5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> m: Lib.IntTypes.uint64
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 260,
"start_col": 60,
"start_line": 254
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide a0 b3
+. mul64_wide a1 b2
+. mul64_wide a2 b1
+. mul64_wide a3 b0 in
let c0 = mul64_wide a4 b4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let d3 = d2
+. mul64_wide a0 b4
+. mul64_wide a1 b3
+. mul64_wide a2 b2
+. mul64_wide a3 b1
+. mul64_wide a4 b0 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 b0 in
let d6 = d5
+. mul64_wide a1 b4
+. mul64_wide a2 b3
+. mul64_wide a3 b2
+. mul64_wide a4 b1 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let c5 = c4
+. mul64_wide a0 b1
+. mul64_wide a1 b0 in
let d8 = d7
+. mul64_wide a2 b4
+. mul64_wide a3 b3
+. mul64_wide a4 b2 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7
+. mul64_wide a0 b2
+. mul64_wide a1 b1
+. mul64_wide a2 b0 in
let d10 = d9
+. mul64_wide a3 b4
+. mul64_wide a4 b3 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4) | let fmul5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) : felem5 = | false | null | false | let r = u64 0x1000003D10 in
let d0 = mul64_wide a0 b3 +. mul64_wide a1 b2 +. mul64_wide a2 b1 +. mul64_wide a3 b0 in
let c0 = mul64_wide a4 b4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in
let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in
let d2 = d1 >>. 52ul in
let d3 =
d2 +. mul64_wide a0 b4 +. mul64_wide a1 b3 +. mul64_wide a2 b2 +. mul64_wide a3 b1 +.
mul64_wide a4 b0
in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in
let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in
let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 b0 in
let d6 = d5 +. mul64_wide a1 b4 +. mul64_wide a2 b3 +. mul64_wide a3 b2 +. mul64_wide a4 b1 in
let u0 = to_u64 d6 &. mask52 in
let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in
let c4 = c3 >>. 52ul in
let c5 = c4 +. mul64_wide a0 b1 +. mul64_wide a1 b0 in
let d8 = d7 +. mul64_wide a2 b4 +. mul64_wide a3 b3 +. mul64_wide a4 b2 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in
let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in
let c7 = c6 >>. 52ul in
let c8 = c7 +. mul64_wide a0 b2 +. mul64_wide a1 b1 +. mul64_wide a2 b0 in
let d10 = d9 +. mul64_wide a3 b4 +. mul64_wide a4 b3 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in
let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in
let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in
let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0, r1, r2, r3, r4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U128",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Lib.IntTypes.mul64_wide",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.to_u128",
"Lib.IntTypes.op_Bar_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask48",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Lib.IntTypes.u64"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.fmul5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5
-> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 216,
"start_col": 72,
"start_line": 154
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqr5 ((a0,a1,a2,a3,a4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in
let c0 = mul64_wide a4 a4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let a4 = a4 *. u64 2 in
let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 a0 in
let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let a0 = a0 *. u64 2 in
let c5 = c4 +. mul64_wide a0 a1 in
let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in
let d10 = d9 +. mul64_wide a3 a4 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4) | let fsqr5 (a0, a1, a2, a3, a4: felem5) : felem5 = | false | null | false | let r = u64 0x1000003D10 in
let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in
let c0 = mul64_wide a4 a4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in
let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in
let d2 = d1 >>. 52ul in
let a4 = a4 *. u64 2 in
let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in
let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in
let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 a0 in
let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in
let u0 = to_u64 d6 &. mask52 in
let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in
let c4 = c3 >>. 52ul in
let a0 = a0 *. u64 2 in
let c5 = c4 +. mul64_wide a0 a1 in
let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in
let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in
let c7 = c6 >>. 52ul in
let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in
let d10 = d9 +. mul64_wide a3 a4 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in
let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in
let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in
let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0, r1, r2, r3, r4) | {
"checked_file": "Hacl.Spec.K256.Field52.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U128",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask52",
"Lib.IntTypes.mul64_wide",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.to_u128",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Bar_Dot",
"Hacl.Spec.K256.Field52.Definitions.mask48",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v"
] | [] | module Hacl.Spec.K256.Field52
open FStar.Mul
open Lib.IntTypes
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 =
let f0 = s0 &. mask52 in
let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in
let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in
let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in
let f4 = s3 >>. 16ul in
(f0,f1,f2,f3,f4)
inline_for_extraction noextract
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in
let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in
let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in
let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in
(o0,o1,o2,o3)
inline_for_extraction noextract
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 =
let o0 = a0 +. b0 in
let o1 = a1 +. b1 in
let o2 = a2 +. b2 in
let o3 = a3 +. b3 in
let o4 = a4 +. b4 in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 =
let o0 = f0 *. c in
let o1 = f1 *. c in
let o2 = f2 *. c in
let o3 = f3 *. c in
let o4 = f4 *. c in
(o0,o1,o2,o3,o4)
inline_for_extraction noextract
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL &&
u64_to_UInt64 f4 =. 0uL
inline_for_extraction noextract
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 >=. 0xffffefffffc2fuL &&
u64_to_UInt64 f1 =. 0xfffffffffffffuL &&
u64_to_UInt64 f2 =. 0xfffffffffffffuL &&
u64_to_UInt64 f3 =. 0xfffffffffffffuL &&
u64_to_UInt64 f4 =. 0xffffffffffffuL
inline_for_extraction noextract
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 =
let m4 = eq_mask t4 mask48 in
let m3 = eq_mask t3 mask52 in
let m2 = eq_mask t2 mask52 in
let m1 = eq_mask t1 mask52 in
let m0 = gte_mask t0 (u64 0xffffefffffc2f) in
let m = m0 &. m1 &. m2 &. m3 &. m4 in
m
inline_for_extraction noextract
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 f4 >. 0uL then false
else begin
if u64_to_UInt64 f3 >. 0uL then false
else begin
if u64_to_UInt64 f2 <. 0x1455123uL then true
else begin
if u64_to_UInt64 f2 >. 0x1455123uL then false
else begin
if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true
else begin
if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false
else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
end
end
end
end
end
inline_for_extraction noextract
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 &&
u64_to_UInt64 a4 =. u64_to_UInt64 b4
inline_for_extraction noextract
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in
x, (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in
let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in
let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in
let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in
(t0,t1,t2,t3,t4)
inline_for_extraction noextract
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in
carry_round5 (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 =
let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
inline_for_extraction noextract
let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 =
let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in
let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in
let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime
let m_to_one = is_ge_p_m &. u64 1 in
let x1 = m_to_one |. x in
let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in
let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in
(k0,k1,k2,k3,k4)
inline_for_extraction noextract
let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 =
let r = u64 0x1000003D10 in
let d0 = mul64_wide a0 b3
+. mul64_wide a1 b2
+. mul64_wide a2 b1
+. mul64_wide a3 b0 in
let c0 = mul64_wide a4 b4 in
let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in
let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in
let d3 = d2
+. mul64_wide a0 b4
+. mul64_wide a1 b3
+. mul64_wide a2 b2
+. mul64_wide a3 b1
+. mul64_wide a4 b0 in
let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in
let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in
let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in
let c2 = mul64_wide a0 b0 in
let d6 = d5
+. mul64_wide a1 b4
+. mul64_wide a2 b3
+. mul64_wide a3 b2
+. mul64_wide a4 b1 in
let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in
let u0' = tx |. (u0 <<. 4ul) in
let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in
let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in
let c5 = c4
+. mul64_wide a0 b1
+. mul64_wide a1 b0 in
let d8 = d7
+. mul64_wide a2 b4
+. mul64_wide a3 b3
+. mul64_wide a4 b2 in
let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in
let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in
let c8 = c7
+. mul64_wide a0 b2
+. mul64_wide a1 b1
+. mul64_wide a2 b0 in
let d10 = d9
+. mul64_wide a3 b4
+. mul64_wide a4 b3 in
let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in
let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in
let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in
let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in
let r4 = c12 +. t4' in
(r0,r1,r2,r3,r4) | false | true | Hacl.Spec.K256.Field52.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsqr5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | [] | Hacl.Spec.K256.Field52.fsqr5 | {
"file_name": "code/k256/Hacl.Spec.K256.Field52.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 18,
"end_line": 250,
"start_col": 46,
"start_line": 220
} |
|
Prims.Tot | val tip_top_predicate (tip: rid) (h: hmap) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip | val tip_top_predicate (tip: rid) (h: hmap) : Type0
let tip_top_predicate (tip: rid) (h: hmap) : Type0 = | false | null | false | forall (r: sid). r `is_in` h <==> r `is_above` tip | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperHeap.hmap",
"Prims.l_Forall",
"FStar.Monotonic.HyperStack.sid",
"Prims.l_iff",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_in",
"FStar.Monotonic.HyperStack.is_above"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"] | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tip_top_predicate (tip: rid) (h: hmap) : Type0 | [] | FStar.Monotonic.HyperStack.tip_top_predicate | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | tip: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperHeap.hmap -> Type0 | {
"end_col": 51,
"end_line": 64,
"start_col": 2,
"start_line": 64
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_in (r:rid) (h:hmap) = h `Map.contains` r | let is_in (r: rid) (h: hmap) = | false | null | false | h `Map.contains` r | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperHeap.hmap",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_in : r: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperHeap.hmap -> Prims.bool | [] | FStar.Monotonic.HyperStack.is_in | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperHeap.hmap -> Prims.bool | {
"end_col": 54,
"end_line": 26,
"start_col": 36,
"start_line": 26
} |
|
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r) | let is_eternal_region_hs r = | false | null | false | is_heap_color (color r) && not (rid_freeable r) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Monotonic.HyperHeap.color",
"Prims.op_Negation",
"FStar.Monotonic.HyperHeap.rid_freeable",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_eternal_region_hs : r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_eternal_region_hs | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 83,
"end_line": 34,
"start_col": 36,
"start_line": 34
} |
|
Prims.Tot | val map_invariant_predicate (m: hmap) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s) | val map_invariant_predicate (m: hmap) : Type0
let map_invariant_predicate (m: hmap) : Type0 = | false | null | false | forall r. Map.contains m r ==> (forall s. includes s r ==> Map.contains m s) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.hmap",
"Prims.l_Forall",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_imp",
"Prims.b2t",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperHeap.includes"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"] | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_invariant_predicate (m: hmap) : Type0 | [] | FStar.Monotonic.HyperStack.map_invariant_predicate | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperHeap.hmap -> Type0 | {
"end_col": 51,
"end_line": 51,
"start_col": 2,
"start_line": 50
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2 | let is_strictly_above r1 r2 = | false | null | false | r1 `is_above` r2 && r1 <> r2 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_above",
"Prims.op_disEquality",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1 | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_strictly_above : r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_strictly_above | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 58,
"end_line": 45,
"start_col": 30,
"start_line": 45
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h | let is_tip (tip: rid) (h: hmap) = | false | null | false | (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\ tip_top tip h | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperHeap.hmap",
"Prims.l_and",
"Prims.l_or",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_stack_region",
"Prims.op_Equality",
"FStar.Monotonic.HyperHeap.root",
"FStar.Monotonic.HyperStack.is_in",
"FStar.Monotonic.HyperStack.tip_top",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_tip : tip: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperHeap.hmap -> Prims.logical | [] | FStar.Monotonic.HyperStack.is_tip | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | tip: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperHeap.hmap -> Prims.logical | {
"end_col": 15,
"end_line": 85,
"start_col": 2,
"start_line": 83
} |
|
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_below r1 r2 = r2 `is_above` r1 | let is_below r1 r2 = | false | null | false | r2 `is_above` r1 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.is_above",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2 | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_below : r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_below | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 53,
"end_line": 43,
"start_col": 37,
"start_line": 43
} |
|
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2 | let is_strictly_below r1 r2 = | false | null | false | r1 `is_below` r2 && r1 <> r2 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_below",
"Prims.op_disEquality",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2 | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_strictly_below : r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_strictly_below | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 58,
"end_line": 44,
"start_col": 30,
"start_line": 44
} |
|
Prims.Tot | val fresh_ref (#a: Type) (#rel: preorder a) (r: mreference a rel) (m0 m1: mem) : Type0 | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i) | val fresh_ref (#a: Type) (#rel: preorder a) (r: mreference a rel) (m0 m1: mem) : Type0
let fresh_ref (#a: Type) (#rel: preorder a) (r: mreference a rel) (m0 m1: mem) : Type0 = | false | null | false | let i = frameOf r in
Heap.fresh (as_ref r) ((get_hmap m0) `Map.sel` i) ((get_hmap m1) `Map.sel` i) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.Heap.fresh",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.frameOf"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_ref (#a: Type) (#rel: preorder a) (r: mreference a rel) (m0 m1: mem) : Type0 | [] | FStar.Monotonic.HyperStack.fresh_ref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
r: FStar.Monotonic.HyperStack.mreference a rel ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 75,
"end_line": 288,
"start_col": 89,
"start_line": 286
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_above r1 r2 = r1 `includes` r2 | let is_above r1 r2 = | false | null | false | r1 `includes` r2 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperHeap.includes",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_above : r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_above | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 53,
"end_line": 41,
"start_col": 37,
"start_line": 41
} |
|
Prims.Tot | val downward_closed_predicate (h: hmap) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) | val downward_closed_predicate (h: hmap) : Type0
let downward_closed_predicate (h: hmap) : Type0 = | false | null | false | forall (r: rid).
r `is_in` h ==>
(r = root \/
(forall (s: rid).
(r `is_above` s /\ s `is_in` h) ==>
((is_stack_region r = is_stack_region s) /\
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.hmap",
"Prims.l_Forall",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_imp",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_in",
"Prims.l_or",
"Prims.op_Equality",
"FStar.Monotonic.HyperHeap.root",
"Prims.l_and",
"FStar.Monotonic.HyperStack.is_above",
"Prims.bool",
"FStar.Monotonic.HyperStack.is_stack_region",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Monotonic.HyperHeap.color",
"FStar.Monotonic.HyperHeap.rid_freeable",
"Prims.eq2"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"] | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val downward_closed_predicate (h: hmap) : Type0 | [] | FStar.Monotonic.HyperStack.downward_closed_predicate | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperHeap.hmap -> Type0 | {
"end_col": 85,
"end_line": 60,
"start_col": 2,
"start_line": 55
} |
Prims.Tot | val rid_ctr_pred_predicate (h: hmap) (n: int) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n | val rid_ctr_pred_predicate (h: hmap) (n: int) : Type0
let rid_ctr_pred_predicate (h: hmap) (n: int) : Type0 = | false | null | false | forall (r: rid). h `Map.contains` r ==> rid_last_component r < n | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.hmap",
"Prims.int",
"Prims.l_Forall",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_imp",
"Prims.b2t",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"Prims.op_LessThan",
"FStar.Monotonic.HyperHeap.rid_last_component"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"] | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rid_ctr_pred_predicate (h: hmap) (n: int) : Type0 | [] | FStar.Monotonic.HyperStack.rid_ctr_pred_predicate | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperHeap.hmap -> n: Prims.int -> Type0 | {
"end_col": 65,
"end_line": 68,
"start_col": 2,
"start_line": 68
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r) | let is_eternal_region r = | false | null | false | is_heap_color (color r) && not (rid_freeable r) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_heap_color",
"FStar.Monotonic.HyperHeap.color",
"Prims.op_Negation",
"FStar.Monotonic.HyperHeap.rid_freeable",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0 | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_eternal_region : r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_eternal_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 74,
"end_line": 32,
"start_col": 27,
"start_line": 32
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let poppable (m:mem) = get_tip m =!= root | let poppable (m: mem) = | false | null | false | get_tip m =!= root | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.l_not",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.get_tip",
"FStar.Monotonic.HyperHeap.root",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero() | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val poppable : m: FStar.Monotonic.HyperStack.mem -> Prims.logical | [] | FStar.Monotonic.HyperStack.poppable | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> Prims.logical | {
"end_col": 41,
"end_line": 189,
"start_col": 23,
"start_line": 189
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr | let is_wf_with_ctr_and_tip (h: hmap) (ctr: int) (tip: rid) = | false | null | false | (not (rid_freeable root)) /\ root `is_in` h /\ tip `is_tip` h /\ map_invariant h /\
downward_closed h /\ rid_ctr_pred h ctr | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.hmap",
"Prims.int",
"FStar.Monotonic.HyperHeap.rid",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Monotonic.HyperHeap.rid_freeable",
"FStar.Monotonic.HyperHeap.root",
"FStar.Monotonic.HyperStack.is_in",
"FStar.Monotonic.HyperStack.is_tip",
"FStar.Monotonic.HyperStack.map_invariant",
"FStar.Monotonic.HyperStack.downward_closed",
"FStar.Monotonic.HyperStack.rid_ctr_pred",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_wf_with_ctr_and_tip : h: FStar.Monotonic.HyperHeap.hmap -> ctr: Prims.int -> tip: FStar.Monotonic.HyperHeap.rid
-> Prims.logical | [] | FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperHeap.hmap -> ctr: Prims.int -> tip: FStar.Monotonic.HyperHeap.rid
-> Prims.logical | {
"end_col": 22,
"end_line": 93,
"start_col": 4,
"start_line": 88
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r)) | let unused_in (#a: Type) (#rel: preorder a) (r: mreference a rel) (m: mem) = | false | null | false | not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r)) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Map.contains",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.Heap.unused_in",
"FStar.Monotonic.HyperStack.as_ref",
"FStar.Map.sel",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unused_in : r: FStar.Monotonic.HyperStack.mreference a rel -> m: FStar.Monotonic.HyperStack.mem -> Prims.logical | [] | FStar.Monotonic.HyperStack.unused_in | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperStack.mreference a rel -> m: FStar.Monotonic.HyperStack.mem -> Prims.logical | {
"end_col": 64,
"end_line": 281,
"start_col": 2,
"start_line": 280
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mreference a rel = mreference' a rel | let mreference a rel = | false | null | false | mreference' a rel | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference'"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mreference : a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.mreference | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 40,
"end_line": 221,
"start_col": 23,
"start_line": 221
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s) | let contains (#a: Type) (#rel: preorder a) (m: mem) (s: mreference a rel) = | false | null | false | live_region m (frameOf s) /\ Heap.contains ((get_hmap m) `Map.sel` (frameOf s)) (as_ref s) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"Prims.l_and",
"Prims.b2t",
"FStar.Monotonic.HyperStack.live_region",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.Heap.contains",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.as_ref",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val contains : m: FStar.Monotonic.HyperStack.mem -> s: FStar.Monotonic.HyperStack.mreference a rel -> Prims.logical | [] | FStar.Monotonic.HyperStack.contains | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> s: FStar.Monotonic.HyperStack.mreference a rel -> Prims.logical | {
"end_col": 61,
"end_line": 277,
"start_col": 2,
"start_line": 276
} |
|
Prims.GTot | val as_addr (#a #rel: _) (x: mreference a rel) : GTot pos | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x) | val as_addr (#a #rel: _) (x: mreference a rel) : GTot pos
let as_addr #a #rel (x: mreference a rel) : GTot pos = | false | null | false | Heap.addr_of (as_ref x) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.Heap.addr_of",
"FStar.Monotonic.HyperStack.as_ref",
"Prims.pos"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_addr (#a #rel: _) (x: mreference a rel) : GTot pos | [] | FStar.Monotonic.HyperStack.as_addr | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Monotonic.HyperStack.mreference a rel -> Prims.GTot Prims.pos | {
"end_col": 27,
"end_line": 239,
"start_col": 4,
"start_line": 239
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) } | let mstackref (a: Type) (rel: preorder a) = | false | null | false | s: mreference a rel {is_stack_region (frameOf s) && not (is_mm s)} | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_stack_region",
"FStar.Monotonic.HyperStack.frameOf",
"Prims.op_Negation",
"FStar.Monotonic.HyperStack.is_mm"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mstackref : a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.mstackref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 69,
"end_line": 254,
"start_col": 2,
"start_line": 254
} |
|
Prims.Tot | val mk_mreference (#a: Type) (#rel: preorder a) (id: rid) (r: Heap.mref a rel) : mreference a rel | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r | val mk_mreference (#a: Type) (#rel: preorder a) (id: rid) (r: Heap.mref a rel) : mreference a rel
let mk_mreference (#a: Type) (#rel: preorder a) (id: rid) (r: Heap.mref a rel) : mreference a rel = | false | null | false | MkRef id r | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.mref",
"FStar.Monotonic.HyperStack.MkRef",
"FStar.Monotonic.HyperStack.mreference"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_mreference (#a: Type) (#rel: preorder a) (id: rid) (r: Heap.mref a rel) : mreference a rel | [] | FStar.Monotonic.HyperStack.mk_mreference | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | id: FStar.Monotonic.HyperHeap.rid -> r: FStar.Monotonic.Heap.mref a rel
-> FStar.Monotonic.HyperStack.mreference a rel | {
"end_col": 14,
"end_line": 230,
"start_col": 4,
"start_line": 230
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) } | let mref (a: Type) (rel: preorder a) = | false | null | false | s: mreference a rel {is_eternal_region_hs (frameOf s) && not (is_mm s)} | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_eternal_region_hs",
"FStar.Monotonic.HyperStack.frameOf",
"Prims.op_Negation",
"FStar.Monotonic.HyperStack.is_mm"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) } | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mref : a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.mref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 73,
"end_line": 257,
"start_col": 2,
"start_line": 257
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i | let fresh_region (i: rid) (m0 m1: mem) = | false | null | false | not ((get_hmap m0) `Map.contains` i) /\ (get_hmap m1) `Map.contains` i | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Negation",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_region : i: FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | [] | FStar.Monotonic.HyperStack.fresh_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
i: FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | {
"end_col": 68,
"end_line": 291,
"start_col": 2,
"start_line": 291
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1) | let modifies_transitively (s: Set.set rid) (m0 m1: mem) = | false | null | false | FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Set.set",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.modifies",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_transitively : s: FStar.Set.set FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | [] | FStar.Monotonic.HyperStack.modifies_transitively | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
s: FStar.Set.set FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | {
"end_col": 126,
"end_line": 420,
"start_col": 62,
"start_line": 420
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s } | let mmmstackref (a: Type) (rel: preorder a) = | false | null | false | s: mreference a rel {is_stack_region (frameOf s) && is_mm s} | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_stack_region",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.is_mm"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) } | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mmmstackref : a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.mmmstackref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 62,
"end_line": 260,
"start_col": 2,
"start_line": 260
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i} | let s_mref (i: rid) (a: Type) (rel: preorder a) = | false | null | false | s: mreference a rel {frameOf s = i} | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Monotonic.HyperStack.frameOf"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s } | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val s_mref : i: FStar.Monotonic.HyperHeap.rid -> a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.s_mref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | i: FStar.Monotonic.HyperHeap.rid -> a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 80,
"end_line": 266,
"start_col": 47,
"start_line": 266
} |
|
Prims.GTot | val sel (#a: Type) (#rel: preorder a) (m: mem) (s: mreference a rel) : GTot a | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s) | val sel (#a: Type) (#rel: preorder a) (m: mem) (s: mreference a rel) : GTot a
let sel (#a: Type) (#rel: preorder a) (m: mem) (s: mreference a rel) : GTot a = | false | null | false | Heap.sel ((get_hmap m) `Map.sel` (frameOf s)) (as_ref s) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.Heap.sel",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.as_ref"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sel (#a: Type) (#rel: preorder a) (m: mem) (s: mreference a rel) : GTot a | [] | FStar.Monotonic.HyperStack.sel | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> s: FStar.Monotonic.HyperStack.mreference a rel -> Prims.GTot a | {
"end_col": 58,
"end_line": 294,
"start_col": 4,
"start_line": 294
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1) | let modifies (s: Set.set rid) (m0 m1: mem) = | false | null | false | modifies_just s (get_hmap m0) (get_hmap m1) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Set.set",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.modifies_just",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies : s: FStar.Set.set FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | [] | FStar.Monotonic.HyperStack.modifies | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
s: FStar.Set.set FStar.Monotonic.HyperHeap.rid ->
m0: FStar.Monotonic.HyperStack.mem ->
m1: FStar.Monotonic.HyperStack.mem
-> Prims.logical | {
"end_col": 92,
"end_line": 418,
"start_col": 49,
"start_line": 418
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m | let top_frame (m: mem) = | false | null | false | (get_hmap m) `Map.sel` (get_tip m) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.get_tip"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val top_frame : m: FStar.Monotonic.HyperStack.mem -> FStar.Monotonic.Heap.heap | [] | FStar.Monotonic.HyperStack.top_frame | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> FStar.Monotonic.Heap.heap | {
"end_col": 54,
"end_line": 424,
"start_col": 24,
"start_line": 424
} |
|
Prims.Tot | val norm_steps:list norm_step | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let norm_steps :list norm_step =
//iota for reducing match
[iota; zeta; delta; delta_only ["FStar.Monotonic.HyperStack.regions_of_some_refs";
"FStar.Monotonic.HyperStack.refs_in_region";
"FStar.Monotonic.HyperStack.modifies_some_refs"];
primops] | val norm_steps:list norm_step
let norm_steps:list norm_step = | false | null | false | [
iota;
zeta;
delta;
delta_only [
"FStar.Monotonic.HyperStack.regions_of_some_refs";
"FStar.Monotonic.HyperStack.refs_in_region";
"FStar.Monotonic.HyperStack.modifies_some_refs"
];
primops
] | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.delta",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.primops"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref
let some_refs = list some_ref
[@@"opaque_to_smt"]
private let rec regions_of_some_refs (rs:some_refs) :Tot (Set.set rid) =
match rs with
| [] -> Set.empty
| (Ref r)::tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl)
[@@"opaque_to_smt"]
private let rec refs_in_region (r:rid) (rs:some_refs) :GTot (Set.set nat) =
match rs with
| [] -> Set.empty
| (Ref x)::tl ->
Set.union (if frameOf x = r then Set.singleton (as_addr x) else Set.empty)
(refs_in_region r tl)
[@@"opaque_to_smt"]
private let rec modifies_some_refs (i:some_refs) (rs:some_refs) (h0:mem) (h1:mem) :GTot Type0 =
match i with
| [] -> True
| (Ref x)::tl ->
(modifies_ref (frameOf x) (refs_in_region (frameOf x) rs) h0 h1) /\
(modifies_some_refs tl rs h0 h1)
[@@"opaque_to_smt"]
unfold private let norm_steps :list norm_step = | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val norm_steps:list norm_step | [] | FStar.Monotonic.HyperStack.norm_steps | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.list FStar.Pervasives.norm_step | {
"end_col": 11,
"end_line": 471,
"start_col": 2,
"start_line": 468
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let heap_only (m0:mem) = get_tip m0 == root | let heap_only (m0: mem) = | false | null | false | get_tip m0 == root | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.get_tip",
"FStar.Monotonic.HyperHeap.root",
"Prims.logical"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1) | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val heap_only : m0: FStar.Monotonic.HyperStack.mem -> Prims.logical | [] | FStar.Monotonic.HyperStack.heap_only | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m0: FStar.Monotonic.HyperStack.mem -> Prims.logical | {
"end_col": 43,
"end_line": 422,
"start_col": 25,
"start_line": 422
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let some_refs = list some_ref | let some_refs = | false | null | false | list some_ref | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Monotonic.HyperStack.some_ref"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val some_refs : Type | [] | FStar.Monotonic.HyperStack.some_refs | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type | {
"end_col": 29,
"end_line": 441,
"start_col": 16,
"start_line": 441
} |
|
Prims.GTot | val mods (rs: some_refs) (h0 h1: mem) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mods (rs:some_refs) (h0 h1:mem) :GTot Type0 =
(norm norm_steps (modifies (regions_of_some_refs rs) h0 h1)) /\
(norm norm_steps (modifies_some_refs rs rs h0 h1)) | val mods (rs: some_refs) (h0 h1: mem) : GTot Type0
let mods (rs: some_refs) (h0 h1: mem) : GTot Type0 = | false | null | false | (norm norm_steps (modifies (regions_of_some_refs rs) h0 h1)) /\
(norm norm_steps (modifies_some_refs rs rs h0 h1)) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.some_refs",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"FStar.Pervasives.norm",
"FStar.Monotonic.HyperStack.norm_steps",
"Prims.logical",
"FStar.Monotonic.HyperStack.modifies",
"FStar.Monotonic.HyperStack.regions_of_some_refs",
"FStar.Monotonic.HyperStack.modifies_some_refs"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r))
let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_ref (#a:Type) (#rel:preorder a) (r:mreference a rel) (m0:mem) (m1:mem) :Type0 =
let i = frameOf r in
Heap.fresh (as_ref r) (get_hmap m0 `Map.sel` i) (get_hmap m1 `Map.sel` i)
let fresh_region (i:rid) (m0 m1:mem) =
not (get_hmap m0 `Map.contains` i) /\ get_hmap m1 `Map.contains` i
let sel (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) :GTot a
= Heap.sel (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let upd (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel{live_region m (frameOf s)}) (v:a)
:GTot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf s in
let h = Map.upd h i (Heap.upd (Map.sel h i) (as_ref s) v) in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let alloc (#a:Type0) (rel:preorder a) (id:rid) (init:a) (mm:bool) (m:mem{get_hmap m `Map.contains` id})
:Tot (p:(mreference a rel * mem){let (r, h) = Heap.alloc rel (get_hmap m `Map.sel` id) init mm in
as_ref (fst p) == r /\
get_hmap (snd p) == Map.upd (get_hmap m) id h})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let r, id_h = Heap.alloc rel (Map.sel h id) init mm in
let h = Map.upd h id id_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
(mk_mreference id r), mk_mem rid_ctr h tip
let free (#a:Type0) (#rel:preorder a) (r:mreference a rel{is_mm r}) (m:mem{m `contains` r})
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.free_mm i_h (as_ref r) in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let upd_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r}) (v:a)
:Tot mem
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let i = frameOf r in
let i_h = h `Map.sel` i in
let i_h = Heap.upd_tot i_h (as_ref r) v in
let h = Map.upd h i i_h in
lemma_is_wf_ctr_and_tip_intro h rid_ctr tip;
mk_mem rid_ctr h tip
let sel_tot (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel{m `contains` r})
:Tot a
= Heap.sel_tot (get_hmap m `Map.sel` (frameOf r)) (as_ref r)
let fresh_frame (m0:mem) (m1:mem) =
not (get_hmap m0 `Map.contains` get_tip m1) /\
parent (get_tip m1) == get_tip m0 /\
get_hmap m1 == Map.upd (get_hmap m0) (get_tip m1) Heap.emp
let hs_push_frame (m:mem) :Tot (m':mem{fresh_frame m m'})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_tip_rid = extend tip rid_ctr 1 in
let h = Map.upd h new_tip_rid Heap.emp in
assert (forall (s:rid). (new_tip_rid `is_above` s /\ s `is_in` h) ==> s = new_tip_rid);
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) new_tip_rid;
mk_mem (rid_ctr + 1) h new_tip_rid
let new_eternal_region (m:mem) (parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
(c:option int{None? c \/ is_heap_color (Some?.v c)})
:Tot (t:(rid * mem){fresh_region (fst t) m (snd t)})
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid =
if None? c then extend_monochrome parent rid_ctr
else extend parent rid_ctr (Some?.v c)
in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let new_freeable_heap_region
(m:mem)
(parent:rid{is_eternal_region_hs parent /\ get_hmap m `Map.contains` parent})
: t:(rid * mem){fresh_region (fst t) m (snd t) /\ rid_freeable (fst t)}
= let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
lemma_is_wf_ctr_and_tip_elim m;
let new_rid = extend_monochrome_freeable parent rid_ctr true in
let h = Map.upd h new_rid Heap.emp in
lemma_is_wf_ctr_and_tip_intro h (rid_ctr + 1) tip;
new_rid, mk_mem (rid_ctr + 1) h tip
let free_heap_region
(m0:mem)
(r:rid{
is_heap_color (color r) /\
rid_freeable r /\
get_hmap m0 `Map.contains` r})
: mem
= let h0, rid_ctr0 = get_hmap m0, get_rid_ctr m0 in
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) r in
let h1 = Map.restrict dom h0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 (get_tip m0);
mk_mem (get_rid_ctr m0) h1 (get_tip m0)
(****** The following two lemmas are only used in FStar.Pointer.Base, and invoked explicitly ******)
val lemma_sel_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1:mreference a rel) (r2:mreference a rel)
:Lemma (requires (frameOf r1 == frameOf r2 /\ h `contains` r1 /\ as_addr r1 = as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r2 /\ sel h r1 == sel h r2))
val lemma_upd_same_addr (#a:Type0) (#rel:preorder a) (h:mem) (r1 r2:mreference a rel) (x: a)
:Lemma (requires (frameOf r1 == frameOf r2 /\ (h `contains` r1 \/ h `contains` r2) /\
as_addr r1 == as_addr r2 /\ is_mm r1 == is_mm r2))
(ensures (h `contains` r1 /\ h `contains` r2 /\ upd h r1 x == upd h r2 x))
(* Two references with different reads are disjoint. *)
val mreference_distinct_sel_disjoint
(#a:Type0) (#rel1: preorder a) (#rel2: preorder a) (h: mem) (r1: mreference a rel1) (r2:mreference a rel2)
: Lemma (requires (h `contains` r1 /\ h `contains` r2 /\ frameOf r1 == frameOf r2 /\ as_addr r1 == as_addr r2))
(ensures (sel h r1 == sel h r2))
(*
* AR: 12/26: modifies clauses
* NOTE: the modifies clauses used to have a m0.tip == m1.tip conjunct too
* which seemed a bit misplaced
* removing that conjunct required very few changes (one in HACL), since ST effect gives it already
*)
let modifies (s:Set.set rid) (m0:mem) (m1:mem) = modifies_just s (get_hmap m0) (get_hmap m1)
let modifies_transitively (s:Set.set rid) (m0:mem) (m1:mem) = FStar.Monotonic.HyperHeap.modifies s (get_hmap m0) (get_hmap m1)
let heap_only (m0:mem) = get_tip m0 == root
let top_frame (m:mem) = get_hmap m `Map.sel` get_tip m
val modifies_drop_tip (m0:mem) (m1:mem) (m2:mem) (s:Set.set rid)
: Lemma (fresh_frame m0 m1 /\ get_tip m1 == get_tip m2 /\
modifies_transitively (Set.union s (Set.singleton (get_tip m1))) m1 m2 ==>
modifies_transitively s m0 (pop m2))
let modifies_one id h0 h1 = modifies_one id (get_hmap h0) (get_hmap h1)
let modifies_ref (id:rid) (s:Set.set nat) (h0:mem) (h1:mem) =
Heap.modifies s (get_hmap h0 `Map.sel` id) (get_hmap h1 `Map.sel` id)
(****** API for generating modifies clauses in the old style, should use new modifies clauses now ******)
noeq type some_ref =
| Ref: #a:Type0 -> #rel:preorder a -> mreference a rel -> some_ref
let some_refs = list some_ref
[@@"opaque_to_smt"]
private let rec regions_of_some_refs (rs:some_refs) :Tot (Set.set rid) =
match rs with
| [] -> Set.empty
| (Ref r)::tl -> Set.union (Set.singleton (frameOf r)) (regions_of_some_refs tl)
[@@"opaque_to_smt"]
private let rec refs_in_region (r:rid) (rs:some_refs) :GTot (Set.set nat) =
match rs with
| [] -> Set.empty
| (Ref x)::tl ->
Set.union (if frameOf x = r then Set.singleton (as_addr x) else Set.empty)
(refs_in_region r tl)
[@@"opaque_to_smt"]
private let rec modifies_some_refs (i:some_refs) (rs:some_refs) (h0:mem) (h1:mem) :GTot Type0 =
match i with
| [] -> True
| (Ref x)::tl ->
(modifies_ref (frameOf x) (refs_in_region (frameOf x) rs) h0 h1) /\
(modifies_some_refs tl rs h0 h1)
[@@"opaque_to_smt"]
unfold private let norm_steps :list norm_step =
//iota for reducing match
[iota; zeta; delta; delta_only ["FStar.Monotonic.HyperStack.regions_of_some_refs";
"FStar.Monotonic.HyperStack.refs_in_region";
"FStar.Monotonic.HyperStack.modifies_some_refs"];
primops]
[@@"opaque_to_smt"] | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mods (rs: some_refs) (h0 h1: mem) : GTot Type0 | [] | FStar.Monotonic.HyperStack.mods | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
rs: FStar.Monotonic.HyperStack.some_refs ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> Prims.GTot Type0 | {
"end_col": 52,
"end_line": 476,
"start_col": 2,
"start_line": 475
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_stack_region r = color r > 0 | let is_stack_region r = | false | null | false | color r > 0 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"Prims.op_GreaterThan",
"FStar.Monotonic.HyperHeap.color",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_stack_region : r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_stack_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 35,
"end_line": 28,
"start_col": 24,
"start_line": 28
} |
|
Prims.GTot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_just_below r1 r2 = r1 `extends` r2 | let is_just_below r1 r2 = | false | null | false | r1 `extends` r2 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperHeap.extends",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_just_below : r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | [] | FStar.Monotonic.HyperStack.is_just_below | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r1: FStar.Monotonic.HyperHeap.rid -> r2: FStar.Monotonic.HyperHeap.rid -> Prims.GTot Prims.bool | {
"end_col": 53,
"end_line": 42,
"start_col": 37,
"start_line": 42
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_heap_color c = c <= 0 | let is_heap_color c = | false | null | false | c <= 0 | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_heap_color : c: Prims.int -> Prims.bool | [] | FStar.Monotonic.HyperStack.is_heap_color | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: Prims.int -> Prims.bool | {
"end_col": 28,
"end_line": 29,
"start_col": 22,
"start_line": 29
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x)) | let remove_elt (#a: eqtype) (s: Set.set a) (x: a) = | false | null | false | Set.intersect s (Set.complement (Set.singleton x)) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.Set.set",
"FStar.Set.intersect",
"FStar.Set.complement",
"FStar.Set.singleton"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val remove_elt : s: FStar.Set.set a -> x: a -> FStar.Set.set a | [] | FStar.Monotonic.HyperStack.remove_elt | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Set.set a -> x: a -> FStar.Set.set a | {
"end_col": 107,
"end_line": 191,
"start_col": 57,
"start_line": 191
} |
|
Prims.Tot | val frameOf (#a: Type) (#rel: preorder a) (r: mreference a rel) : rid | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame | val frameOf (#a: Type) (#rel: preorder a) (r: mreference a rel) : rid
let frameOf (#a: Type) (#rel: preorder a) (r: mreference a rel) : rid = | false | null | false | r.frame | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.HyperStack.__proj__MkRef__item__frame",
"FStar.Monotonic.HyperHeap.rid"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frameOf (#a: Type) (#rel: preorder a) (r: mreference a rel) : rid | [] | FStar.Monotonic.HyperStack.frameOf | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperStack.mreference a rel -> FStar.Monotonic.HyperHeap.rid | {
"end_col": 11,
"end_line": 225,
"start_col": 4,
"start_line": 225
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s } | let mmmref (a: Type) (rel: preorder a) = | false | null | false | s: mreference a rel {is_eternal_region_hs (frameOf s) && is_mm s} | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"Prims.b2t",
"Prims.op_AmpAmp",
"FStar.Monotonic.HyperStack.is_eternal_region_hs",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.is_mm"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s } | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mmmref : a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | [] | FStar.Monotonic.HyperStack.mmmref | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type0 -> rel: FStar.Preorder.preorder a -> Type0 | {
"end_col": 67,
"end_line": 263,
"start_col": 2,
"start_line": 263
} |
|
Prims.GTot | val is_mm (#a: Type) (#rel: preorder a) (r: mreference a rel) : GTot bool | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r) | val is_mm (#a: Type) (#rel: preorder a) (r: mreference a rel) : GTot bool
let is_mm (#a: Type) (#rel: preorder a) (r: mreference a rel) : GTot bool = | false | null | false | Heap.is_mm (as_ref r) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"sometrivial"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.Heap.is_mm",
"FStar.Monotonic.HyperStack.as_ref",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)] | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_mm (#a: Type) (#rel: preorder a) (r: mreference a rel) : GTot bool | [] | FStar.Monotonic.HyperStack.is_mm | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperStack.mreference a rel -> Prims.GTot Prims.bool | {
"end_col": 23,
"end_line": 246,
"start_col": 2,
"start_line": 246
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let contains_ref_in_its_region (#a:Type) (#rel:preorder a) (m:mem) (r:mreference a rel) =
Heap.contains (get_hmap m `Map.sel` (frameOf r)) (as_ref r) | let contains_ref_in_its_region (#a: Type) (#rel: preorder a) (m: mem) (r: mreference a rel) = | false | null | false | Heap.contains ((get_hmap m) `Map.sel` (frameOf r)) (as_ref r) | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperStack.mreference",
"FStar.Monotonic.Heap.contains",
"FStar.Map.sel",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Monotonic.HyperStack.as_ref"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface
*)
let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i
let contains (#a:Type) (#rel:preorder a) (m:mem) (s:mreference a rel) =
live_region m (frameOf s) /\
Heap.contains (get_hmap m `Map.sel` (frameOf s)) (as_ref s)
let unused_in (#a:Type) (#rel:preorder a) (r:mreference a rel) (m:mem) =
not ((get_hmap m) `Map.contains` (frameOf r)) \/
Heap.unused_in (as_ref r) ((get_hmap m) `Map.sel` (frameOf r)) | false | false | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val contains_ref_in_its_region : m: FStar.Monotonic.HyperStack.mem -> r: FStar.Monotonic.HyperStack.mreference a rel -> Type0 | [] | FStar.Monotonic.HyperStack.contains_ref_in_its_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> r: FStar.Monotonic.HyperStack.mreference a rel -> Type0 | {
"end_col": 61,
"end_line": 284,
"start_col": 2,
"start_line": 284
} |
|
Prims.Tot | val live_region (m: mem) (i: rid) : bool | [
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let live_region (m:mem) (i:rid) :bool = get_hmap m `Map.contains` i | val live_region (m: mem) (i: rid) : bool
let live_region (m: mem) (i: rid) : bool = | false | null | false | (get_hmap m) `Map.contains` i | {
"checked_file": "FStar.Monotonic.HyperStack.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Monotonic.Heap.fsti.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Monotonic.HyperStack.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Map.contains",
"FStar.Monotonic.Heap.heap",
"FStar.Monotonic.HyperStack.get_hmap",
"Prims.bool"
] | [] | (*
Copyright 2008-2014 Aseem Rastogi, 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 FStar.Monotonic.HyperStack
open FStar.Preorder
module Map = FStar.Map
include FStar.Monotonic.HyperHeap
(****** Some predicates ******)
unfold let is_in (r:rid) (h:hmap) = h `Map.contains` r
let is_stack_region r = color r > 0
let is_heap_color c = c <= 0
[@@(deprecated "FStar.HyperStack.ST.is_eternal_region")]
let is_eternal_region r = is_heap_color (color r) && not (rid_freeable r)
unfold let is_eternal_region_hs r = is_heap_color (color r) && not (rid_freeable r)
type sid = r:rid{is_stack_region r} //stack region ids
(*
* AR: marking these unfolds, else I think there are pattern firing issues depending on which one we use
*)
unfold let is_above r1 r2 = r1 `includes` r2
unfold let is_just_below r1 r2 = r1 `extends` r2
unfold let is_below r1 r2 = r2 `is_above` r1
let is_strictly_below r1 r2 = r1 `is_below` r2 && r1 <> r2
let is_strictly_above r1 r2 = r1 `is_above` r2 && r1 <> r2
[@@"opaque_to_smt"]
unfold private let map_invariant_predicate (m:hmap) :Type0 =
forall r. Map.contains m r ==>
(forall s. includes s r ==> Map.contains m s)
[@@"opaque_to_smt"]
unfold private let downward_closed_predicate (h:hmap) :Type0 =
forall (r:rid). r `is_in` h //for any region in the memory
==> (r=root //either is the root
\/ (forall (s:rid). (r `is_above` s //or, any region beneath it
/\ s `is_in` h) //that is also in the memory
==> ((is_stack_region r = is_stack_region s) /\ //must be of the same flavor as itself
((is_heap_color (color r) /\ rid_freeable r) ==> s == r)))) //and if r is a freeable heap region, s can only be r (no regions strictly below r)
[@@"opaque_to_smt"]
unfold private let tip_top_predicate (tip:rid) (h:hmap) :Type0 =
forall (r:sid). r `is_in` h <==> r `is_above` tip
[@@"opaque_to_smt"]
unfold private let rid_ctr_pred_predicate (h:hmap) (n:int) :Type0 =
forall (r:rid). h `Map.contains` r ==> rid_last_component r < n
(****** Mem definition ******)
[@@ remove_unused_type_parameters [0]]
val map_invariant (m:hmap) :Type0 //all regions above a contained region are contained
[@@ remove_unused_type_parameters [0]]
val downward_closed (h:hmap) :Type0 //regions below a non-root region are of the same color
[@@ remove_unused_type_parameters [0;1]]
val tip_top (tip:rid) (h:hmap) :Type0 //all contained stack regions are above tip
[@@ remove_unused_type_parameters [0;1]]
val rid_ctr_pred (h:hmap) (n:int) :Type0 //all live regions have last component less than the rid_ctr
let is_tip (tip:rid) (h:hmap) =
(is_stack_region tip \/ tip = root) /\ //the tip is a stack region, or the root
tip `is_in` h /\ //the tip is live
tip_top tip h //any other sid activation is a above (or equal to) the tip
let is_wf_with_ctr_and_tip (h:hmap) (ctr:int) (tip:rid)
= (not (rid_freeable root)) /\
root `is_in` h /\
tip `is_tip` h /\
map_invariant h /\
downward_closed h /\
rid_ctr_pred h ctr
private val mem' :Type u#1
private val mk_mem (rid_ctr:int) (h:hmap) (tip:rid) :mem'
val get_hmap (m:mem') :hmap
val get_rid_ctr (m:mem') :int
val get_tip (m:mem') :rid
private val lemma_mk_mem'_projectors (rid_ctr:int) (h:hmap) (tip:rid)
:Lemma (requires True)
(ensures (let m = mk_mem rid_ctr h tip in
(get_hmap m == h /\ get_rid_ctr m == rid_ctr /\ get_tip m == tip)))
[SMTPatOr [[SMTPat (get_hmap (mk_mem rid_ctr h tip))];
[SMTPat (get_rid_ctr (mk_mem rid_ctr h tip))];
[SMTPat (get_tip (mk_mem rid_ctr h tip))]
]]
type mem :Type = m:mem'{is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m) }
(****** Lemmas about mem and predicates ******)
private val lemma_mem_projectors_are_in_wf_relation (m:mem)
:Lemma (is_wf_with_ctr_and_tip (get_hmap m) (get_rid_ctr m) (get_tip m))
private val lemma_is_wf_ctr_and_tip_intro (h:hmap) (ctr:int) (tip:rid)
:Lemma (requires (root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h ctr))
(ensures (is_wf_with_ctr_and_tip h ctr tip))
private val lemma_is_wf_ctr_and_tip_elim (m:mem)
:Lemma (let h, rid_ctr, tip = get_hmap m, get_rid_ctr m, get_tip m in
(root `is_in` h /\ (is_stack_region tip \/ tip = root) /\ tip `is_in` h /\
tip_top_predicate tip h /\ map_invariant_predicate h /\
downward_closed_predicate h /\ rid_ctr_pred_predicate h rid_ctr))
(******* map_invariant related lemmas ******)
val lemma_map_invariant (m:mem) (r s:rid)
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (s `is_in` get_hmap m))
[SMTPat (r `is_in` get_hmap m); SMTPat (s `is_above` r); SMTPat (s `is_in` get_hmap m)]
(****** downward_closed related lemmas *******)
val lemma_downward_closed (m:mem) (r:rid) (s:rid{s =!= root})
:Lemma (requires (r `is_in` get_hmap m /\ s `is_above` r))
(ensures (is_heap_color (color r) == is_heap_color (color s) /\
is_stack_region r == is_stack_region s))
[SMTPatOr [[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_heap_color (color s))];
[SMTPat (get_hmap m `Map.contains` r); SMTPat (s `is_above` r); SMTPat (is_stack_region s)]
]]
(****** tip_top related lemmas ******)
val lemma_tip_top (m:mem) (r:sid)
:Lemma (r `is_in` get_hmap m <==> r `is_above` get_tip m)
(*
* Pointer uses lemma_tip_top by calling it explicitly with Classical.forall_intro2
* Classical.forall_intro2 does not work well with SMTPat
* So adding this smt form of the same lemma
*)
val lemma_tip_top_smt (m:mem) (r:rid)
:Lemma (requires (is_stack_region r))
(ensures (r `is_in` get_hmap m <==> r `is_above` get_tip m))
[SMTPatOr [[SMTPat (is_stack_region r); SMTPat (r `is_above` get_tip m)];
[SMTPat (is_stack_region r); SMTPat (r `is_in` get_hmap m)]]]
(****** rid_ctr_pred related lemmas ******)
val lemma_rid_ctr_pred (_:unit)
:Lemma (forall (m:mem) (r:rid).{:pattern (get_hmap m `Map.contains` r)} get_hmap m `Map.contains` r ==> rid_last_component r < get_rid_ctr m)
(*****)
(****** Operations on mem ******)
let empty_mem : mem =
let empty_map = Map.restrict Set.empty (Map.const Heap.emp) in
let h = Map.upd empty_map root Heap.emp in
let tip = root in
root_last_component ();
lemma_is_wf_ctr_and_tip_intro h 1 tip;
mk_mem 1 h tip
let heap_region_does_not_overlap_with_tip
(m:mem) (r:rid{is_heap_color (color r) /\ not (disjoint r (get_tip m)) /\ r =!= root /\ is_stack_region (get_tip m)})
: Lemma (requires True)
(ensures (~ (r `is_in` get_hmap m)))
= root_has_color_zero()
let poppable (m:mem) = get_tip m =!= root
private let remove_elt (#a:eqtype) (s:Set.set a) (x:a) = Set.intersect s (Set.complement (Set.singleton x))
let popped (m0 m1:mem) =
poppable m0 /\
(let h0, tip0, h1, tip1 = get_hmap m0, get_tip m0, get_hmap m1, get_tip m1 in
(parent tip0 = tip1 /\
Set.equal (Map.domain h1) (remove_elt (Map.domain h0) tip0) /\
Map.equal h1 (Map.restrict (Map.domain h1) h0)))
let pop (m0:mem{poppable m0}) :mem =
let h0, tip0, rid_ctr0 = get_hmap m0, get_tip m0, get_rid_ctr m0 in
root_has_color_zero();
lemma_is_wf_ctr_and_tip_elim m0;
let dom = remove_elt (Map.domain h0) tip0 in
let h1 = Map.restrict dom h0 in
let tip1 = parent tip0 in
lemma_is_wf_ctr_and_tip_intro h1 rid_ctr0 tip1;
mk_mem rid_ctr0 h1 tip1
//A (reference a) may reside in the stack or heap, and may be manually managed
//Mark it private so that clients can't use its projectors etc.
//enabling extraction of mreference to just a reference in ML and pointer in C
//note that this not enforcing any abstraction
(*
* AR: 12/26: Defining it using Heap.mref directly, removing the HyperHeap.mref indirection
*)
private noeq
type mreference' (a:Type) (rel:preorder a) =
| MkRef : frame:rid -> ref:Heap.mref a rel -> mreference' a rel
let mreference a rel = mreference' a rel
//TODO: rename to frame_of, avoiding the inconsistent use of camelCase
let frameOf (#a:Type) (#rel:preorder a) (r:mreference a rel) :rid
= r.frame
let mk_mreference (#a:Type) (#rel:preorder a) (id:rid)
(r:Heap.mref a rel)
:mreference a rel
= MkRef id r
//Hopefully we can get rid of this one
val as_ref (#a:Type0) (#rel:preorder a) (x:mreference a rel)
:Heap.mref a rel
//And make this one abstract
let as_addr #a #rel (x:mreference a rel)
:GTot pos
= Heap.addr_of (as_ref x)
val lemma_as_ref_inj (#a:Type) (#rel:preorder a) (r:mreference a rel)
:Lemma (requires True) (ensures (mk_mreference (frameOf r) (as_ref r) == r))
[SMTPat (as_ref r)]
let is_mm (#a:Type) (#rel:preorder a) (r:mreference a rel) :GTot bool =
Heap.is_mm (as_ref r)
// Warning: all of the type aliases below get special support for KaRaMeL
// extraction. If you rename or add to this list,
// src/extraction/FStar.Extraction.Karamel.fs needs to be updated.
//adding (not s.mm) to stackref and ref so as to keep their semantics as is
let mstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && not (is_mm s) }
let mref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && not (is_mm s) }
let mmmstackref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_stack_region (frameOf s) && is_mm s }
let mmmref (a:Type) (rel:preorder a) =
s:mreference a rel{ is_eternal_region_hs (frameOf s) && is_mm s }
//NS: Why do we need this one?
let s_mref (i:rid) (a:Type) (rel:preorder a) = s:mreference a rel{frameOf s = i}
(*
* AR: this used to be (is_eternal_region i \/ i `is_above` m.tip) /\ Map.contains ...
* As far as the memory model is concerned, this should just be Map.contains
* The fact that an eternal region is always contained (because of monotonicity) should be used in the ST interface | false | true | FStar.Monotonic.HyperStack.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val live_region (m: mem) (i: rid) : bool | [] | FStar.Monotonic.HyperStack.live_region | {
"file_name": "ulib/FStar.Monotonic.HyperStack.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: FStar.Monotonic.HyperStack.mem -> i: FStar.Monotonic.HyperHeap.rid -> Prims.bool | {
"end_col": 67,
"end_line": 273,
"start_col": 40,
"start_line": 273
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.