file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.fmul5
val fmul5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
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)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 216, "start_col": 0, "start_line": 154 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "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" ]
[]
false
false
false
true
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)
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.fsqr5
val fsqr5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
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)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 250, "start_col": 0, "start_line": 220 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "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" ]
[]
false
false
false
true
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)
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.example2
val example2 (r: ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp)
val example2 (r: ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp)
let example2 (r:ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp) = let p1 = kfork (fun _ -> write_pt #_ #0 r 1) in p1
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 4, "end_line": 255, "start_col": 0, "start_line": 253 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_ // (* Sanity check *) let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) = (); f (); () (* Identity cont with frame, to eliminate a SteelK *) let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame) = noop(); return x let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q)) : SteelK (thread q) p (fun _ -> emp) = SteelK?.reflect ( fun (#frame:vprop) (#postf:vprop) (k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) -> noop (); let t1 () : SteelT unit (emp `star` p) (fun _ -> q) = let r : steelK unit false p (fun _ -> q) = reify (f ()) in r #emp #q (fun _ -> idk()) in let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in let ff () : SteelT unit (p `star` frame) (fun _ -> postf) = fork #p #q #frame #postf t1 t2 in ff()) let kjoin (#p:vprop) (t : thread p) : SteelK unit emp (fun _ -> p) = SteelK?.reflect (fun #f k -> join t; k ()) (* Example *) assume val q : int -> vprop assume val f : unit -> SteelK unit emp (fun _ -> emp) assume val g : i:int -> SteelK unit emp (fun _ -> q i) assume val h : unit -> SteelK unit emp (fun _ -> emp) let example () : SteelK unit emp (fun _ -> q 1 `star` q 2) = let p1:thread (q 1) = kfork (fun () -> g 1) in let p2:thread (q 2) = kfork (fun () -> g 2) in kjoin p1; h(); kjoin p2 let as_steelk_repr' (a:Type) (pre:pre_t) (post:post_t a) (f:unit -> SteelT a pre post) : steelK a false pre post = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in k x let triv_pre (req:vprop) : req_t req = fun _ -> True let triv_post (#a:Type) (req:vprop) (ens:post_t a) : ens_t req a ens = fun _ _ _ -> True let as_steelk_repr (a:Type) (pre:pre_t) (post:post_t a) (f:repr a false pre post (triv_pre pre) (triv_post pre post))// unit -> SteelT a pre post) : steelK a false pre post = as_steelk_repr' a pre post (fun _ -> SteelBase?.reflect f) // let as_steelk_repr' (a:Type) (pre:slprop) (post:post_t a) (f:unit -> SteelT a pre post) // : steelK a pre post // = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> // let x = f () in // k x // let as_steelk (#a:Type) (#pre:slprop) (#post:post_t a) ($f:unit -> SteelT a pre post) // : SteelK a pre post // = SteelK?.reflect (as_steelk_repr a pre post f) open Steel.FractionalPermission sub_effect SteelBase ~> SteelKBase = as_steelk_repr
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.Reference.ref Prims.int -> Steel.Primitive.ForkJoin.Unix.SteelK (Steel.Primitive.ForkJoin.thread (Steel.Reference.pts_to r Steel.FractionalPermission.full_perm 1))
Steel.Primitive.ForkJoin.Unix.SteelK
[]
[]
[ "Steel.Reference.ref", "Prims.int", "Steel.Primitive.ForkJoin.thread", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Primitive.ForkJoin.Unix.kfork", "FStar.Ghost.reveal", "FStar.Ghost.hide", "Prims.unit", "Steel.Reference.write_pt", "Steel.Effect.Common.emp", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let example2 (r: ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp) =
let p1 = kfork (fun _ -> write_pt #_ #0 r 1) in p1
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.bn_to_bytes_be
val bn_to_bytes_be: Hacl.Bignum.Convert.bn_to_bytes_be_st t_limbs n_bytes
val bn_to_bytes_be: Hacl.Bignum.Convert.bn_to_bytes_be_st t_limbs n_bytes
let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 167, "start_col": 0, "start_line": 167 }
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
{ "checked_file": "/", "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" }
[ { "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.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Convert.bn_to_bytes_be_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_bytes
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_to_bytes_be", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_bytes" ]
[]
false
false
false
true
false
let bn_to_bytes_be =
Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.kjoin
val kjoin (#p: vprop) (t: thread p) : SteelK unit emp (fun _ -> p)
val kjoin (#p: vprop) (t: thread p) : SteelK unit emp (fun _ -> p)
let kjoin (#p:vprop) (t : thread p) : SteelK unit emp (fun _ -> p) = SteelK?.reflect (fun #f k -> join t; k ())
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 45, "end_line": 208, "start_col": 0, "start_line": 207 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_ // (* Sanity check *) let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) = (); f (); () (* Identity cont with frame, to eliminate a SteelK *) let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame) = noop(); return x let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q)) : SteelK (thread q) p (fun _ -> emp) = SteelK?.reflect ( fun (#frame:vprop) (#postf:vprop) (k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) -> noop (); let t1 () : SteelT unit (emp `star` p) (fun _ -> q) = let r : steelK unit false p (fun _ -> q) = reify (f ()) in r #emp #q (fun _ -> idk()) in let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in let ff () : SteelT unit (p `star` frame) (fun _ -> postf) = fork #p #q #frame #postf t1 t2 in ff())
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Steel.Primitive.ForkJoin.thread p -> Steel.Primitive.ForkJoin.Unix.SteelK Prims.unit
Steel.Primitive.ForkJoin.Unix.SteelK
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Primitive.ForkJoin.thread", "Prims.unit", "Steel.Effect.Common.star", "Steel.Primitive.ForkJoin.join", "Steel.Effect.Common.emp" ]
[]
false
true
false
false
false
let kjoin (#p: vprop) (t: thread p) : SteelK unit emp (fun _ -> p) =
SteelK?.reflect (fun #f k -> join t; k ())
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.perform
val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post
val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post
let perform f = f ()
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 33, "start_col": 0, "start_line": 33 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post)
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.unit -> Pulse.Lib.Core.stt a pre post) -> Pulse.Lib.Core.stt a pre post
Prims.Tot
[ "total" ]
[]
[ "Pulse.Lib.Core.vprop", "Prims.unit", "Pulse.Lib.Core.stt" ]
[]
false
false
false
false
false
let perform f =
f ()
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.tthd
val tthd (x: 'a & 'b & 'c) : 'c
val tthd (x: 'a & 'b & 'c) : 'c
let tthd (x:'a & 'b & 'c) : 'c = Mktuple3?._3 x
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 47, "end_line": 79, "start_col": 0, "start_line": 79 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1 let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1 // // Native extraction in the Rust backend // ```pulse fn ref_apply (#a #b:Type) (r:ref (a -> b)) (x:a) (#f:erased (a -> b)) requires pts_to r f returns y:b ensures pts_to r f ** pure (y == (reveal f) x) { let f = !r; f x } ``` // // Native extraction in the Rust backend // let tfst (x:'a & 'b & 'c) : 'a = Mktuple3?._1 x
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: (('a * 'b) * 'c) -> 'c
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.__proj__Mktuple3__item___3" ]
[]
false
false
false
true
false
let tthd (x: 'a & 'b & 'c) : 'c =
Mktuple3?._3 x
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.default_arg
val default_arg : t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
let default_arg (t:T.term) = T.exact t
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 83, "start_col": 0, "start_line": 83 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1 let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1 // // Native extraction in the Rust backend // ```pulse fn ref_apply (#a #b:Type) (r:ref (a -> b)) (x:a) (#f:erased (a -> b)) requires pts_to r f returns y:b ensures pts_to r f ** pure (y == (reveal f) x) { let f = !r; f x } ``` // // Native extraction in the Rust backend // let tfst (x:'a & 'b & 'c) : 'a = Mktuple3?._1 x let tsnd (x:'a & 'b & 'c) : 'b = Mktuple3?._2 x let tthd (x:'a & 'b & 'c) : 'c = Mktuple3?._3 x // some convenience functions
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.exact", "Prims.unit" ]
[]
false
true
false
false
false
let default_arg (t: T.term) =
T.exact t
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.perform_ghost
val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post
val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post
let perform_ghost f = f ()
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 39, "start_col": 0, "start_line": 39 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post)
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.unit -> Pulse.Lib.Core.stt_ghost a pre post) -> Pulse.Lib.Core.stt_ghost a pre post
Prims.Tot
[ "total" ]
[]
[ "Pulse.Lib.Core.vprop", "Prims.unit", "Pulse.Lib.Core.stt_ghost" ]
[]
false
false
false
false
false
let perform_ghost f =
f ()
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.tsnd
val tsnd (x: 'a & 'b & 'c) : 'b
val tsnd (x: 'a & 'b & 'c) : 'b
let tsnd (x:'a & 'b & 'c) : 'b = Mktuple3?._2 x
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 47, "end_line": 78, "start_col": 0, "start_line": 78 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1 let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1 // // Native extraction in the Rust backend // ```pulse fn ref_apply (#a #b:Type) (r:ref (a -> b)) (x:a) (#f:erased (a -> b)) requires pts_to r f returns y:b ensures pts_to r f ** pure (y == (reveal f) x) { let f = !r; f x } ``` // // Native extraction in the Rust backend //
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: (('a * 'b) * 'c) -> 'b
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.__proj__Mktuple3__item___2" ]
[]
false
false
false
true
false
let tsnd (x: 'a & 'b & 'c) : 'b =
Mktuple3?._2 x
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.tfst
val tfst (x: 'a & 'b & 'c) : 'a
val tfst (x: 'a & 'b & 'c) : 'a
let tfst (x:'a & 'b & 'c) : 'a = Mktuple3?._1 x
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 47, "end_line": 77, "start_col": 0, "start_line": 77 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1 let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1 // // Native extraction in the Rust backend // ```pulse fn ref_apply (#a #b:Type) (r:ref (a -> b)) (x:a) (#f:erased (a -> b)) requires pts_to r f returns y:b ensures pts_to r f ** pure (y == (reveal f) x) { let f = !r; f x } ``` // // Native extraction in the Rust backend
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: (('a * 'b) * 'c) -> 'a
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.__proj__Mktuple3__item___1" ]
[]
false
false
false
true
false
let tfst (x: 'a & 'b & 'c) : 'a =
Mktuple3?._1 x
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.vprop_equiv_norm
val vprop_equiv_norm: unit -> T.Tac unit
val vprop_equiv_norm: unit -> T.Tac unit
let vprop_equiv_norm (_:unit) : T.Tac unit = T.mapply (`vprop_equiv_refl)
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 105, "start_col": 0, "start_line": 104 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1 let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1 // // Native extraction in the Rust backend // ```pulse fn ref_apply (#a #b:Type) (r:ref (a -> b)) (x:a) (#f:erased (a -> b)) requires pts_to r f returns y:b ensures pts_to r f ** pure (y == (reveal f) x) { let f = !r; f x } ``` // // Native extraction in the Rust backend // let tfst (x:'a & 'b & 'c) : 'a = Mktuple3?._1 x let tsnd (x:'a & 'b & 'c) : 'b = Mktuple3?._2 x let tthd (x:'a & 'b & 'c) : 'c = Mktuple3?._3 x // some convenience functions module T = FStar.Tactics let default_arg (t:T.term) = T.exact t ```pulse ghost fn call_ghost (#a:Type0) (#b: a -> Type0) (#pre: a -> vprop) (#post: (x:a -> b x -> vprop)) (f:(x:a -> stt_ghost (b x) (pre x) (fun y -> post x y))) (x:a) requires pre x returns y:erased (b x) ensures post x y { let y = f x; rewrite (post x y) as (post x (reveal (hide y))); hide y } ```
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.mapply" ]
[]
false
true
false
false
false
let vprop_equiv_norm (_: unit) : T.Tac unit =
T.mapply (`vprop_equiv_refl)
false
Vale.PPC64LE.Stack_i.fsti
Vale.PPC64LE.Stack_i.modifies_stack
val modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0
val modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0
let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 26, "start_col": 0, "start_line": 22 }
module Vale.PPC64LE.Stack_i open FStar.Mul open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val init_r1 (h:vale_stack) : (n:nat64{n >= 65536})
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Stack_i.fsti" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lo_r1: Prims.nat -> hi_r1: Prims.nat -> h: Vale.PPC64LE.Stack_i.vale_stack -> h': Vale.PPC64LE.Stack_i.vale_stack -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.PPC64LE.Stack_i.vale_stack", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Vale.PPC64LE.Stack_i.valid_src_stack64", "Prims.op_BarBar", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_GreaterThanOrEqual", "Prims.eq2", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Stack_i.load_stack64", "Vale.Def.Prop_s.prop0" ]
[]
false
false
false
true
false
let modifies_stack (lo_r1 hi_r1: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr. {:pattern (load_stack64 addr h')\/(valid_src_stack64 addr h')} valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.inames_ext
val inames_ext (is1 is2: inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)]
val inames_ext (is1 is2: inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)]
let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 46, "start_col": 0, "start_line": 42 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f ()
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
is1: Pulse.Lib.Core.inames -> is2: Pulse.Lib.Core.inames -> FStar.Pervasives.Lemma (requires forall (i: Pulse.Lib.Core.iname). FStar.Set.mem i (FStar.Ghost.reveal is1) <==> FStar.Set.mem i (FStar.Ghost.reveal is2)) (ensures is1 == is2) [SMTPat (is1 == is2)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Lib.Core.inames", "FStar.Set.lemma_equal_intro", "Pulse.Lib.Core.iname", "FStar.Ghost.reveal", "FStar.Set.set", "Prims.unit", "Prims.l_Forall", "Prims.l_iff", "Prims.b2t", "FStar.Set.mem", "Prims.squash", "Prims.eq2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.logical", "Prims.Nil" ]
[]
true
false
true
false
false
let inames_ext (is1 is2: inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] =
Set.lemma_equal_intro is1 is2
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.inames_join_self
val inames_join_self (is1: inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)]
val inames_join_self (is1: inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)]
let inames_join_self (is1 : inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] = Set.lemma_equal_intro (join_inames is1 is1) is1
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 58, "start_col": 0, "start_line": 56 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1 let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
is1: Pulse.Lib.Core.inames -> FStar.Pervasives.Lemma (ensures Pulse.Lib.Core.join_inames is1 is1 == is1) [SMTPat (Pulse.Lib.Core.join_inames is1 is1)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Lib.Core.inames", "FStar.Set.lemma_equal_intro", "Pulse.Lib.Core.iname", "FStar.Ghost.reveal", "FStar.Set.set", "Pulse.Lib.Core.join_inames", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let inames_join_self (is1: inames) : Lemma (join_inames is1 is1 == is1) [SMTPat (join_inames is1 is1)] =
Set.lemma_equal_intro (join_inames is1 is1) is1
false
Vale.PPC64LE.Stack_i.fsti
Vale.PPC64LE.Stack_i.modifies_stacktaint
val modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0
val modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0
let modifies_stacktaint (lo_r1 hi_r1:nat) (h h':memtaint) : Vale.Def.Prop_s.prop0 = forall addr t. {:pattern (valid_taint_stack64 addr t h') } (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_taint_stack64 addr t h == valid_taint_stack64 addr t h'
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 179, "start_col": 0, "start_line": 176 }
module Vale.PPC64LE.Stack_i open FStar.Mul open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val init_r1 (h:vale_stack) : (n:nat64{n >= 65536}) let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures valid_src_stack128 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures valid_src_stack128 ptr (free_stack128 start finish h)) [SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (valid_src_stack128 ptr (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (load_stack128 ptr (store_stack128 ptr v h) == v) [SMTPat (load_stack128 ptr (store_stack128 ptr v h))] val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h)) [SMTPat (load_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h)) [SMTPat (load_stack128 ptr (free_stack128 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack64 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack64 start finish h))] val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_r1 (store_stack64 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack64 ptr v h))] val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack128 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack128 start finish h))] val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (init_r1 (store_stack128 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack128 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack128 ptr t stackTaint) val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))] val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 16 \/ i + 16 <= ptr) (ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))] let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/ (valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Stack_i.fsti" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lo_r1: Prims.nat -> hi_r1: Prims.nat -> h: Vale.PPC64LE.Memory.memtaint -> h': Vale.PPC64LE.Memory.memtaint -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.PPC64LE.Memory.memtaint", "Prims.l_Forall", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Prims.l_imp", "Prims.b2t", "Prims.op_BarBar", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_GreaterThanOrEqual", "Prims.eq2", "Vale.Def.Prop_s.prop0", "Vale.PPC64LE.Stack_i.valid_taint_stack64" ]
[]
false
false
false
true
false
let modifies_stacktaint (lo_r1 hi_r1: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 =
forall addr t. {:pattern (valid_taint_stack64 addr t h')} (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_taint_stack64 addr t h == valid_taint_stack64 addr t h'
false
Vale.PPC64LE.Stack_i.fsti
Vale.PPC64LE.Stack_i.valid_stack_slot64
val valid_stack_slot64 : ptr: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.PPC64LE.Memory.memtaint -> Prims.logical
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 168, "start_col": 0, "start_line": 167 }
module Vale.PPC64LE.Stack_i open FStar.Mul open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val init_r1 (h:vale_stack) : (n:nat64{n >= 65536}) let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures valid_src_stack128 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures valid_src_stack128 ptr (free_stack128 start finish h)) [SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (valid_src_stack128 ptr (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (load_stack128 ptr (store_stack128 ptr v h) == v) [SMTPat (load_stack128 ptr (store_stack128 ptr v h))] val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h)) [SMTPat (load_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h)) [SMTPat (load_stack128 ptr (free_stack128 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack64 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack64 start finish h))] val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_r1 (store_stack64 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack64 ptr v h))] val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack128 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack128 start finish h))] val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (init_r1 (store_stack128 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack128 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack128 ptr t stackTaint) val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))] val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 16 \/ i + 16 <= ptr) (ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))]
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Stack_i.fsti" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.PPC64LE.Memory.memtaint -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Memory.memtaint", "Prims.l_and", "Prims.b2t", "Vale.PPC64LE.Stack_i.valid_src_stack64", "Vale.PPC64LE.Stack_i.valid_taint_stack64", "Prims.logical" ]
[]
false
false
false
true
true
let valid_stack_slot64 (ptr: int) (h: vale_stack) (t: taint) (stackTaint: memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.inames_join_emp_l
val inames_join_emp_l (is1: inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)]
val inames_join_emp_l (is1: inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)]
let inames_join_emp_l (is1 : inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] = Set.lemma_equal_intro (join_inames emp_inames is1) is1
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 54, "start_col": 0, "start_line": 52 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2 let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
is1: Pulse.Lib.Core.inames -> FStar.Pervasives.Lemma (ensures Pulse.Lib.Core.join_inames Pulse.Lib.Core.emp_inames is1 == is1) [SMTPat (Pulse.Lib.Core.join_inames Pulse.Lib.Core.emp_inames is1)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Lib.Core.inames", "FStar.Set.lemma_equal_intro", "Pulse.Lib.Core.iname", "FStar.Ghost.reveal", "FStar.Set.set", "Pulse.Lib.Core.join_inames", "Pulse.Lib.Core.emp_inames", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let inames_join_emp_l (is1: inames) : Lemma (join_inames emp_inames is1 == is1) [SMTPat (join_inames emp_inames is1)] =
Set.lemma_equal_intro (join_inames emp_inames is1) is1
false
Vale.PPC64LE.Stack_i.fsti
Vale.PPC64LE.Stack_i.valid_src_stack64s
val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0
val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 31, "start_col": 0, "start_line": 28 }
module Vale.PPC64LE.Stack_i open FStar.Mul open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val init_r1 (h:vale_stack) : (n:nat64{n >= 65536}) let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Stack_i.fsti" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
base: Prims.nat -> num_slots: Prims.nat -> h: Vale.PPC64LE.Stack_i.vale_stack -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.PPC64LE.Stack_i.vale_stack", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_Subtraction", "Vale.PPC64LE.Stack_i.valid_src_stack64", "Vale.Def.Prop_s.prop0" ]
[]
false
false
false
true
false
let valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr. {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h
false
Vale.PPC64LE.Stack_i.fsti
Vale.PPC64LE.Stack_i.valid_stack_slot64s
val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0
val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0
let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/ (valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 174, "start_col": 0, "start_line": 170 }
module Vale.PPC64LE.Stack_i open FStar.Mul open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val free_stack128 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val init_r1 (h:vale_stack) : (n:nat64{n >= 65536}) let modifies_stack (lo_r1 hi_r1:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_r1 || addr >= hi_r1) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures valid_src_stack128 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures valid_src_stack128 ptr (free_stack128 start finish h)) [SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (valid_src_stack128 ptr (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (load_stack128 ptr (store_stack128 ptr v h) == v) [SMTPat (load_stack128 ptr (store_stack128 ptr v h))] val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h)) [SMTPat (load_stack128 i (store_stack128 ptr v h))] val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h)) [SMTPat (load_stack128 ptr (free_stack128 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_r1_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack64 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack64 start finish h))] val lemma_same_init_r1_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_r1 (store_stack64 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack64 ptr v h))] val lemma_same_init_r1_free_stack128 (start:int) (finish:int) (h:vale_stack) : Lemma (init_r1 (free_stack128 start finish h) == init_r1 h) [SMTPat (init_r1 (free_stack128 start finish h))] val lemma_same_init_r1_store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (init_r1 (store_stack128 ptr v h) == init_r1 h) [SMTPat (init_r1 (store_stack128 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val store_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] val lemma_valid_taint_stack128_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack128 ptr t stackTaint) val lemma_correct_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 ptr t (store_taint_stack128 ptr t stackTaint))] val lemma_frame_store_load_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 16 \/ i + 16 <= ptr) (ensures valid_taint_stack128 i t' stackTaint == valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint)) [SMTPat (valid_taint_stack128 i t' (store_taint_stack128 ptr t stackTaint))] let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Stack_i.fsti" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
base: Prims.nat -> num_slots: Prims.nat -> h: Vale.PPC64LE.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.PPC64LE.Memory.memtaint -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.HeapTypes_s.taint", "Vale.PPC64LE.Memory.memtaint", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.l_and", "Vale.PPC64LE.Stack_i.valid_src_stack64", "Vale.PPC64LE.Stack_i.valid_taint_stack64", "Vale.PPC64LE.Stack_i.valid_stack_slot64", "Vale.Def.Prop_s.prop0" ]
[]
false
false
false
true
false
let valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0 =
forall addr. {:pattern (valid_src_stack64 addr h)\/(valid_taint_stack64 addr t stackTaint)\/(valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
false
Pulse.Lib.Pervasives.fst
Pulse.Lib.Pervasives.inames_join_emp_r
val inames_join_emp_r (is1: inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)]
val inames_join_emp_r (is1: inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)]
let inames_join_emp_r (is1 : inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] = Set.lemma_equal_intro (join_inames is1 emp_inames) is1
{ "file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Pervasives.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 50, "start_col": 0, "start_line": 48 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Lib.Pervasives include Pulse.Main include Pulse.Lib.Core include Pulse.Lib.Forall include Pulse.Lib.Array include Pulse.Lib.Reference include PulseCore.FractionalPermission include PulseCore.Observability include FStar.Ghost (* Pulse will currently not recognize calls to anything other than top-level names, so this allows to force it. *) val perform (#a #pre #post : _) (f : unit -> stt a pre post) : stt a pre post let perform f = f () val perform_ghost (#a #pre #post : _) (f : unit -> stt_ghost a pre post) : stt_ghost a pre post let perform_ghost f = f () (* TEMPORARY! REMOVE! *) let inames_ext (is1 is2 : inames) : Lemma (requires forall i. Set.mem i is1 <==> Set.mem i is2) (ensures is1 == is2) [SMTPat (is1 == is2)] = Set.lemma_equal_intro is1 is2
{ "checked_file": "/", "dependencies": [ "PulseCore.Observability.fst.checked", "PulseCore.FractionalPermission.fst.checked", "Pulse.Main.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Forall.fsti.checked", "Pulse.Lib.Core.fsti.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Lib.Pervasives.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Reference", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Array", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Forall", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Core", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Main", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
is1: Pulse.Lib.Core.inames -> FStar.Pervasives.Lemma (ensures Pulse.Lib.Core.join_inames is1 Pulse.Lib.Core.emp_inames == is1) [SMTPat (Pulse.Lib.Core.join_inames is1 Pulse.Lib.Core.emp_inames)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Lib.Core.inames", "FStar.Set.lemma_equal_intro", "Pulse.Lib.Core.iname", "FStar.Ghost.reveal", "FStar.Set.set", "Pulse.Lib.Core.join_inames", "Pulse.Lib.Core.emp_inames", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let inames_join_emp_r (is1: inames) : Lemma (join_inames is1 emp_inames == is1) [SMTPat (join_inames is1 emp_inames)] =
Set.lemma_equal_intro (join_inames is1 emp_inames) is1
false
EverCrypt.Curve25519.fst
EverCrypt.Curve25519.has_adx_bmi2
val has_adx_bmi2: Prims.unit -> Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
val has_adx_bmi2: Prims.unit -> Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled))))
let has_adx_bmi2 (): Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) = let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in has_bmi2 && has_adx
{ "file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 14, "start_col": 0, "start_line": 6 }
module EverCrypt.Curve25519 module B = LowStar.Buffer
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Hacl.Curve25519_64.fsti.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.Pervasives.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 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": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.unit", "Prims.op_AmpAmp", "Prims.bool", "EverCrypt.AutoConfig2.has_adx", "EverCrypt.AutoConfig2.has_bmi2", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "Prims.l_and", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.l_imp", "Prims.b2t", "Vale.X64.CPU_Features_s.adx_enabled", "Vale.X64.CPU_Features_s.bmi2_enabled" ]
[]
false
true
false
false
false
let has_adx_bmi2 () : Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) =
let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in has_bmi2 && has_adx
false
Vale.Interop.fst
Vale.Interop.addrs_set_lemma_all
val addrs_set_lemma_all (_:unit) : Lemma (forall (mem:interop_heap) (x:int).{:pattern (Set.mem x (addrs_set mem))} let addrs = addrs_of_mem mem in let ptrs = ptrs_of_mem mem in valid_addr mem x <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
val addrs_set_lemma_all (_:unit) : Lemma (forall (mem:interop_heap) (x:int).{:pattern (Set.mem x (addrs_set mem))} let addrs = addrs_of_mem mem in let ptrs = ptrs_of_mem mem in valid_addr mem x <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 200, "start_col": 0, "start_line": 199 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (mem: Vale.Interop.Heap_s.interop_heap) (x: Prims.int). {:pattern FStar.Set.mem x (Vale.Interop.Heap_s.addrs_set mem)} let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in Vale.Interop.valid_addr mem x <==> (exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). {:pattern addrs b} addrs b <= x /\ x < addrs b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Classical.forall_intro_2", "Vale.Interop.Heap_s.interop_heap", "Prims.int", "Prims.l_iff", "Prims.b2t", "Vale.Interop.valid_addr", "Prims.l_Exists", "Vale.Interop.Types.b8", "FStar.List.Tot.Base.memP", "Vale.Interop.Heap_s.ptrs_of_mem", "Prims.l_and", "Prims.op_LessThanOrEqual", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.op_LessThan", "Prims.op_Addition", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.addrs_set_lemma" ]
[]
false
false
true
false
false
let addrs_set_lemma_all () =
FStar.Classical.forall_intro_2 addrs_set_lemma
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.add_carry_st
val add_carry_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0
let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin))
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 25, "start_col": 0, "start_line": 15 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Lib.IntTypes.U32", "Lib.IntTypes.U64", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.Buffer.modifies1", "Prims.eq2", "Prims.int", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.bits", "Lib.IntTypes.int_t", "FStar.Seq.Base.index", "Lib.Buffer.as_seq" ]
[]
false
false
false
false
true
let add_carry_st (t: inttype{t = U32 \/ t = U64}) =
cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin))
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.add_carry_u64
val add_carry_u64: add_carry_st U64
val add_carry_u64: add_carry_st U64
let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 86, "start_col": 0, "start_line": 86 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin)) val add_carry_u32: add_carry_st U32 let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c inline_for_extraction noextract let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin)) val sub_borrow_u32: sub_borrow_st U32 let sub_borrow_u32 cin x y r = let res = to_u64 x -. to_u64 y -. to_u64 cin in assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64); Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64); assert (v res == (v x - v y - v cin) % pow2 64); assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32); Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64; assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32); let c = to_u32 (res >>. 32ul) &. u32 1 in assert_norm (pow2 1 = 2); mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul; assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1); assert (v c = v res / pow2 32 % pow2 1); r.(0ul) <- to_u32 res; assert (v c = (if 0 <= v x - v y - v cin then 0 else 1)); c (* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which don't support uint128. The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not be changed because they are hardcoded in KaRaMeL for extracting wasm code which uses these intrinsics. *) inline_for_extraction noextract val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t let add_carry_fallback #t cin x y r = let res = x +. cin +. y in let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in r.(0ul) <- res; logand_lemma (eq_mask res x) cin; logor_lemma (lt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.IntTypes.Intrinsics.add_carry_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "Hacl.IntTypes.Intrinsics.add_carry_fallback" ]
[]
false
false
false
true
false
let add_carry_u64 cin x y r =
add_carry_fallback #U64 cin x y r
false
Vale.Interop.fst
Vale.Interop.write_vale_mem
val write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Tot machine_heap (decreases (length - i))
val write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Tot machine_heap (decreases (length - i))
let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap )
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 27, "start_col": 0, "start_line": 19 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> Prims.Tot Vale.Arch.MachineHeap_s.machine_heap
Prims.Tot
[ "total", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment" ]
[ "recursion" ]
false
false
false
false
false
let rec write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Tot machine_heap (decreases (length - i)) =
if i >= length then curr_heap else (let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i + 1) heap)
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.sub_borrow_st
val sub_borrow_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin))
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 45, "start_col": 0, "start_line": 35 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin)) val add_carry_u32: add_carry_st U32 let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Lib.IntTypes.U32", "Lib.IntTypes.U64", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.Buffer.modifies1", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.bits", "Lib.IntTypes.int_t", "FStar.Seq.Base.index", "Lib.Buffer.as_seq" ]
[]
false
false
false
false
true
let sub_borrow_st (t: inttype{t = U32 \/ t = U64}) =
cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin))
false
Vale.Interop.fst
Vale.Interop.addrs_set_lemma
val addrs_set_lemma (mem:interop_heap) (x:int) : Lemma (let addrs = addrs_of_mem mem in let ptrs = ptrs_of_mem mem in valid_addr mem x <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
val addrs_set_lemma (mem:interop_heap) (x:int) : Lemma (let addrs = addrs_of_mem mem in let ptrs = ptrs_of_mem mem in valid_addr mem x <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs b)} addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)))
let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 197, "start_col": 0, "start_line": 196 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> x: Prims.int -> FStar.Pervasives.Lemma (ensures (let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in Vale.Interop.valid_addr mem x <==> (exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). {:pattern addrs b} addrs b <= x /\ x < addrs b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Prims.int", "Vale.Interop.addrs_set_lemma_aux", "Vale.Interop.Heap_s.addrs_of_mem", "Vale.Interop.Heap_s.ptrs_of_mem", "FStar.Set.empty", "Prims.unit" ]
[]
true
false
true
false
false
let addrs_set_lemma mem x =
addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.sub_borrow_u64
val sub_borrow_u64: sub_borrow_st U64
val sub_borrow_u64: sub_borrow_st U64
let sub_borrow_u64 cin x y r = sub_borrow_fallback #U64 cin x y r
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 100, "start_col": 0, "start_line": 100 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin)) val add_carry_u32: add_carry_st U32 let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c inline_for_extraction noextract let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin)) val sub_borrow_u32: sub_borrow_st U32 let sub_borrow_u32 cin x y r = let res = to_u64 x -. to_u64 y -. to_u64 cin in assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64); Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64); assert (v res == (v x - v y - v cin) % pow2 64); assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32); Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64; assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32); let c = to_u32 (res >>. 32ul) &. u32 1 in assert_norm (pow2 1 = 2); mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul; assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1); assert (v c = v res / pow2 32 % pow2 1); r.(0ul) <- to_u32 res; assert (v c = (if 0 <= v x - v y - v cin then 0 else 1)); c (* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which don't support uint128. The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not be changed because they are hardcoded in KaRaMeL for extracting wasm code which uses these intrinsics. *) inline_for_extraction noextract val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t let add_carry_fallback #t cin x y r = let res = x +. cin +. y in let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in r.(0ul) <- res; logand_lemma (eq_mask res x) cin; logor_lemma (lt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; c val add_carry_u64: add_carry_st U64 let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r inline_for_extraction noextract val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t let sub_borrow_fallback #t cin x y r = let res = x -. y -. cin in let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in logand_lemma (eq_mask res x) cin; logor_lemma (gt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; r.(0ul) <- res; c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.IntTypes.Intrinsics.sub_borrow_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "Hacl.IntTypes.Intrinsics.sub_borrow_fallback" ]
[]
false
false
false
true
false
let sub_borrow_u64 cin x y r =
sub_borrow_fallback #U64 cin x y r
false
CQueue.LList.fst
CQueue.LList.free_llist
val free_llist (#a: Type0) (c: cllist_ptrvalue a) // could be cllist_lvalue, but cllist gives the right refinement : Steel unit (cllist c) (fun _ -> emp) (fun _ -> freeable c) (fun _ _ _ -> True)
val free_llist (#a: Type0) (c: cllist_ptrvalue a) // could be cllist_lvalue, but cllist gives the right refinement : Steel unit (cllist c) (fun _ -> emp) (fun _ -> freeable c) (fun _ _ _ -> True)
let free_llist #a c = let c = elim_cllist c in free (cllist_head c); free (cllist_tail c)
{ "file_name": "share/steel/examples/steel/CQueue.LList.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 163, "start_col": 0, "start_line": 158 }
module CQueue.LList noeq type cllist_ptrvalue (a: Type0) = { head: ref (ccell_ptrvalue a); tail: ref (ref (ccell_ptrvalue a)); all_or_none_null: squash (is_null head == is_null tail); } let cllist_ptrvalue_null a = {head = null; tail = null; all_or_none_null = ()} let cllist_ptrvalue_is_null #a x = is_null x.head let cllist_head #a c = c.head let cllist_tail #a c = c.tail #push-options "--ide_id_info_off" let cllist0_refine (#a: Type0) (c: cllist_ptrvalue a) (_: t_of emp) : Tot prop = cllist_ptrvalue_is_null c == false // unfold let cllist0_rewrite (#a: Type0) (c: cllist_ptrvalue a) (_: t_of (emp `vrefine` cllist0_refine c)) : Tot (cllist_lvalue a) = c [@@ __steel_reduce__] let cllist0 (a: Type0) (c: cllist_lvalue a) : Tot vprop = (vptr (cllist_head c) `star` vptr (cllist_tail c)) // unfold let cllist_rewrite (#a: Type0) (c: cllist_ptrvalue a) (x: dtuple2 (cllist_lvalue a) (vdep_payload (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (cllist0 a))) : GTot (vllist a) = let p = dsnd #(cllist_lvalue a) #(vdep_payload (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (cllist0 a)) x in { vllist_head = fst p; vllist_tail = snd p; } [@@ __steel_reduce__ ; __reduce__] // to avoid manual unfoldings through change_slprop let cllist1 (#a: Type0) (c: cllist_ptrvalue a) : Tot vprop = emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a `vrewrite` cllist_rewrite c let cllist_hp #a c = hp_of (cllist1 c) let cllist_sel #a c = sel_of (cllist1 c) let intro_cllist #opened #a c = intro_vrefine emp (cllist0_refine c); intro_vrewrite (emp `vrefine` cllist0_refine c) (cllist0_rewrite c); reveal_star (vptr (cllist_head c)) (vptr (cllist_tail c)); intro_vdep (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (vptr (cllist_head c) `star` vptr (cllist_tail c)) (cllist0 a); intro_vrewrite (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a) (cllist_rewrite c); change_slprop_rel (cllist1 c) (cllist c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (cllist1 c) == cllist_hp c); assert_norm (sel_of (cllist1 c) m === sel_of (cllist c) m) ) let elim_cllist_ghost #opened #a c = change_slprop_rel (cllist c) (cllist1 c) (fun x y -> x == y) (fun m -> assert_norm (hp_of (cllist1 c) == cllist_hp c); assert_norm (sel_of (cllist1 c) m === sel_of (cllist c) m) ); elim_vrewrite (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a) (cllist_rewrite c); let c' : Ghost.erased (cllist_lvalue a) = elim_vdep (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (cllist0 a) in elim_vrewrite (emp `vrefine` cllist0_refine c) (cllist0_rewrite c); elim_vrefine emp (cllist0_refine c); change_equal_slprop (cllist0 a c') (vptr (cllist_head (Ghost.reveal c')) `star` vptr (cllist_tail (Ghost.reveal c'))); reveal_star (vptr (cllist_head (Ghost.reveal c'))) (vptr (cllist_tail (Ghost.reveal c'))); c' let elim_cllist #opened #a c = let c2 = elim_cllist_ghost c in let c : cllist_lvalue a = c in change_equal_slprop (vptr (cllist_head c2)) (vptr (cllist_head c)); change_equal_slprop (vptr (cllist_tail c2)) (vptr (cllist_tail c)); return c let cllist_not_null #opened #a c = let c1 = elim_cllist_ghost c in let c2 : cllist_lvalue a = c in change_equal_slprop (vptr (cllist_head c1)) (vptr (cllist_head c2)); change_equal_slprop (vptr (cllist_tail c1)) (vptr (cllist_tail c2)); intro_cllist c2; change_equal_slprop (cllist c2) (cllist c); () let freeable _ = True let ralloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> h1 (vptr r) == x /\ not (is_null r)) = malloc x let alloc_llist #a head tail = let rhead = ralloc head in let rtail = ralloc tail in let res : cllist_lvalue a = ({ head = rhead; tail = rtail; all_or_none_null = () }) in change_equal_slprop (vptr rhead) (vptr (cllist_head res)); change_equal_slprop (vptr rtail) (vptr (cllist_tail res)); intro_cllist res; return res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "CQueue.LList.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue.Cell", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: CQueue.LList.cllist_ptrvalue a -> Steel.Effect.Steel Prims.unit
Steel.Effect.Steel
[]
[]
[ "CQueue.LList.cllist_ptrvalue", "Steel.Reference.free", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "CQueue.LList.cllist_tail", "Prims.unit", "CQueue.LList.cllist_head", "CQueue.LList.cllist_lvalue", "CQueue.LList.elim_cllist", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty" ]
[]
false
true
false
false
false
let free_llist #a c =
let c = elim_cllist c in free (cllist_head c); free (cllist_tail c)
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.idk
val idk (#frame: vprop) (#a: Type) (x: a) : SteelT a frame (fun x -> frame)
val idk (#frame: vprop) (#a: Type) (x: a) : SteelT a frame (fun x -> frame)
let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame) = noop(); return x
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 188, "start_col": 0, "start_line": 187 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_ // (* Sanity check *) let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) = (); f (); () (* Identity cont with frame, to eliminate a SteelK *)
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Effect.SteelT a
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Atomic.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.Effect.Atomic.noop" ]
[]
false
true
false
false
false
let idk (#frame: vprop) (#a: Type) (x: a) : SteelT a frame (fun x -> frame) =
noop (); return x
false
Vale.Interop.fst
Vale.Interop.addrs_ptr_lemma
val addrs_ptr_lemma (i: nat) (addrs: addr_map) (ptr: b8{i <= DV.length (get_downview ptr.bsrc)}) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc) ) (decreases (DV.length (get_downview ptr.bsrc) - i))
val addrs_ptr_lemma (i: nat) (addrs: addr_map) (ptr: b8{i <= DV.length (get_downview ptr.bsrc)}) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc) ) (decreases (DV.length (get_downview ptr.bsrc) - i))
let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 182, "start_col": 0, "start_line": 171 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat -> addrs: Vale.Interop.Types.addr_map -> ptr: Vale.Interop.Types.b8 {i <= LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr))} -> acc: FStar.Set.set Prims.int -> x: Prims.int -> FStar.Pervasives.Lemma (ensures FStar.Set.mem x (Vale.Interop.Heap_s.addrs_ptr i addrs ptr acc) <==> addrs ptr + i <= x /\ x < addrs ptr + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr)) \/ FStar.Set.mem x acc) (decreases LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc ptr)) - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.nat", "Vale.Interop.Types.addr_map", "Vale.Interop.Types.b8", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "FStar.Set.set", "Prims.int", "Prims.op_Equality", "Prims.bool", "Vale.Interop.addrs_ptr_lemma", "Prims.op_Addition", "FStar.Set.union", "FStar.Set.singleton", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "FStar.Set.mem", "Vale.Interop.Heap_s.addrs_ptr", "Prims.l_or", "Prims.l_and", "Prims.op_LessThan", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec addrs_ptr_lemma (i: nat) (addrs: addr_map) (ptr: b8{i <= DV.length (get_downview ptr.bsrc)}) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc) ) (decreases (DV.length (get_downview ptr.bsrc) - i)) =
if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i + 1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
false
Vale.Interop.fst
Vale.Interop.domain_write_vale_mem
val domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))
val domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))
let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 82, "start_col": 0, "start_line": 66 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> FStar.Pervasives.Lemma (ensures (let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in forall (j: Prims.int). FStar.Set.mem j (FStar.Map.domain new_heap) /\ Prims.op_Negation (FStar.Set.mem j (FStar.Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases length - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.domain_write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Set.mem", "FStar.Map.domain", "Prims.op_Negation", "Vale.Interop.write_vale_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i)) =
if i >= length then () else let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i + 1) heap
false
Vale.Interop.fst
Vale.Interop.domain2_write_vale_mem
val domain2_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))
val domain2_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))
let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 99, "start_col": 0, "start_line": 84 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> FStar.Pervasives.Lemma (requires forall (j: Prims.int). addr <= j /\ j < addr + i ==> FStar.Set.mem j (FStar.Map.domain curr_heap)) (ensures (let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in forall (j: Prims.int). addr <= j /\ j < addr + length ==> FStar.Set.mem j (FStar.Map.domain new_heap))) (decreases length - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.domain2_write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment", "Prims.unit", "FStar.Set.mem", "FStar.Map.domain", "Prims.squash", "Vale.Interop.write_vale_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec domain2_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i)) =
if i >= length then () else let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i + 1) heap
false
Vale.Interop.fst
Vale.Interop.frame_write_vale_mem
val frame_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) (j: int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[ j ] == new_heap.[ j ])) (decreases (length - i))
val frame_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) (j: int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[ j ] == new_heap.[ j ])) (decreases (length - i))
let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j )
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 45, "start_col": 0, "start_line": 29 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap )
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> j: Prims.int -> FStar.Pervasives.Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in curr_heap.[ j ] == new_heap.[ j ])) (decreases length - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.frame_write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment", "Prims.unit", "Prims.squash", "Vale.Interop.write_vale_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec frame_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) (j: int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[ j ] == new_heap.[ j ])) (decreases (length - i)) =
if i >= length then () else (let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i + 1) heap j)
false
Vale.Interop.fst
Vale.Interop.get_seq_heap_as_seq
val get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[ x ] == heap2.[ x ])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b)
val get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[ x ] == heap2.[ x ])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b)
let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 112, "end_line": 355, "start_col": 0, "start_line": 351 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
heap1: Vale.Arch.MachineHeap_s.machine_heap -> heap2: Vale.Arch.MachineHeap_s.machine_heap -> mem: Vale.Interop.Heap_s.interop_heap -> b: Vale.Interop.Types.b8 -> FStar.Pervasives.Lemma (requires Vale.Interop.Heap_s.correct_down_p mem heap1 b /\ (forall (x: Prims.int). x >= Vale.Interop.Heap_s.addrs_of_mem mem b /\ x < Vale.Interop.Heap_s.addrs_of_mem mem b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==> heap1.[ x ] == heap2.[ x ])) (ensures LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem) (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) == Vale.Interop.get_seq_heap heap2 (Vale.Interop.Heap_s.addrs_of_mem mem) b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.Types.b8", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.get_seq_heap", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.unit", "Prims.l_and", "Vale.Interop.Heap_s.correct_down_p", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "LowStar.BufferView.Down.length", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Interop.op_String_Access", "Prims.squash", "FStar.Seq.Properties.lseq", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let get_seq_heap_as_seq (heap1 heap2: machine_heap) (mem: interop_heap) (b: b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[ x ] == heap2.[ x ])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) =
assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
false
Vale.Interop.fst
Vale.Interop.same_unspecified_down
val same_unspecified_down (hs1: HS.mem) (hs2: HS.mem) (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) : Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in forall i. not (valid_addr mem1 i) ==> // REVIEW: the 'forall' lacks a {:pattern ...} heap1.[i] == heap2.[i])
val same_unspecified_down (hs1: HS.mem) (hs2: HS.mem) (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) : Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in forall i. not (valid_addr mem1 i) ==> // REVIEW: the 'forall' lacks a {:pattern ...} heap1.[i] == heap2.[i])
let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 349, "start_col": 0, "start_line": 348 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
hs1: FStar.Monotonic.HyperStack.mem -> hs2: FStar.Monotonic.HyperStack.mem -> ptrs: Prims.list Vale.Interop.Types.b8 { Vale.Interop.Heap_s.list_disjoint_or_eq ptrs /\ Vale.Interop.Heap_s.list_live hs1 ptrs /\ Vale.Interop.Heap_s.list_live hs2 ptrs } -> FStar.Pervasives.Lemma (ensures (let mem1 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs1 in let mem2 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs2 in let addrs = Vale.Interop.Heap_s.addrs_of_mem mem1 in let heap1 = Vale.Interop.down_mem mem1 in let heap2 = Vale.Interop.down_mem mem2 in forall (i: Prims.int). Prims.op_Negation (Vale.Interop.valid_addr mem1 i) ==> heap1.[ i ] == heap2.[ i ]))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.list", "Vale.Interop.Types.b8", "Prims.l_and", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.list_live", "FStar.Classical.forall_intro", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_Negation", "Vale.Interop.valid_addr", "Vale.Interop.Heap_s.mem_of_hs_roots", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Interop.op_String_Access", "Vale.Interop.down_mem", "Vale.Interop.same_unspecified_down_aux", "Prims.unit" ]
[]
false
false
true
false
false
let same_unspecified_down hs1 hs2 ptrs =
Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs)
false
Vale.Interop.fst
Vale.Interop.correct_down_p_cancel
val correct_down_p_cancel (mem: interop_heap) (heap: _) (p: b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p'))
val correct_down_p_cancel (mem: interop_heap) (heap: _) (p: b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p'))
let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 143, "start_col": 0, "start_line": 120 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40"
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> heap: Vale.Arch.MachineHeap_s.machine_heap -> p: Vale.Interop.Types.b8 -> FStar.Pervasives.Lemma (ensures forall (p': Vale.Interop.Types.b8). p == p' ==> (let b = Vale.Interop.Types.get_downview (Buffer?.bsrc p) in let length = LowStar.BufferView.Down.length b in let contents = LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem) b in let addr = Vale.Interop.Heap_s.addrs_of_mem mem p in let new_heap = Vale.Interop.write_vale_mem contents length addr 0 heap in Vale.Interop.Heap_s.correct_down_p mem new_heap p'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Types.b8", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.eq2", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.write_vale_mem", "LowStar.BufferView.Down.as_seq", "FStar.UInt8.t", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "LowStar.BufferView.Down.length", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat64", "FStar.Seq.Properties.lseq", "Prims.nat", "LowStar.BufferView.Down.buffer", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Interop.load_store_write_vale_mem", "Prims.l_Forall" ]
[]
false
false
true
false
false
let correct_down_p_cancel (mem: interop_heap) heap (p: b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) =
let rec aux (p': b8) : Lemma (p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux
false
Vale.Interop.fst
Vale.Interop.addrs_set_mem
val addrs_set_mem (mem:interop_heap) (a:b8) (i:int) : Lemma (requires (let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in List.memP a ptrs /\ i >= addrs a /\ i < addrs a + DV.length (get_downview a.bsrc))) (ensures valid_addr mem i)
val addrs_set_mem (mem:interop_heap) (a:b8) (i:int) : Lemma (requires (let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in List.memP a ptrs /\ i >= addrs a /\ i < addrs a + DV.length (get_downview a.bsrc))) (ensures valid_addr mem i)
let addrs_set_mem mem a i = addrs_set_lemma_all ()
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 203, "start_col": 0, "start_line": 202 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> a: Vale.Interop.Types.b8 -> i: Prims.int -> FStar.Pervasives.Lemma (requires (let ptrs = Vale.Interop.Heap_s.ptrs_of_mem mem in let addrs = Vale.Interop.Heap_s.addrs_of_mem mem in FStar.List.Tot.Base.memP a ptrs /\ i >= addrs a /\ i < addrs a + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc a)))) (ensures Vale.Interop.valid_addr mem i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.Types.b8", "Prims.int", "Vale.Interop.addrs_set_lemma_all", "Prims.unit" ]
[]
true
false
true
false
false
let addrs_set_mem mem a i =
addrs_set_lemma_all ()
false
Vale.Interop.fst
Vale.Interop.up_mem
val up_mem (heap:machine_heap) (mem:interop_heap{Set.equal (addrs_set mem) (Map.domain heap)}) : GTot (new_mem:interop_heap{ptrs_of_mem mem == ptrs_of_mem new_mem /\ correct_down new_mem heap})
val up_mem (heap:machine_heap) (mem:interop_heap{Set.equal (addrs_set mem) (Map.domain heap)}) : GTot (new_mem:interop_heap{ptrs_of_mem mem == ptrs_of_mem new_mem /\ correct_down new_mem heap})
let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 382, "start_col": 0, "start_line": 382 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
heap: Vale.Arch.MachineHeap_s.machine_heap -> mem: Vale.Interop.Heap_s.interop_heap {FStar.Set.equal (Vale.Interop.Heap_s.addrs_set mem) (FStar.Map.domain heap)} -> Prims.GTot (new_mem: Vale.Interop.Heap_s.interop_heap { Vale.Interop.Heap_s.ptrs_of_mem mem == Vale.Interop.Heap_s.ptrs_of_mem new_mem /\ Vale.Interop.Heap_s.correct_down new_mem heap })
Prims.GTot
[ "sometrivial" ]
[]
[ "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.interop_heap", "FStar.Set.equal", "Prims.int", "Vale.Interop.Heap_s.addrs_set", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Vale.Interop.up_mem_aux", "Vale.Interop.Heap_s.ptrs_of_mem", "Prims.Nil", "Vale.Interop.Types.b8", "Prims.l_and", "Prims.eq2", "Prims.list", "Prims.l_or", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.correct_down" ]
[]
false
false
false
false
false
let up_mem heap mem =
up_mem_aux heap (ptrs_of_mem mem) [] mem
false
Vale.Interop.fst
Vale.Interop.addrs_set_lemma_aux
val addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b: b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc))
val addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b: b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc))
let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 194, "start_col": 0, "start_line": 184 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
addrs: Vale.Interop.Types.addr_map -> ptrs: Prims.list Vale.Interop.Types.b8 -> acc: FStar.Set.set Prims.int -> x: Prims.int -> FStar.Pervasives.Lemma (ensures FStar.Set.mem x (FStar.List.Tot.Base.fold_right_gtot ptrs (Vale.Interop.Heap_s.addrs_ptr 0 addrs) acc) <==> (exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). addrs b <= x /\ x < addrs b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))) \/ FStar.Set.mem x acc)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Types.addr_map", "Prims.list", "Vale.Interop.Types.b8", "FStar.Set.set", "Prims.int", "Vale.Interop.addrs_set_lemma_aux", "Prims.unit", "Vale.Interop.addrs_ptr_lemma", "FStar.List.Tot.Base.fold_right_gtot", "Vale.Interop.Heap_s.addrs_ptr", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "FStar.Set.mem", "Prims.l_or", "Prims.l_Exists", "FStar.List.Tot.Base.memP", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec addrs_set_lemma_aux (addrs: addr_map) (ptrs: list b8) (acc: Set.set int) (x: int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b: b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) =
match ptrs with | [] -> () | a :: q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x
false
Vale.Interop.fst
Vale.Interop.up_down_identity_aux
val up_down_identity_aux (mem: interop_heap) (init_heap: machine_heap{correct_down mem init_heap}) (x: int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x)
val up_down_identity_aux (mem: interop_heap) (init_heap: machine_heap{correct_down mem init_heap}) (x: int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x)
let up_down_identity_aux (mem:interop_heap) (init_heap:machine_heap{correct_down mem init_heap}) (x:int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x) = let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in addrs_set_lemma_all (); Classical.forall_intro (Classical.move_requires (correct_down_p_same_sel mem (down_mem mem) init_heap x) )
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 432, "start_col": 0, "start_line": 420 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let down_up_identity mem = let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem // Selecting a buffer index in any corresponding map of bytes always yields the same result let correct_down_p_same_sel (mem:interop_heap) (heap1 heap2:machine_heap) (x:int) (b:b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x) = let addrs = addrs_of_mem mem in let i = x - addrs b in assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)); assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> init_heap: Vale.Arch.MachineHeap_s.machine_heap{Vale.Interop.Heap_s.correct_down mem init_heap} -> x: Prims.int -> FStar.Pervasives.Lemma (requires FStar.Map.contains init_heap x) (ensures FStar.Map.sel init_heap x == FStar.Map.sel (Vale.Interop.down_mem mem) x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "Prims.int", "FStar.Classical.forall_intro", "Vale.Interop.Types.b8", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.op_LessThan", "Prims.op_Addition", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.down_mem", "Prims.eq2", "Vale.Def.Types_s.nat8", "FStar.Map.sel", "FStar.Classical.move_requires", "Vale.Interop.correct_down_p_same_sel", "Prims.unit", "Vale.Interop.addrs_set_lemma_all", "Vale.Interop.Types.addr_map", "Prims.list", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.ptrs_of_mem", "FStar.Map.contains", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let up_down_identity_aux (mem: interop_heap) (init_heap: machine_heap{correct_down mem init_heap}) (x: int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x) =
let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in addrs_set_lemma_all (); Classical.forall_intro (Classical.move_requires (correct_down_p_same_sel mem (down_mem mem) init_heap x))
false
Vale.Interop.fst
Vale.Interop.monotone_domain_write_vale_mem
val monotone_domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))
val monotone_domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))
let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 116, "start_col": 0, "start_line": 101 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> FStar.Pervasives.Lemma (ensures (let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in forall (j: Prims.int). FStar.Set.mem j (FStar.Map.domain curr_heap) ==> FStar.Set.mem j (FStar.Map.domain new_heap))) (decreases length - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.monotone_domain_write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Set.mem", "FStar.Map.domain", "Vale.Interop.write_vale_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec monotone_domain_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i)) =
if i >= length then () else let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i + 1) heap
false
Vale.Interop.fst
Vale.Interop.down_mem
val down_mem: down_mem_t
val down_mem: down_mem_t
let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 293, "start_col": 0, "start_line": 283 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Heap_s.down_mem_t
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Prims.unit", "FStar.Classical.forall_intro", "Prims.int", "Prims.l_iff", "Prims.b2t", "FStar.Set.mem", "Vale.Interop.Heap_s.addrs_set", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat8", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Interop.lemma_down_mem_aux_domain", "Vale.Interop.Types.b8", "Vale.Interop.addrs_set_lemma_all", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_imp", "FStar.List.Tot.Base.memP", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.down_mem_aux", "Prims.list", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.ptrs_of_mem", "FStar.Map.t", "FStar.Map.restrict", "FStar.Set.empty", "FStar.Map.const", "Vale.Interop.Heap_s.correct_down" ]
[]
false
false
false
true
false
let down_mem mem =
let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x: int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f
false
Vale.Interop.fst
Vale.Interop.update_buffer_up_mem
val update_buffer_up_mem (mem:interop_heap) (b:b8{List.memP b (ptrs_of_mem mem)}) (heap1:machine_heap{correct_down mem heap1}) (heap2:machine_heap{Set.equal (Map.domain heap1) (Map.domain heap2)}) : Lemma (requires (forall x.{:pattern heap1.[x] \/ heap2.[x]} x < addrs_of_mem mem b \/ x >= addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures hs_of_mem (up_mem heap2 mem) == DV.upd_seq (hs_of_mem mem) (get_downview b.bsrc) (get_seq_heap heap2 (addrs_of_mem mem) b))
val update_buffer_up_mem (mem:interop_heap) (b:b8{List.memP b (ptrs_of_mem mem)}) (heap1:machine_heap{correct_down mem heap1}) (heap2:machine_heap{Set.equal (Map.domain heap1) (Map.domain heap2)}) : Lemma (requires (forall x.{:pattern heap1.[x] \/ heap2.[x]} x < addrs_of_mem mem b \/ x >= addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures hs_of_mem (up_mem heap2 mem) == DV.upd_seq (hs_of_mem mem) (get_downview b.bsrc) (get_seq_heap heap2 (addrs_of_mem mem) b))
let update_buffer_up_mem m b h1 h2 = let ptrs = ptrs_of_mem m in update_buffer_up_mem_aux h1 h2 ptrs [] b m
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 493, "start_col": 0, "start_line": 491 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let down_up_identity mem = let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem // Selecting a buffer index in any corresponding map of bytes always yields the same result let correct_down_p_same_sel (mem:interop_heap) (heap1 heap2:machine_heap) (x:int) (b:b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x) = let addrs = addrs_of_mem mem in let i = x - addrs b in assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)); assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)) let up_down_identity_aux (mem:interop_heap) (init_heap:machine_heap{correct_down mem init_heap}) (x:int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x) = let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in addrs_set_lemma_all (); Classical.forall_intro (Classical.move_requires (correct_down_p_same_sel mem (down_mem mem) init_heap x) ) let up_down_identity mem heap = let new_heap = down_mem (up_mem heap mem) in same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem); let aux (x:int) : Lemma (requires Map.contains heap x) (ensures Map.sel heap x == Map.sel new_heap x) = up_down_identity_aux (up_mem heap mem) heap x in Classical.forall_intro (Classical.move_requires aux); assert (Map.equal heap new_heap) #reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 1 --initial_fuel 1 --initial_ifuel 1" let rec update_buffer_up_mem_aux (h1 h2:machine_heap) (ps:list b8) (accu:list b8) (b:b8) (m:interop_heap{forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu}) : Lemma (requires List.memP b (ptrs_of_mem m) /\ Set.equal (Map.domain h1) (addrs_set m) /\ Set.equal (Map.domain h2) (addrs_set m) /\ (forall p. List.memP p accu ==> correct_down_p m h2 p) /\ (List.memP b accu ==> DV.as_seq (hs_of_mem m) (get_downview b.bsrc) == get_seq_heap h2 (addrs_of_mem m) b) /\ (forall p. (p =!= b /\ List.memP p (ptrs_of_mem m)) ==> correct_down_p m h1 p) /\ (forall x. x < addrs_of_mem m b \/ x >= addrs_of_mem m b + DV.length (get_downview b.bsrc) ==> h1.[x] == h2.[x]) ) (ensures (List.memP b accu ==> up_mem_aux h2 ps accu m == m) /\ (~(List.memP b accu) ==> hs_of_mem (up_mem_aux h2 ps accu m) == DV.upd_seq (hs_of_mem m) (get_downview b.bsrc) (get_seq_heap h2 (addrs_of_mem m) b))) = match ps with | [] -> () | hd::tl -> let db = get_downview hd.bsrc in let addrs = addrs_of_mem m in let mem = hs_of_mem m in let ptrs = ptrs_of_mem m in let s = get_seq_heap h2 addrs hd in DV.upd_seq_spec mem db s; let m' = DV.upd_seq mem db s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); let aux2 () : Lemma (requires hd =!= b) (ensures DV.as_seq mem db == get_seq_heap h2 addrs hd) = reveal_opaque (`%addr_map_pred) addr_map_pred; get_seq_heap_as_seq h1 h2 m hd in Classical.move_requires aux2 (); update_buffer_up_mem_aux h1 h2 tl (hd::accu) b (InteropHeap ptrs addrs m')
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b (Vale.Interop.Heap_s.ptrs_of_mem mem)} -> heap1: Vale.Arch.MachineHeap_s.machine_heap{Vale.Interop.Heap_s.correct_down mem heap1} -> heap2: Vale.Arch.MachineHeap_s.machine_heap {FStar.Set.equal (FStar.Map.domain heap1) (FStar.Map.domain heap2)} -> FStar.Pervasives.Lemma (requires forall (x: Prims.int). {:pattern heap1.[ x ]\/heap2.[ x ]} x < Vale.Interop.Heap_s.addrs_of_mem mem b \/ x >= Vale.Interop.Heap_s.addrs_of_mem mem b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==> heap1.[ x ] == heap2.[ x ]) (ensures Vale.Interop.Heap_s.hs_of_mem (Vale.Interop.up_mem heap2 mem) == LowStar.BufferView.Down.upd_seq (Vale.Interop.Heap_s.hs_of_mem mem) (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) (Vale.Interop.get_seq_heap heap2 (Vale.Interop.Heap_s.addrs_of_mem mem) b))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.Types.b8", "FStar.List.Tot.Base.memP", "Vale.Interop.Heap_s.ptrs_of_mem", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "FStar.Set.equal", "Prims.int", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Vale.Interop.update_buffer_up_mem_aux", "Prims.Nil", "Prims.list", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Prims.unit" ]
[]
true
false
true
false
false
let update_buffer_up_mem m b h1 h2 =
let ptrs = ptrs_of_mem m in update_buffer_up_mem_aux h1 h2 ptrs [] b m
false
Vale.Interop.fst
Vale.Interop.frame_down_mem_aux
val frame_down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i: int) : Lemma (requires (forall (b: b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ])
val frame_down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i: int) : Lemma (requires (forall (b: b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ])
let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 320, "start_col": 0, "start_line": 296 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} -> mem: Vale.Interop.Heap_s.interop_heap -> ps: Prims.list Vale.Interop.Types.b8 -> accu: Prims.list Vale.Interop.Types.b8 { forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p ptrs <==> FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } -> h: Vale.Arch.MachineHeap_s.machine_heap { forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p accu} FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p } -> i: Prims.int -> FStar.Pervasives.Lemma (requires forall (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ps}). let base = Vale.Interop.Heap_s.addrs_of_mem mem b in i < base \/ i >= base + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))) (ensures h.[ i ] == (Vale.Interop.down_mem_aux ptrs mem ps accu h).[ i ])
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.interop_heap", "Prims.l_Forall", "Prims.l_iff", "FStar.List.Tot.Base.memP", "Prims.l_or", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_imp", "Vale.Interop.Heap_s.correct_down_p", "Prims.int", "Vale.Interop.frame_write_vale_mem", "Prims.unit", "Vale.Interop.frame_down_mem_aux", "Prims.Cons", "Vale.Interop.Heap_s.list_disjoint_or_eq_reveal", "Vale.Interop.correct_down_p_frame", "Vale.Interop.correct_down_p_cancel", "Vale.Interop.load_store_write_vale_mem", "Vale.Def.Words_s.nat64", "Vale.Interop.Heap_s.addrs_of_mem", "FStar.Seq.Properties.lseq", "FStar.UInt8.t", "LowStar.BufferView.Down.length", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Prims.nat", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.write_buffer_vale", "Prims.b2t", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "Prims.squash", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Interop.op_String_Access", "Vale.Interop.down_mem_aux", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec frame_down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i: int) : Lemma (requires (forall (b: b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[ i ] == (down_mem_aux ptrs mem ps accu h).[ i ]) =
match ps with | [] -> () | a :: q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a :: accu) new_heap i; frame_write_vale_mem contents length addr 0 h i
false
Vale.Interop.fst
Vale.Interop.lemma_write_buffer_domain
val lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem)))
val lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem)))
let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 250, "start_col": 0, "start_line": 235 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Interop.Types.b8 -> heap: Vale.Arch.MachineHeap_s.machine_heap -> mem: Vale.Interop.Heap_s.interop_heap -> FStar.Pervasives.Lemma (ensures FStar.Set.equal (FStar.Set.union (FStar.Map.domain heap) (Vale.Interop.Heap_s.addrs_ptr 0 (Vale.Interop.Heap_s.addrs_of_mem mem) a FStar.Set.empty)) (FStar.Map.domain (Vale.Interop.write_buffer_vale a heap mem)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Types.b8", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.monotone_domain_write_vale_mem", "Prims.unit", "FStar.Classical.forall_intro", "Prims.int", "Prims.l_iff", "Prims.b2t", "FStar.Set.mem", "Vale.Interop.Heap_s.addrs_ptr", "Vale.Interop.Heap_s.addrs_of_mem", "FStar.Set.empty", "Prims.l_or", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_LessThan", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.addrs_ptr_lemma", "Vale.Interop.domain2_write_vale_mem", "Vale.Interop.domain_write_vale_mem", "Vale.Def.Words_s.nat64", "FStar.Seq.Properties.lseq", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Prims.nat", "LowStar.BufferView.Down.buffer", "FStar.Set.set", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Vale.Interop.write_buffer_vale", "Prims.l_True", "Prims.squash", "FStar.Set.equal", "FStar.Set.union", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_write_buffer_domain (a: b8) (heap: machine_heap) (mem: interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) =
let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap
false
Vale.Interop.fst
Vale.Interop.down_mem_aux
val down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap: machine_heap {forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p})
val down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap: machine_heap {forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p})
let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 233, "start_col": 0, "start_line": 212 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} -> mem: Vale.Interop.Heap_s.interop_heap -> ps: Prims.list Vale.Interop.Types.b8 -> accu: Prims.list Vale.Interop.Types.b8 { forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p ptrs <==> FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } -> h: Vale.Arch.MachineHeap_s.machine_heap { forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p accu} FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p } -> Prims.GTot (heap: Vale.Arch.MachineHeap_s.machine_heap { forall (p: Vale.Interop.Types.b8). {:pattern FStar.List.Tot.Base.memP p ptrs} FStar.List.Tot.Base.memP p ptrs ==> Vale.Interop.Heap_s.correct_down_p mem heap p })
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.list", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.interop_heap", "Prims.l_Forall", "Prims.l_iff", "FStar.List.Tot.Base.memP", "Prims.l_or", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_imp", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.down_mem_aux", "Prims.Cons", "Prims.unit", "Vale.Interop.Heap_s.list_disjoint_or_eq_reveal", "Vale.Interop.correct_down_p_frame", "Vale.Interop.correct_down_p_cancel", "Vale.Interop.load_store_write_vale_mem", "Vale.Def.Words_s.nat64", "Vale.Interop.Heap_s.addrs_of_mem", "FStar.Seq.Properties.lseq", "FStar.UInt8.t", "LowStar.BufferView.Down.length", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Prims.nat", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.write_buffer_vale" ]
[ "recursion" ]
false
false
false
false
false
let rec down_mem_aux (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap {forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap: machine_heap {forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) =
match ps with | [] -> h | a :: q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a :: accu) new_heap
false
Vale.Interop.fst
Vale.Interop.load_store_write_vale_mem
val load_store_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ] )) (decreases (length - i))
val load_store_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) (addr: _) (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ] )) (decreases (length - i))
let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 64, "start_col": 0, "start_line": 47 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j )
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
contents: FStar.Seq.Base.seq FStar.UInt8.t -> length: Prims.nat{length = FStar.Seq.Base.length contents} -> addr: Prims.int -> i: Prims.nat{i <= length} -> curr_heap: Vale.Arch.MachineHeap_s.machine_heap { forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). {:pattern FStar.Seq.Base.index contents j} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == FStar.UInt8.v (FStar.Seq.Base.index contents j) } -> FStar.Pervasives.Lemma (ensures (let new_heap = Vale.Interop.write_vale_mem contents length addr i curr_heap in forall (j: i: Prims.int{i >= 0 /\ i < FStar.Seq.Base.length contents}). 0 <= j /\ j < length ==> FStar.UInt8.v (FStar.Seq.Base.index contents j) == new_heap.[ addr + j ])) (decreases length - i)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.int", "Prims.op_LessThanOrEqual", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_Forall", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "Prims.op_Addition", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.bool", "Vale.Interop.load_store_write_vale_mem", "FStar.Map.t", "Vale.Def.Words_s.nat8", "Vale.Interop.op_String_Assignment", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.Interop.write_vale_mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec load_store_write_vale_mem (contents: Seq.seq UInt8.t) (length: nat{length = FStar.Seq.Base.length contents}) addr (i: nat{i <= length}) (curr_heap: machine_heap { forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[ addr + j ] == UInt8.v (Seq.index contents j) }) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[ addr + j ] )) (decreases (length - i)) =
if i >= length then () else let heap = curr_heap.[ addr + i ] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i + 1) heap
false
Vale.Interop.fst
Vale.Interop.write_buffer_vale
val write_buffer_vale : a: Vale.Interop.Types.b8 -> heap: Vale.Arch.MachineHeap_s.machine_heap -> mem: Vale.Interop.Heap_s.interop_heap -> Prims.GTot Vale.Arch.MachineHeap_s.machine_heap
let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 210, "start_col": 0, "start_line": 205 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Interop.Types.b8 -> heap: Vale.Arch.MachineHeap_s.machine_heap -> mem: Vale.Interop.Heap_s.interop_heap -> Prims.GTot Vale.Arch.MachineHeap_s.machine_heap
Prims.GTot
[ "sometrivial" ]
[]
[ "Vale.Interop.Types.b8", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.write_vale_mem", "Vale.Def.Words_s.nat64", "Vale.Interop.Heap_s.addrs_of_mem", "FStar.Seq.Properties.lseq", "FStar.UInt8.t", "LowStar.BufferView.Down.length", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Prims.nat", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc" ]
[]
false
false
false
false
false
let write_buffer_vale (a: b8) (heap: machine_heap) (mem: interop_heap) =
let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap
false
Vale.Interop.fst
Vale.Interop.correct_down_p_frame
val correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p'))
val correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p'))
let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 169, "start_col": 0, "start_line": 145 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> heap: Vale.Arch.MachineHeap_s.machine_heap -> p: Vale.Interop.Types.b8 -> FStar.Pervasives.Lemma (ensures forall (p': Vale.Interop.Types.b8). Vale.Interop.disjoint p p' /\ Vale.Interop.Heap_s.correct_down_p mem heap p' ==> (let b = Vale.Interop.Types.get_downview (Buffer?.bsrc p) in let length = LowStar.BufferView.Down.length b in let contents = LowStar.BufferView.Down.as_seq (Vale.Interop.Heap_s.hs_of_mem mem) b in let addr = Vale.Interop.Heap_s.addrs_of_mem mem p in let new_heap = Vale.Interop.write_vale_mem contents length addr 0 heap in Vale.Interop.Heap_s.correct_down_p mem new_heap p'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Types.b8", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_and", "Vale.Interop.disjoint", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.write_vale_mem", "LowStar.BufferView.Down.as_seq", "FStar.UInt8.t", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "LowStar.BufferView.Down.length", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat64", "FStar.Seq.Properties.lseq", "Prims.nat", "LowStar.BufferView.Down.buffer", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Interop.op_String_Access", "FStar.Classical.move_requires", "Vale.Interop.frame_write_vale_mem", "FStar.Pervasives.reveal_opaque", "Prims.logical", "Vale.Interop.Types.addr_map_pred", "Prims.l_Forall" ]
[]
false
false
true
false
false
let correct_down_p_frame (mem: interop_heap) (heap: machine_heap) (p: b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) =
let rec aux (p': b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap) ) in Classical.forall_intro aux
false
Vale.Interop.fst
Vale.Interop.down_up_identity
val down_up_identity (mem:interop_heap) : Lemma (mem == up_mem (down_mem mem) mem)
val down_up_identity (mem:interop_heap) : Lemma (mem == up_mem (down_mem mem) mem)
let down_up_identity mem = let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 404, "start_col": 0, "start_line": 402 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> FStar.Pervasives.Lemma (ensures mem == Vale.Interop.up_mem (Vale.Interop.down_mem mem) mem)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.down_up_identity_aux", "Vale.Interop.Heap_s.ptrs_of_mem", "Prims.Nil", "Vale.Interop.Types.b8", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Interop.Heap_s.correct_down", "Vale.Interop.down_mem", "Prims.unit" ]
[]
true
false
true
false
false
let down_up_identity mem =
let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem
false
Vale.Interop.fst
Vale.Interop.correct_down_p_same_sel
val correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x)
val correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x)
let correct_down_p_same_sel (mem:interop_heap) (heap1 heap2:machine_heap) (x:int) (b:b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x) = let addrs = addrs_of_mem mem in let i = x - addrs b in assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)); assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 97, "end_line": 418, "start_col": 0, "start_line": 407 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let down_up_identity mem = let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> heap1: Vale.Arch.MachineHeap_s.machine_heap -> heap2: Vale.Arch.MachineHeap_s.machine_heap -> x: Prims.int -> b: Vale.Interop.Types.b8 -> FStar.Pervasives.Lemma (requires x >= Vale.Interop.Heap_s.addrs_of_mem mem b /\ x < Vale.Interop.Heap_s.addrs_of_mem mem b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) /\ Vale.Interop.Heap_s.correct_down_p mem heap1 b /\ Vale.Interop.Heap_s.correct_down_p mem heap2 b) (ensures FStar.Map.sel heap1 x == FStar.Map.sel heap2 x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.int", "Vale.Interop.Types.b8", "Prims._assert", "Prims.eq2", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_8", "Vale.Interop.op_String_Access", "Vale.Def.Types_s.nat8", "FStar.UInt8.v", "FStar.Seq.Base.index", "FStar.UInt8.t", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Prims.unit", "Prims.op_Subtraction", "Vale.Interop.Types.addr_map", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.op_Addition", "LowStar.BufferView.Down.length", "Vale.Interop.Heap_s.correct_down_p", "Prims.squash", "FStar.Map.sel", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let correct_down_p_same_sel (mem: interop_heap) (heap1 heap2: machine_heap) (x: int) (b: b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x) =
let addrs = addrs_of_mem mem in let i = x - addrs b in assert (heap1.[ x ] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)); assert (heap2.[ x ] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i))
false
Vale.Interop.fst
Vale.Interop.same_unspecified_down_aux
val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i])
val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i])
let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 346, "start_col": 0, "start_line": 336 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i])
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
hs1: FStar.Monotonic.HyperStack.mem -> hs2: FStar.Monotonic.HyperStack.mem -> ptrs: Prims.list Vale.Interop.Types.b8 { Vale.Interop.Heap_s.list_disjoint_or_eq ptrs /\ Vale.Interop.Heap_s.list_live hs1 ptrs /\ Vale.Interop.Heap_s.list_live hs2 ptrs } -> i: Prims.int -> FStar.Pervasives.Lemma (ensures (let mem1 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs1 in let mem2 = Vale.Interop.Heap_s.mem_of_hs_roots ptrs hs2 in let addrs = Vale.Interop.Heap_s.addrs_of_mem mem1 in let heap1 = Vale.Interop.down_mem mem1 in let heap2 = Vale.Interop.down_mem mem2 in Prims.op_Negation (Vale.Interop.valid_addr mem1 i) ==> heap1.[ i ] == heap2.[ i ]))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.list", "Vale.Interop.Types.b8", "Prims.l_and", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.list_live", "Prims.int", "FStar.Classical.move_requires", "Prims.l_Forall", "FStar.List.Tot.Base.memP", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "LowStar.BufferView.Down.length", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Prims.eq2", "Vale.Def.Types_s.nat8", "Vale.Interop.op_String_Access", "Vale.Interop.down_mem_aux", "Prims.Nil", "Vale.Interop.frame_down_mem_aux", "Prims.unit", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_imp", "Vale.Interop.Heap_s.correct_down_p", "Vale.Interop.Types.addr_map", "Vale.Interop.Heap_s.interop_heap", "Vale.Interop.Heap_s.mem_of_hs_roots", "FStar.Map.t", "Vale.Def.Words_s.nat8", "FStar.Map.restrict", "FStar.Set.empty", "FStar.Map.const", "Vale.Interop.addrs_set_lemma_all" ]
[]
false
false
true
false
false
let same_unspecified_down_aux hs1 hs2 ptrs i =
addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i
false
Vale.Interop.fst
Vale.Interop.up_down_identity
val up_down_identity (mem:interop_heap) (heap:machine_heap{Set.equal (addrs_set mem) (Map.domain heap)}) : Lemma (requires (forall x.{:pattern Map.sel heap x \/ Map.sel (down_mem mem) x} not (Map.contains heap x) ==> Map.sel heap x == Map.sel (down_mem mem) x)) (ensures (down_mem (up_mem heap mem) == heap))
val up_down_identity (mem:interop_heap) (heap:machine_heap{Set.equal (addrs_set mem) (Map.domain heap)}) : Lemma (requires (forall x.{:pattern Map.sel heap x \/ Map.sel (down_mem mem) x} not (Map.contains heap x) ==> Map.sel heap x == Map.sel (down_mem mem) x)) (ensures (down_mem (up_mem heap mem) == heap))
let up_down_identity mem heap = let new_heap = down_mem (up_mem heap mem) in same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem); let aux (x:int) : Lemma (requires Map.contains heap x) (ensures Map.sel heap x == Map.sel new_heap x) = up_down_identity_aux (up_mem heap mem) heap x in Classical.forall_intro (Classical.move_requires aux); assert (Map.equal heap new_heap)
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 442, "start_col": 0, "start_line": 434 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let down_up_identity mem = let heap = down_mem mem in down_up_identity_aux heap (ptrs_of_mem mem) [] mem // Selecting a buffer index in any corresponding map of bytes always yields the same result let correct_down_p_same_sel (mem:interop_heap) (heap1 heap2:machine_heap) (x:int) (b:b8) : Lemma (requires (x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) /\ correct_down_p mem heap1 b /\ correct_down_p mem heap2 b)) (ensures Map.sel heap1 x == Map.sel heap2 x) = let addrs = addrs_of_mem mem in let i = x - addrs b in assert (heap1.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)); assert (heap2.[x] == UInt8.v (Seq.index (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) i)) let up_down_identity_aux (mem:interop_heap) (init_heap:machine_heap{correct_down mem init_heap}) (x:int) : Lemma (requires Map.contains init_heap x) (ensures Map.sel init_heap x == Map.sel (down_mem mem) x) = let ptrs = ptrs_of_mem mem in let addrs = addrs_of_mem mem in addrs_set_lemma_all (); Classical.forall_intro (Classical.move_requires (correct_down_p_same_sel mem (down_mem mem) init_heap x) )
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mem: Vale.Interop.Heap_s.interop_heap -> heap: Vale.Arch.MachineHeap_s.machine_heap {FStar.Set.equal (Vale.Interop.Heap_s.addrs_set mem) (FStar.Map.domain heap)} -> FStar.Pervasives.Lemma (requires forall (x: Prims.int). {:pattern FStar.Map.sel heap x\/FStar.Map.sel (Vale.Interop.down_mem mem) x} Prims.op_Negation (FStar.Map.contains heap x) ==> FStar.Map.sel heap x == FStar.Map.sel (Vale.Interop.down_mem mem) x) (ensures Vale.Interop.down_mem (Vale.Interop.up_mem heap mem) == heap)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Interop.Heap_s.interop_heap", "Vale.Arch.MachineHeap_s.machine_heap", "FStar.Set.equal", "Prims.int", "Vale.Interop.Heap_s.addrs_set", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Prims._assert", "FStar.Map.equal", "Prims.unit", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.b2t", "FStar.Map.contains", "Prims.eq2", "FStar.Map.sel", "FStar.Classical.move_requires", "Vale.Def.Words_s.nat8", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Interop.up_down_identity_aux", "Vale.Interop.up_mem", "Vale.Interop.same_unspecified_down", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Heap_s.ptrs_of_mem", "Vale.Interop.Heap_s.correct_down", "Vale.Interop.down_mem" ]
[]
false
false
true
false
false
let up_down_identity mem heap =
let new_heap = down_mem (up_mem heap mem) in same_unspecified_down (hs_of_mem mem) (hs_of_mem (up_mem heap mem)) (ptrs_of_mem mem); let aux (x: int) : Lemma (requires Map.contains heap x) (ensures Map.sel heap x == Map.sel new_heap x) = up_down_identity_aux (up_mem heap mem) heap x in Classical.forall_intro (Classical.move_requires aux); assert (Map.equal heap new_heap)
false
Vale.Interop.fst
Vale.Interop.down_up_identity_aux
val down_up_identity_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : Lemma (m == up_mem_aux h ps accu m)
val down_up_identity_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : Lemma (m == up_mem_aux h ps accu m)
let rec down_up_identity_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : Lemma (m == up_mem_aux h ps accu m) = match ps with | [] -> () | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); (* The previous assertion and lemma ensure that m == m' *) down_up_identity_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 400, "start_col": 0, "start_line": 384 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b)) let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m') let up_mem heap mem = up_mem_aux heap (ptrs_of_mem mem) [] mem
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: Vale.Arch.MachineHeap_s.machine_heap -> ps: Prims.list Vale.Interop.Types.b8 -> accu: Prims.list Vale.Interop.Types.b8 -> m: Vale.Interop.Heap_s.interop_heap { Vale.Interop.Heap_s.correct_down m h /\ (forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) <==> FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu) } -> FStar.Pervasives.Lemma (ensures m == Vale.Interop.up_mem_aux h ps accu m)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Arch.MachineHeap_s.machine_heap", "Prims.list", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.interop_heap", "Prims.l_and", "Vale.Interop.Heap_s.correct_down", "Prims.l_Forall", "Prims.l_iff", "FStar.List.Tot.Base.memP", "Vale.Interop.Heap_s.ptrs_of_mem", "Prims.l_or", "Vale.Interop.down_up_identity_aux", "Prims.Cons", "Vale.Interop.Heap_s.InteropHeap", "Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs", "Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "LowStar.BufferView.Down.upd_seq_spec", "FStar.Monotonic.HyperStack.mem", "LowStar.BufferView.Down.upd_seq", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "FStar.Seq.Properties.lseq", "LowStar.BufferView.Down.length", "Vale.Interop.get_seq_heap", "Vale.Interop.Heap_s.addrs_of_mem", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.up_mem_aux", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec down_up_identity_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { correct_down m h /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : Lemma (m == up_mem_aux h ps accu m) =
match ps with | [] -> () | hd :: tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in let m' = DV.upd_seq (hs_of_mem m) b s in DV.upd_seq_spec (hs_of_mem m) b s; assert (Seq.equal s (DV.as_seq (hs_of_mem m) b)); down_up_identity_aux h tl (hd :: accu) (InteropHeap m.ptrs m.addrs m')
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.sub_borrow_fallback
val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t
val sub_borrow_fallback: #t:inttype{t = U32 \/ t = U64} -> sub_borrow_st t
let sub_borrow_fallback #t cin x y r = let res = x -. y -. cin in let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in logand_lemma (eq_mask res x) cin; logor_lemma (gt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; r.(0ul) <- res; c
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 97, "start_col": 0, "start_line": 90 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin)) val add_carry_u32: add_carry_st U32 let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c inline_for_extraction noextract let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin)) val sub_borrow_u32: sub_borrow_st U32 let sub_borrow_u32 cin x y r = let res = to_u64 x -. to_u64 y -. to_u64 cin in assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64); Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64); assert (v res == (v x - v y - v cin) % pow2 64); assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32); Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64; assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32); let c = to_u32 (res >>. 32ul) &. u32 1 in assert_norm (pow2 1 = 2); mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul; assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1); assert (v c = v res / pow2 32 % pow2 1); r.(0ul) <- to_u32 res; assert (v c = (if 0 <= v x - v y - v cin then 0 else 1)); c (* Fallback versions of add_carry_u64 and sub_borrow_u64 for platforms which don't support uint128. The names Hacl.IntTypes.Intrinsics.add_carry_u64 and sub_borrow_u64 must not be changed because they are hardcoded in KaRaMeL for extracting wasm code which uses these intrinsics. *) inline_for_extraction noextract val add_carry_fallback: #t:inttype{t = U32 \/ t = U64} -> add_carry_st t let add_carry_fallback #t cin x y r = let res = x +. cin +. y in let c = logand (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in r.(0ul) <- res; logand_lemma (eq_mask res x) cin; logor_lemma (lt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (lt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; c val add_carry_u64: add_carry_st U64 let add_carry_u64 cin x y r = add_carry_fallback #U64 cin x y r inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.IntTypes.Intrinsics.sub_borrow_st t
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Lib.IntTypes.U32", "Lib.IntTypes.U64", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "Prims.unit", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.logand_mask", "Lib.IntTypes.logor", "Lib.IntTypes.gt_mask", "Lib.IntTypes.logand", "Lib.IntTypes.eq_mask", "Lib.IntTypes.uint", "Lib.IntTypes.logor_lemma", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Subtraction_Dot" ]
[]
false
false
false
false
false
let sub_borrow_fallback #t cin x y r =
let res = x -. y -. cin in let c = logand (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) in logand_lemma (eq_mask res x) cin; logor_lemma (gt_mask res x) (logand (eq_mask res x) cin); logand_mask (logor (gt_mask res x) (logand (eq_mask res x) cin)) (uint #t 1) 1; r.(0ul) <- res; c
false
Vale.Interop.fst
Vale.Interop.up_mem_aux
val up_mem_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h})
val up_mem_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h})
let rec up_mem_aux (h:machine_heap) (ps:list b8) (accu:list b8) (m:interop_heap{Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu)}) : GTot (m':interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) = match ps with | [] -> m | hd::tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p:b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc)) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd::accu) (InteropHeap m.ptrs m.addrs m')
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 380, "start_col": 0, "start_line": 357 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x let down_mem mem = (* Dummy heap *) let heap = FStar.Map.const 0 in let heap = Map.restrict Set.empty heap in let ptrs = ptrs_of_mem mem in let heap_f = down_mem_aux ptrs mem ptrs [] heap in let aux (x:int) : Lemma (Set.mem x (addrs_set mem) <==> Set.mem x (Map.domain heap_f)) = addrs_set_lemma_all (); lemma_down_mem_aux_domain ptrs mem ptrs [] heap x in Classical.forall_intro aux; heap_f private let rec frame_down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) (i:int) : Lemma (requires (forall (b:b8{List.memP b ps}). let base = addrs_of_mem mem b in i < base \/ i >= base + DV.length (get_downview b.bsrc))) (ensures h.[i] == (down_mem_aux ptrs mem ps accu h).[i]) = match ps with | [] -> () | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); frame_down_mem_aux ptrs mem q (a::accu) new_heap i; frame_write_vale_mem contents length addr 0 h i val same_unspecified_down_aux: (hs1: HS.mem) -> (hs2: HS.mem) -> (ptrs:list b8{list_disjoint_or_eq ptrs /\ list_live hs1 ptrs /\ list_live hs2 ptrs}) -> (i:int) -> Lemma ( let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heap1 = down_mem mem1 in let heap2 = down_mem mem2 in not (valid_addr mem1 i) ==> heap1.[i] == heap2.[i]) let same_unspecified_down_aux hs1 hs2 ptrs i = addrs_set_lemma_all (); let heap = Map.const 0 in let heap = Map.restrict Set.empty heap in let mem1 = mem_of_hs_roots ptrs hs1 in let mem2 = mem_of_hs_roots ptrs hs2 in let addrs = addrs_of_mem mem1 in let heapf1 = down_mem_aux ptrs mem1 ptrs [] heap in let heapf2 = down_mem_aux ptrs mem2 ptrs [] heap in Classical.move_requires (frame_down_mem_aux ptrs mem1 ptrs [] heap) i; Classical.move_requires (frame_down_mem_aux ptrs mem2 ptrs [] heap) i let same_unspecified_down hs1 hs2 ptrs = Classical.forall_intro (same_unspecified_down_aux hs1 hs2 ptrs) let get_seq_heap_as_seq (heap1 heap2:machine_heap) (mem:interop_heap) (b:b8) : Lemma (requires correct_down_p mem heap1 b /\ (forall x. x >= addrs_of_mem mem b /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc) ==> heap1.[x] == heap2.[x])) (ensures DV.as_seq (hs_of_mem mem) (get_downview b.bsrc) == get_seq_heap heap2 (addrs_of_mem mem) b) = assert (Seq.equal (DV.as_seq (hs_of_mem mem) (get_downview b.bsrc)) (get_seq_heap heap2 (addrs_of_mem mem) b))
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: Vale.Arch.MachineHeap_s.machine_heap -> ps: Prims.list Vale.Interop.Types.b8 -> accu: Prims.list Vale.Interop.Types.b8 -> m: Vale.Interop.Heap_s.interop_heap { FStar.Set.equal (Vale.Interop.Heap_s.addrs_set m) (FStar.Map.domain h) /\ (forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p m h p) /\ (forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p (Vale.Interop.Heap_s.ptrs_of_mem m) <==> FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu) } -> Prims.GTot (m': Vale.Interop.Heap_s.interop_heap { Vale.Interop.Heap_s.ptrs_of_mem m == Vale.Interop.Heap_s.ptrs_of_mem m' /\ Vale.Interop.Heap_s.correct_down m' h })
Prims.GTot
[ "sometrivial" ]
[]
[ "Vale.Arch.MachineHeap_s.machine_heap", "Prims.list", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.interop_heap", "Prims.l_and", "FStar.Set.equal", "Prims.int", "Vale.Interop.Heap_s.addrs_set", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Prims.l_Forall", "Prims.l_imp", "FStar.List.Tot.Base.memP", "Vale.Interop.Heap_s.correct_down_p", "Prims.l_iff", "Vale.Interop.Heap_s.ptrs_of_mem", "Prims.l_or", "Vale.Interop.up_mem_aux", "Prims.Cons", "Vale.Interop.Heap_s.InteropHeap", "Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs", "Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs", "Prims.unit", "Vale.Interop.Heap_s.list_disjoint_or_eq_reveal", "FStar.Classical.forall_intro", "LowStar.Monotonic.Buffer.live", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Heap_s.hs_of_mem", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "Prims.eq2", "FStar.Seq.Properties.lseq", "FStar.UInt8.t", "LowStar.BufferView.Down.length", "Vale.Interop.Types.get_downview", "LowStar.BufferView.Down.as_seq", "FStar.Classical.move_requires", "Vale.Interop.Heap_s.__proj__InteropHeap__item__hs", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Lib.BufferViewHelpers.lemma_dv_equal", "Vale.Interop.Types.down_view", "FStar.Monotonic.HyperStack.mem", "LowStar.BufferView.Down.upd_seq", "LowStar.BufferView.Down.upd_seq_spec", "LowStar.BufferView.Down.buffer", "Vale.Interop.get_seq_heap", "Vale.Interop.Heap_s.addrs_of_mem", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.correct_down" ]
[ "recursion" ]
false
false
false
false
false
let rec up_mem_aux (h: machine_heap) (ps accu: list b8) (m: interop_heap { Set.equal (addrs_set m) (Map.domain h) /\ (forall p. List.memP p accu ==> correct_down_p m h p) /\ (forall p. List.memP p (ptrs_of_mem m) <==> List.memP p ps \/ List.memP p accu) }) : GTot (m': interop_heap{ptrs_of_mem m == ptrs_of_mem m' /\ correct_down m' h}) =
match ps with | [] -> m | hd :: tl -> let s = get_seq_heap h (addrs_of_mem m) hd in let b = get_downview hd.bsrc in DV.upd_seq_spec (hs_of_mem m) b s; let m' = DV.upd_seq (hs_of_mem m) b s in let aux1 (p: b8) : Lemma (requires MB.live (hs_of_mem m) p.bsrc /\ MB.loc_disjoint (MB.loc_buffer p.bsrc) (MB.loc_buffer hd.bsrc)) (ensures DV.as_seq (hs_of_mem m) (get_downview p.bsrc) == DV.as_seq m' (get_downview p.bsrc) ) = lemma_dv_equal (down_view p.src) p.bsrc (hs_of_mem m) m' in Classical.forall_intro (Classical.move_requires aux1); list_disjoint_or_eq_reveal (); up_mem_aux h tl (hd :: accu) (InteropHeap m.ptrs m.addrs m')
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.live4
val live4 : h: FStar.Monotonic.HyperStack.mem -> b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> Prims.logical
let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 16, "start_col": 0, "start_line": 15 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.lbuffer", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Prims.logical" ]
[]
false
false
false
false
true
let live4 #a #len (h: mem) (b0: lbuffer a len) (b1: lbuffer a len) (b2: lbuffer a len) (b3: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3
false
SteelTableJoin.fst
SteelTableJoin.v2
val v2 (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
val v2 (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
let v2 (#p: Ghost.erased nat) (al: ptr) (err: ptr) : STT unit (pts_to1 al p `star` pts_to1 err 0) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = gen_elim () in let _ = join al ar in intro_exists _ (fun v -> pts_to1 al _ `star` pts_to1 err v); intro_exists _ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v)); return ()
{ "file_name": "share/steel/tests/SteelTableJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 35, "start_col": 0, "start_line": 25 }
module SteelTableJoin open Steel.ST.GenElim assume val ptr : Type0 assume val pts_to1 (p: ptr) (v: Ghost.erased nat) : vprop assume val split (#v: Ghost.erased nat) (p: ptr) : STT ptr (pts_to1 p v) (fun res -> exists_ (fun vl -> exists_ (fun vr -> pts_to1 p vl `star` pts_to1 res vr))) assume val join (#opened: _) (#pl #pr: Ghost.erased nat) (al ar: ptr) : STGhostT (Ghost.erased nat) opened (pts_to1 al pl `star` pts_to1 ar pr) (fun res -> pts_to1 al res) assume val v1 (#p: Ghost.erased nat) (a: ptr) (err: ptr) : STT unit (pts_to1 a p `star` pts_to1 err 0) (fun _ -> pts_to1 a p `star` exists_ (fun v -> pts_to1 err v))
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "SteelTableJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
al: SteelTableJoin.ptr -> err: SteelTableJoin.ptr -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "FStar.Ghost.erased", "Prims.nat", "SteelTableJoin.ptr", "Steel.ST.Util.return", "Prims.unit", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "SteelTableJoin.pts_to1", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_exists", "Steel.Effect.Common.star", "FStar.Ghost.reveal", "SteelTableJoin.join", "Steel.ST.GenElim.Base.fstp", "FStar.Pervasives.Native.tuple2", "Steel.ST.GenElim.Base.sndp", "Steel.ST.GenElim.gen_elim", "Prims.l_and", "Prims.l_True", "Prims.prop", "SteelTableJoin.v1", "SteelTableJoin.split" ]
[]
false
true
false
false
false
let v2 (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v)))) =
let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = gen_elim () in let _ = join al ar in intro_exists _ (fun v -> (pts_to1 al _) `star` (pts_to1 err v)); intro_exists _ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))); return ()
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.live8
val live8 : h: FStar.Monotonic.HyperStack.mem -> b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> b4: Lib.Buffer.lbuffer a len -> b5: Lib.Buffer.lbuffer a len -> b6: Lib.Buffer.lbuffer a len -> b7: Lib.Buffer.lbuffer a len -> Prims.logical
let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 102, "end_line": 19, "start_col": 0, "start_line": 18 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> b4: Lib.Buffer.lbuffer a len -> b5: Lib.Buffer.lbuffer a len -> b6: Lib.Buffer.lbuffer a len -> b7: Lib.Buffer.lbuffer a len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.lbuffer", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Prims.logical" ]
[]
false
false
false
false
true
let live8 #a #len (h: mem) (b0: lbuffer a len) (b1: lbuffer a len) (b2: lbuffer a len) (b3: lbuffer a len) (b4: lbuffer a len) (b5: lbuffer a len) (b6: lbuffer a len) (b7: lbuffer a len) =
live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.internally_disjoint4
val internally_disjoint4 : b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> Prims.logical
let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 23, "start_col": 0, "start_line": 21 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Prims.l_and", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Prims.logical" ]
[]
false
false
false
false
true
let internally_disjoint4 #len #a (b0: lbuffer a len) (b1: lbuffer a len) (b2: lbuffer a len) (b3: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.internally_disjoint8
val internally_disjoint8 : b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> b4: Lib.Buffer.lbuffer a len -> b5: Lib.Buffer.lbuffer a len -> b6: Lib.Buffer.lbuffer a len -> b7: Lib.Buffer.lbuffer a len -> Prims.logical
let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 32, "start_col": 0, "start_line": 25 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b0: Lib.Buffer.lbuffer a len -> b1: Lib.Buffer.lbuffer a len -> b2: Lib.Buffer.lbuffer a len -> b3: Lib.Buffer.lbuffer a len -> b4: Lib.Buffer.lbuffer a len -> b5: Lib.Buffer.lbuffer a len -> b6: Lib.Buffer.lbuffer a len -> b7: Lib.Buffer.lbuffer a len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Prims.l_and", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Prims.logical" ]
[]
false
false
false
false
true
let internally_disjoint8 #len #a (b0: lbuffer a len) (b1: lbuffer a len) (b2: lbuffer a len) (b3: lbuffer a len) (b4: lbuffer a len) (b5: lbuffer a len) (b6: lbuffer a len) (b7: lbuffer a len) =
disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.multibuf
val multibuf : lanes: Lib.NTuple.flen -> len: Lib.IntTypes.size_t -> Type0
let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 35, "start_col": 22, "start_line": 34 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lanes: Lib.NTuple.flen -> len: Lib.IntTypes.size_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8" ]
[]
false
false
false
true
true
let multibuf (lanes: flen) (len: size_t) =
ntuple (lbuffer uint8 len) lanes
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.disjoint_multi
val disjoint_multi : b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.Buffer.lbuffer a len' -> Prims.logical
let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b'
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 41, "start_col": 0, "start_line": 40 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.Buffer.lbuffer a len' -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Lib.Buffer.lbuffer", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.NTuple.op_Lens_Access", "Prims.logical" ]
[]
false
false
false
false
true
let disjoint_multi #lanes #len #a #len' (b: multibuf lanes len) (b': lbuffer a len') =
forall i. i < lanes ==> disjoint b.(| i |) b'
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.add_carry_u32
val add_carry_u32: add_carry_st U32
val add_carry_u32: add_carry_st U32
let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 32, "start_col": 0, "start_line": 28 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.IntTypes.Intrinsics.add_carry_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "Prims.unit", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.to_u32", "Lib.IntTypes.U64", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.to_u64" ]
[]
false
false
false
true
false
let add_carry_u32 cin x y r =
let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c
false
EverCrypt.Curve25519.fst
EverCrypt.Curve25519.scalarmult
val scalarmult: shared:lbuffer uint8 32ul -> my_priv:lbuffer uint8 32ul -> their_pub:lbuffer uint8 32ul -> Stack unit (requires fun h0 -> live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\ disjoint shared my_priv /\ disjoint shared their_pub) (ensures fun h0 _ h1 -> modifies (loc shared) h0 h1 /\ as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub))
val scalarmult: shared:lbuffer uint8 32ul -> my_priv:lbuffer uint8 32ul -> their_pub:lbuffer uint8 32ul -> Stack unit (requires fun h0 -> live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\ disjoint shared my_priv /\ disjoint shared their_pub) (ensures fun h0 _ h1 -> modifies (loc shared) h0 h1 /\ as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub))
let scalarmult shared my_priv their_pub = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub
{ "file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 37, "start_col": 0, "start_line": 28 }
module EverCrypt.Curve25519 module B = LowStar.Buffer [@ CInline ] let has_adx_bmi2 (): Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) = let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in has_bmi2 && has_adx #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" let secret_to_public pub priv = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Hacl.Curve25519_64.fsti.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.Pervasives.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
shared: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> my_priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> their_pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Prims.op_AmpAmp", "Hacl.Curve25519_64.scalarmult", "Prims.unit", "Prims.bool", "Hacl.Curve25519_51.scalarmult", "EverCrypt.AutoConfig2.has_adx", "EverCrypt.AutoConfig2.has_bmi2" ]
[]
false
true
false
false
false
let scalarmult shared my_priv their_pub =
if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.modifies_multi
val modifies_multi : b: Lib.MultiBuffer.multibuf lanes len -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) = modifies (loc_multi b) h0 h1
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 74, "start_col": 0, "start_line": 73 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.modifies", "Lib.MultiBuffer.loc_multi" ]
[]
false
false
false
false
true
let modifies_multi #lanes #len (b: multibuf lanes len) (h0: mem) (h1: mem) =
modifies (loc_multi b) h0 h1
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.live_multi
val live_multi : h: FStar.Monotonic.HyperStack.mem -> b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical
let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|)
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 71, "start_col": 0, "start_line": 70 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "FStar.Monotonic.HyperStack.mem", "Lib.MultiBuffer.multibuf", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.NTuple.op_Lens_Access", "Lib.Buffer.lbuffer", "Prims.logical" ]
[]
false
false
false
false
true
let live_multi #lanes #len (h: mem) (b: multibuf lanes len) =
forall i. i < lanes ==> live h b.(| i |)
false
Point.fst
Point.contains_well_typed_refs
val contains_well_typed_refs : h: FStar.DM4F.Heap.heap -> s: Prims.list (FStar.DM4F.Heap.ref Prims.nat) -> Prims.logical
let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 23, "start_col": 8, "start_line": 22 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.DM4F.Heap.heap -> s: Prims.list (FStar.DM4F.Heap.ref Prims.nat) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "Prims.list", "FStar.DM4F.Heap.ref", "Prims.nat", "Prims.l_Forall", "Prims.l_imp", "FStar.List.Tot.Base.memP", "FStar.DM4F.Heap.contains_a_well_typed", "Prims.logical" ]
[]
false
false
false
true
true
let contains_well_typed_refs (h: heap) (s: list (ref nat)) =
forall (r: ref nat). memP r s ==> h `contains_a_well_typed` r
false
Point.fst
Point.live
val live : p: Point.point -> h: FStar.DM4F.Heap.heap -> Type0
let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 43, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Point.point -> h: FStar.DM4F.Heap.heap -> Type0
Prims.Tot
[ "total" ]
[]
[ "Point.point", "FStar.DM4F.Heap.heap", "Point.__proj__C__item__inv", "Point.__proj__C__item__fp" ]
[]
false
false
false
true
true
let live (p: point) (h: heap) =
(C?.inv p) h (C?.fp p)
false
EverCrypt.Curve25519.fst
EverCrypt.Curve25519.secret_to_public
val secret_to_public: pub:lbuffer uint8 32ul -> priv:lbuffer uint8 32ul -> Stack unit (requires fun h0 -> live h0 pub /\ live h0 priv /\ disjoint pub priv) (ensures fun h0 _ h1 -> modifies (loc pub) h0 h1 /\ as_seq h1 pub == Spec.Curve25519.secret_to_public (as_seq h0 priv))
val secret_to_public: pub:lbuffer uint8 32ul -> priv:lbuffer uint8 32ul -> Stack unit (requires fun h0 -> live h0 pub /\ live h0 priv /\ disjoint pub priv) (ensures fun h0 _ h1 -> modifies (loc pub) h0 h1 /\ as_seq h1 pub == Spec.Curve25519.secret_to_public (as_seq h0 priv))
let secret_to_public pub priv = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv
{ "file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 26, "start_col": 0, "start_line": 17 }
module EverCrypt.Curve25519 module B = LowStar.Buffer [@ CInline ] let has_adx_bmi2 (): Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) = let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in has_bmi2 && has_adx
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Hacl.Curve25519_64.fsti.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.Pervasives.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Prims.op_AmpAmp", "Hacl.Curve25519_64.secret_to_public", "Prims.unit", "Prims.bool", "Hacl.Curve25519_51.secret_to_public", "EverCrypt.AutoConfig2.has_adx", "EverCrypt.AutoConfig2.has_bmi2" ]
[]
false
true
false
false
false
let secret_to_public pub priv =
if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv
false
Hacl.IntTypes.Intrinsics.fst
Hacl.IntTypes.Intrinsics.sub_borrow_u32
val sub_borrow_u32: sub_borrow_st U32
val sub_borrow_u32: sub_borrow_st U32
let sub_borrow_u32 cin x y r = let res = to_u64 x -. to_u64 y -. to_u64 cin in assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64); Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64); assert (v res == (v x - v y - v cin) % pow2 64); assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32); Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64; assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32); let c = to_u32 (res >>. 32ul) &. u32 1 in assert_norm (pow2 1 = 2); mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul; assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1); assert (v c = v res / pow2 32 % pow2 1); r.(0ul) <- to_u32 res; assert (v c = (if 0 <= v x - v y - v cin then 0 else 1)); c
{ "file_name": "code/fallback/Hacl.IntTypes.Intrinsics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 66, "start_col": 0, "start_line": 48 }
module Hacl.IntTypes.Intrinsics open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open FStar.Mul #set-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction noextract let add_carry_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r + v c * pow2 (bits t) == v x + v y + v cin)) val add_carry_u32: add_carry_st U32 let add_carry_u32 cin x y r = let res = to_u64 x +. to_u64 cin +. to_u64 y in let c = to_u32 (res >>. 32ul) in r.(0ul) <- to_u32 res; c inline_for_extraction noextract let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) = cin:uint_t t SEC -> x:uint_t t SEC -> y:uint_t t SEC -> r:lbuffer (uint_t t SEC) (size 1) -> Stack (uint_t t SEC) (requires fun h -> live h r /\ v cin <= 1) (ensures fun h0 c h1 -> modifies1 r h0 h1 /\ v c <= 1 /\ (let r = Seq.index (as_seq h1 r) 0 in v r - v c * pow2 (bits t) == v x - v y - v cin))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.IntTypes.Intrinsics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.IntTypes.Intrinsics.sub_borrow_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.v", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.bool", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.to_u32", "Lib.IntTypes.U64", "Prims.op_Modulus", "Prims.op_Division", "Prims.pow2", "Prims.eq2", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.mk_int", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.Pervasives.assert_norm", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u32", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "FStar.Math.Lemmas.lemma_mod_add_distr", "Prims.op_Minus", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.to_u64" ]
[]
false
false
false
true
false
let sub_borrow_u32 cin x y r =
let res = to_u64 x -. to_u64 y -. to_u64 cin in assert (v res == ((v x - v y) % pow2 64 - v cin) % pow2 64); Math.Lemmas.lemma_mod_add_distr (- v cin) (v x - v y) (pow2 64); assert (v res == (v x - v y - v cin) % pow2 64); assert (v res % pow2 32 = (v x - v y - v cin) % pow2 64 % pow2 32); Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x - v y - v cin) 32 64; assert (v res % pow2 32 = (v x - v y - v cin) % pow2 32); let c = to_u32 (res >>. 32ul) &. u32 1 in assert_norm (pow2 1 = 2); mod_mask_lemma (to_u32 (res >>. 32ul)) 1ul; assert (v ((mk_int #U32 #SEC 1 <<. 1ul) -! mk_int 1) == 1); assert (v c = v res / pow2 32 % pow2 1); r.(0ul) <- to_u32 res; assert (v c = (if 0 <= v x - v y - v cin then 0 else 1)); c
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.multiseq
val multiseq : lanes: Lib.NTuple.flen -> len: Prims.nat -> Type0
let multiseq (lanes:flen) (len:nat) = ntuple (Seq.lseq uint8 len) lanes
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 80, "start_col": 0, "start_line": 79 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|) let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) = modifies (loc_multi b) h0 h1 let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) = forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lanes: Lib.NTuple.flen -> len: Prims.nat -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Prims.nat", "Lib.NTuple.ntuple", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8" ]
[]
false
false
false
true
true
let multiseq (lanes: flen) (len: nat) =
ntuple (Seq.lseq uint8 len) lanes
false
Vale.Interop.fst
Vale.Interop.lemma_down_mem_aux_domain
val lemma_down_mem_aux_domain (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap { forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p }) (x: int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
val lemma_down_mem_aux_domain (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap { forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p }) (x: int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)))
let rec lemma_down_mem_aux_domain (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p}) (x:int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b:b8{List.memP b accu}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b:b8{List.memP b ptrs}).{:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc)) ) = match ps with | [] -> () | a::tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a::accu) new_heap x
{ "file_name": "vale/code/arch/x64/Vale.Interop.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 281, "start_col": 0, "start_line": 252 }
module Vale.Interop open FStar.Mul module List = FStar.List.Tot.Base module HS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module MB = LowStar.Monotonic.Buffer module M = LowStar.Modifies module DV = LowStar.BufferView.Down open Vale.Def.Opaque_s //open Vale.Interop.Base open Vale.Lib.BufferViewHelpers #reset-options "--max_fuel 2 --initial_fuel 2 --max_ifuel 1 --initial_ifuel 1" (* Write a buffer in the vale memory *) let rec write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr+j] == UInt8.v (Seq.index contents j)}) : Tot machine_heap (decreases (length - i)) = if i >= length then curr_heap else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in write_vale_mem contents length addr (i+1) heap ) let rec frame_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) (j:int) : Lemma (requires j < addr \/ j >= addr + length) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in curr_heap.[j] == new_heap.[j])) (decreases (length - i))= if i >= length then () else ( let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in frame_write_vale_mem contents length addr (i+1) heap j ) let rec load_store_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. 0 <= j /\ j < length ==> UInt8.v (Seq.index contents j) == new_heap.[addr + j])) (decreases (length - i)) = if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in load_store_write_vale_mem contents length addr (i+1) heap end let rec domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain new_heap) /\ not (Set.mem j (Map.domain curr_heap)) ==> addr <= j /\ j < addr + length)) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain_write_vale_mem contents length addr (i+1) heap end let rec domain2_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires forall j. addr <= j /\ j < addr + i ==> Set.mem j (Map.domain curr_heap)) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. addr <= j /\ j < addr + length ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in domain2_write_vale_mem contents length addr (i+1) heap end let rec monotone_domain_write_vale_mem (contents:Seq.seq UInt8.t) (length:nat{length = FStar.Seq.Base.length contents}) addr (i:nat{i <= length}) (curr_heap:machine_heap{forall j. {:pattern (Seq.index contents j)} 0 <= j /\ j < i ==> curr_heap.[addr + j] == UInt8.v (Seq.index contents j)}) : Lemma (requires True) (ensures (let new_heap = write_vale_mem contents length addr i curr_heap in forall j. Set.mem j (Map.domain curr_heap) ==> Set.mem j (Map.domain new_heap))) (decreases (length - i))= if i >= length then () else begin let heap = curr_heap.[addr + i] <- UInt8.v (FStar.Seq.index contents i) in monotone_domain_write_vale_mem contents length addr (i+1) heap end #set-options "--z3rlimit 40" let correct_down_p_cancel (mem:interop_heap) heap (p:b8) : Lemma (forall p'. p == p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (p == p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in load_store_write_vale_mem contents length addr 0 heap in Classical.forall_intro aux let correct_down_p_frame (mem:interop_heap) (heap:machine_heap) (p:b8) : Lemma (forall p'. disjoint p p' /\ correct_down_p mem heap p' ==> (let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let rec aux (p':b8) : Lemma (disjoint p p' /\ correct_down_p mem heap p' ==> ( let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in correct_down_p mem new_heap p')) = let b = get_downview p.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem p in let new_heap = write_vale_mem contents length addr 0 heap in reveal_opaque (`%addr_map_pred) addr_map_pred; Classical.forall_intro (Classical.move_requires (frame_write_vale_mem contents length addr 0 heap)) in Classical.forall_intro aux let rec addrs_ptr_lemma (i:nat) (addrs:addr_map) (ptr:b8{i <= DV.length (get_downview ptr.bsrc)}) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (addrs_ptr i addrs ptr acc) <==> ((addrs ptr + i <= x /\ x < addrs ptr + DV.length (get_downview ptr.bsrc)) \/ Set.mem x acc)) (decreases (DV.length (get_downview ptr.bsrc) - i)) = if i = DV.length (get_downview ptr.bsrc) then () else addrs_ptr_lemma (i+1) addrs ptr (Set.union (Set.singleton (addrs ptr + i)) acc) x let rec addrs_set_lemma_aux (addrs:addr_map) (ptrs:list b8) (acc:Set.set int) (x:int) : Lemma (requires True) (ensures Set.mem x (List.fold_right_gtot ptrs (addrs_ptr 0 addrs) acc) <==> ((exists (b:b8{List.memP b ptrs}). addrs b <= x /\ x < addrs b + DV.length (get_downview b.bsrc)) \/ Set.mem x acc)) = match ptrs with | [] -> () | a::q -> let acc' = List.fold_right_gtot q (addrs_ptr 0 addrs) acc in addrs_ptr_lemma 0 addrs a acc' x; addrs_set_lemma_aux addrs q acc x let addrs_set_lemma mem x = addrs_set_lemma_aux (addrs_of_mem mem) (ptrs_of_mem mem) Set.empty x let addrs_set_lemma_all () = FStar.Classical.forall_intro_2 addrs_set_lemma let addrs_set_mem mem a i = addrs_set_lemma_all () let write_buffer_vale (a:b8) (heap:machine_heap) (mem:interop_heap) = let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in write_vale_mem contents length addr 0 heap let rec down_mem_aux (ptrs:list b8{list_disjoint_or_eq ptrs}) (mem:interop_heap) (ps:list b8) (accu:list b8{forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h:machine_heap{forall p. {:pattern List.memP p accu} List.memP p accu ==> correct_down_p mem h p}) : GTot (heap:machine_heap{forall p. {:pattern List.memP p ptrs} List.memP p ptrs ==> correct_down_p mem heap p}) = match ps with | [] -> h | a::q -> let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); down_mem_aux ptrs mem q (a::accu) new_heap let lemma_write_buffer_domain (a:b8) (heap:machine_heap) (mem:interop_heap) : Lemma (Set.equal (Set.union (Map.domain heap) (addrs_ptr 0 (addrs_of_mem mem) a Set.empty)) (Map.domain (write_buffer_vale a heap mem))) = let new_heap = write_buffer_vale a heap mem in let s1 = Map.domain heap in let s2 = addrs_ptr 0 (addrs_of_mem mem) a Set.empty in let s3 = Map.domain new_heap in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in domain_write_vale_mem contents length addr 0 heap; domain2_write_vale_mem contents length addr 0 heap; Classical.forall_intro (addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty); monotone_domain_write_vale_mem contents length addr 0 heap
{ "checked_file": "/", "dependencies": [ "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Modifies.fst.checked", "LowStar.BufferView.Down.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Interop.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Heap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Modifies", "short_module": "M" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "Vale", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptrs: Prims.list Vale.Interop.Types.b8 {Vale.Interop.Heap_s.list_disjoint_or_eq ptrs} -> mem: Vale.Interop.Heap_s.interop_heap -> ps: Prims.list Vale.Interop.Types.b8 -> accu: Prims.list Vale.Interop.Types.b8 { forall (p: Vale.Interop.Types.b8). FStar.List.Tot.Base.memP p ptrs <==> FStar.List.Tot.Base.memP p ps \/ FStar.List.Tot.Base.memP p accu } -> h: Vale.Arch.MachineHeap_s.machine_heap { forall (p: Vale.Interop.Types.b8). {:pattern Vale.Interop.Heap_s.correct_down_p mem h p} FStar.List.Tot.Base.memP p accu ==> Vale.Interop.Heap_s.correct_down_p mem h p } -> x: Prims.int -> FStar.Pervasives.Lemma (requires FStar.Set.mem x (FStar.Map.domain h) <==> (exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b accu}). {:pattern Vale.Interop.Heap_s.addrs_of_mem mem b} Vale.Interop.Heap_s.addrs_of_mem mem b <= x /\ x < Vale.Interop.Heap_s.addrs_of_mem mem b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)))) (ensures FStar.Set.mem x (FStar.Map.domain (Vale.Interop.down_mem_aux ptrs mem ps accu h)) <==> (exists (b: Vale.Interop.Types.b8{FStar.List.Tot.Base.memP b ptrs}). {:pattern Vale.Interop.Heap_s.addrs_of_mem mem b} Vale.Interop.Heap_s.addrs_of_mem mem b <= x /\ x < Vale.Interop.Heap_s.addrs_of_mem mem b + LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "Vale.Interop.Types.b8", "Vale.Interop.Heap_s.list_disjoint_or_eq", "Vale.Interop.Heap_s.interop_heap", "Prims.l_Forall", "Prims.l_iff", "FStar.List.Tot.Base.memP", "Prims.l_or", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.l_imp", "Vale.Interop.Heap_s.correct_down_p", "Prims.int", "Vale.Interop.lemma_down_mem_aux_domain", "Prims.Cons", "Prims.unit", "Vale.Interop.Heap_s.list_disjoint_or_eq_reveal", "Vale.Interop.correct_down_p_frame", "Vale.Interop.correct_down_p_cancel", "Vale.Interop.load_store_write_vale_mem", "Vale.Def.Words_s.nat64", "Vale.Interop.Heap_s.addrs_of_mem", "FStar.Seq.Properties.lseq", "FStar.UInt8.t", "LowStar.BufferView.Down.length", "LowStar.BufferView.Down.as_seq", "Vale.Interop.Heap_s.hs_of_mem", "Prims.nat", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Interop.Types.__proj__Buffer__item__src", "Vale.Interop.Types.b8_preorder", "Vale.Interop.Types.__proj__Buffer__item__writeable", "Vale.Interop.Types.base_typ_as_type", "Vale.Interop.Types.__proj__Buffer__item__bsrc", "Vale.Interop.write_buffer_vale", "Vale.Interop.addrs_ptr_lemma", "FStar.Set.empty", "Vale.Interop.lemma_write_buffer_domain", "Prims.b2t", "FStar.Set.mem", "FStar.Map.domain", "Vale.Def.Types_s.nat8", "Prims.l_Exists", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "Prims.squash", "Vale.Interop.down_mem_aux", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_down_mem_aux_domain (ptrs: list b8 {list_disjoint_or_eq ptrs}) (mem: interop_heap) (ps: list b8) (accu: list b8 {forall p. List.memP p ptrs <==> List.memP p ps \/ List.memP p accu}) (h: machine_heap { forall p. {:pattern correct_down_p mem h p} List.memP p accu ==> correct_down_p mem h p }) (x: int) : Lemma (requires Set.mem x (Map.domain h) <==> (exists (b: b8{List.memP b accu}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) (ensures Set.mem x (Map.domain (down_mem_aux ptrs mem ps accu h)) <==> (exists (b: b8{List.memP b ptrs}). {:pattern (addrs_of_mem mem b)} addrs_of_mem mem b <= x /\ x < addrs_of_mem mem b + DV.length (get_downview b.bsrc))) =
match ps with | [] -> () | a :: tl -> lemma_write_buffer_domain a h mem; addrs_ptr_lemma 0 (addrs_of_mem mem) a Set.empty x; let new_heap = write_buffer_vale a h mem in let b = get_downview a.bsrc in let length = DV.length b in let contents = DV.as_seq (hs_of_mem mem) b in let addr = addrs_of_mem mem a in load_store_write_vale_mem contents length addr 0 h; correct_down_p_cancel mem h a; correct_down_p_frame mem h a; list_disjoint_or_eq_reveal (); lemma_down_mem_aux_domain ptrs mem tl (a :: accu) new_heap x
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.internally_disjoint
val internally_disjoint : b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical
let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|)
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 38, "start_col": 0, "start_line": 37 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_disEquality", "Prims.l_or", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.NTuple.op_Lens_Access", "Lib.Buffer.lbuffer", "Prims.logical" ]
[]
false
false
false
false
true
let internally_disjoint #lanes #len (b: multibuf lanes len) =
forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(| i |) b.(| j |)
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.op_Lens_Access
val op_Lens_Access : s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> a
let op_Lens_Access #a #len = index #a #len
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 91, "start_col": 7, "start_line": 91 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|) let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) = modifies (loc_multi b) h0 h1 let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) = forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s let multiseq (lanes:flen) (len:nat) = ntuple (Seq.lseq uint8 len) lanes let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) = gmap (as_seq h) b let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}): Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|)) [SMTPat (as_seq_multi #lanes #len h b).(|i|)] = index_gmap_lemma (as_seq h) b i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> a
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.NTuple.index", "Lib.NTuple.ntuple", "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let ( .(||) ) #a #len =
index #a #len
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.op_Lens_Assignment
val op_Lens_Assignment : s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> x: a -> Lib.NTuple.ntuple a len
let op_Lens_Assignment #a #len = upd #a #len
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 92, "start_col": 7, "start_line": 92 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|) let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) = modifies (loc_multi b) h0 h1 let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) = forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s let multiseq (lanes:flen) (len:nat) = ntuple (Seq.lseq uint8 len) lanes let as_seq_multi #lanes #len (h:mem) (b:multibuf lanes len) : GTot (multiseq lanes (v len)) = gmap (as_seq h) b let as_seq_multi_lemma (#lanes:flen) #len h b (i:nat{i < lanes}): Lemma ((as_seq_multi #lanes #len h b).(|i|) == as_seq h b.(|i|)) [SMTPat (as_seq_multi #lanes #len h b).(|i|)] = index_gmap_lemma (as_seq h) b i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Lib.NTuple.ntuple a len -> i: Prims.nat{i < len} -> x: a -> Lib.NTuple.ntuple a len
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.NTuple.upd", "Lib.NTuple.ntuple", "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let ( .(||)<- ) #a #len =
upd #a #len
false
Point.fst
Point.move
val move (p: point) : ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1)
val move (p: point) : ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1)
let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 50, "start_col": 1, "start_line": 45 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Point.point -> FStar.DM4F.Heap.ST.ST Prims.unit
FStar.DM4F.Heap.ST.ST
[]
[]
[ "Point.point", "FStar.DM4F.Heap.heap", "Point.fp", "Point.point_t", "Point.move_t", "Point.get_t", "Prims.unit", "Point.live" ]
[]
false
true
false
false
false
let move (p: point) : ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) =
match p with | C _ fp f -> let m, _ = f in m fp
false
Point.fst
Point.get
val get (p: point) : ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1)
val get (p: point) : ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1)
let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 57, "start_col": 1, "start_line": 52 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Point.point -> FStar.DM4F.Heap.ST.ST (Prims.nat * Prims.nat)
FStar.DM4F.Heap.ST.ST
[]
[]
[ "Point.point", "FStar.DM4F.Heap.heap", "Point.fp", "Point.point_t", "Point.move_t", "Point.get_t", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Point.live" ]
[]
false
true
false
false
false
let get (p: point) : ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) =
match p with | C _ fp f -> let _, g = f in g fp
false
BinarySearchTreeFirst.fst
BinarySearchTreeFirst.max
val max : i: Prims.int -> j: Prims.int -> Prims.int
let max i j = if i < j then j else i
{ "file_name": "examples/data_structures/BinarySearchTreeFirst.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 43, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* Exercising: -- indexed types -- implicit value parameters -- dependent tuples -- and refinements, of course *) module BinarySearchTreeFirst open FStar.List.Tot (* The type of a binary tree indexed by its max element *) type tree (r:int) = | Node : #l :int -> left :option (tree l) -> n :int -> right:option (tree r){l <= n /\ n <= r /\ (None? right == (n=r)) /\ (None? left == (n=l))} -> tree r (* Need to supply #i for the empty sub-trees, since it can't be inferred by unification *) let leaf i : tree i = Node #i #i None i None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "BinarySearchTreeFirst.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.int -> j: Prims.int -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_LessThan", "Prims.bool" ]
[]
false
false
false
true
false
let max i j =
if i < j then j else i
false
Steel.MonotonicHigherReference.fsti
Steel.MonotonicHigherReference.pts_to
val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop
val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop
let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop = to_vprop (pts_to_sl r f v)
{ "file_name": "lib/steel/Steel.MonotonicHigherReference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 43, "start_col": 7, "start_line": 42 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.MonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.MonotonicHigherReference.fsti" }
[ { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.MonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: FStar.Ghost.erased a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "Steel.MonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "Steel.Effect.Common.to_vprop", "Steel.MonotonicHigherReference.pts_to_sl", "Steel.Effect.Common.vprop" ]
[]
false
false
false
false
false
let pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: erased a) : vprop =
to_vprop (pts_to_sl r f v)
false
EverCrypt.Curve25519.fst
EverCrypt.Curve25519.ecdh
val ecdh: shared:lbuffer uint8 32ul -> my_priv:lbuffer uint8 32ul -> their_pub:lbuffer uint8 32ul -> Stack bool (requires fun h0 -> live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\ disjoint shared my_priv /\ disjoint shared their_pub) (ensures fun h0 r h1 -> modifies (loc shared) h0 h1 /\ as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub) /\ (not r == Lib.ByteSequence.lbytes_eq #32 (as_seq h1 shared) (Lib.Sequence.create 32 (u8 0))))
val ecdh: shared:lbuffer uint8 32ul -> my_priv:lbuffer uint8 32ul -> their_pub:lbuffer uint8 32ul -> Stack bool (requires fun h0 -> live h0 shared /\ live h0 my_priv /\ live h0 their_pub /\ disjoint shared my_priv /\ disjoint shared their_pub) (ensures fun h0 r h1 -> modifies (loc shared) h0 h1 /\ as_seq h1 shared == Spec.Curve25519.scalarmult (as_seq h0 my_priv) (as_seq h0 their_pub) /\ (not r == Lib.ByteSequence.lbytes_eq #32 (as_seq h1 shared) (Lib.Sequence.create 32 (u8 0))))
let ecdh shared my_priv their_pub = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.ecdh shared my_priv their_pub else Hacl.Curve25519_51.ecdh shared my_priv their_pub else Hacl.Curve25519_51.ecdh shared my_priv their_pub
{ "file_name": "providers/evercrypt/fst/EverCrypt.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 48, "start_col": 0, "start_line": 39 }
module EverCrypt.Curve25519 module B = LowStar.Buffer [@ CInline ] let has_adx_bmi2 (): Stack bool (fun _ -> True) (ensures (fun h0 b h1 -> B.(modifies B.loc_none h0 h1) /\ (b ==> Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)))) = let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in has_bmi2 && has_adx #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" let secret_to_public pub priv = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv else Hacl.Curve25519_51.secret_to_public pub priv let scalarmult shared my_priv their_pub = if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub else Hacl.Curve25519_51.scalarmult shared my_priv their_pub
{ "checked_file": "/", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Hacl.Curve25519_64.fsti.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.Pervasives.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
shared: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> my_priv: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> their_pub: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Prims.op_AmpAmp", "Hacl.Curve25519_64.ecdh", "Prims.bool", "Hacl.Curve25519_51.ecdh", "EverCrypt.AutoConfig2.has_adx", "EverCrypt.AutoConfig2.has_bmi2" ]
[]
false
true
false
false
false
let ecdh shared my_priv their_pub =
if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_bmi2 = EverCrypt.AutoConfig2.has_bmi2 () in let has_adx = EverCrypt.AutoConfig2.has_adx () in if (has_bmi2 && has_adx) then Hacl.Curve25519_64.ecdh shared my_priv their_pub else Hacl.Curve25519_51.ecdh shared my_priv their_pub else Hacl.Curve25519_51.ecdh shared my_priv their_pub
false
Point.fst
Point.equal_heaps_except_fp
val equal_heaps_except_fp : h0: FStar.DM4F.Heap.heap -> h1: FStar.DM4F.Heap.heap -> s: Point.fp -> Prims.logical
let equal_heaps_except_fp (h0:heap) (h1:heap) (s:fp) = forall (a:Type) (r:ref a). ref_not_in_fp r s ==> sel h0 r == sel h1 r
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 118, "start_col": 8, "start_line": 117 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *) private let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y) private let move_point :(move_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1) let init_point () :ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) = let r1 = alloc 1 in let r2 = alloc 1 in C inv_point [r1; r2] (move_point, get_point) private let inv_colored_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ length fp = 3 /\ (let r1 = hd fp in let r2 = hd (tl fp) in let r3 = hd (tl (tl fp)) in addr_of r1 <> addr_of r2 /\ addr_of r2 <> addr_of r3 /\ addr_of r3 <> addr_of r1) private let move_colored_point :(move_t inv_colored_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1) private let get_colored_point :(get_t inv_colored_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y) let init_colored_point (): ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) = let r_1 = alloc 1 in let r_2 = alloc 1 in let r_3 = alloc 1 in C inv_colored_point [r_1; r_2; r_3] (move_colored_point, get_colored_point) private let ref_not_in_fp (#a:Type) (r:ref a) (s:fp) = forall (r':ref nat). memP r' s ==> addr_of r' <> addr_of r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h0: FStar.DM4F.Heap.heap -> h1: FStar.DM4F.Heap.heap -> s: Point.fp -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "Point.fp", "Prims.l_Forall", "FStar.DM4F.Heap.ref", "Prims.l_imp", "Point.ref_not_in_fp", "Prims.eq2", "FStar.DM4F.Heap.sel", "Prims.logical" ]
[]
false
false
false
true
true
let equal_heaps_except_fp (h0 h1: heap) (s: fp) =
forall (a: Type) (r: ref a). ref_not_in_fp r s ==> sel h0 r == sel h1 r
false
Point.fst
Point.get_point
val get_point:(get_t inv_point)
val get_point:(get_t inv_point)
let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 71, "start_col": 9, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Point.get_t Point.inv_point
Prims.Tot
[ "total" ]
[]
[ "Point.fp", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.Heap.ST.read_weak", "FStar.DM4F.Heap.ref", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl" ]
[]
false
false
false
true
false
let get_point:(get_t inv_point) =
fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y)
false
Point.fst
Point.move_point
val move_point:(move_t inv_point)
val move_point:(move_t inv_point)
let move_point :(move_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 80, "start_col": 9, "start_line": 73 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *) private let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Point.move_t Point.inv_point
Prims.Tot
[ "total" ]
[]
[ "Point.fp", "FStar.DM4F.Heap.ST.write_weak", "Prims.nat", "Prims.op_Addition", "Prims.unit", "FStar.DM4F.Heap.ST.read_weak", "FStar.DM4F.Heap.ref", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl" ]
[]
false
false
false
true
false
let move_point:(move_t inv_point) =
fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
false
Steel.MonotonicHigherReference.fsti
Steel.MonotonicHigherReference.property
val property : a: Type -> Type
let property (a:Type) = a -> prop
{ "file_name": "lib/steel/Steel.MonotonicHigherReference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 67, "start_col": 0, "start_line": 66 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.MonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector [@@ __steel_reduce__] unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop = to_vprop (pts_to_sl r f v) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc (#a:Type) (p:Preorder.preorder a) (v:a) : SteelT (ref a p) emp (fun r -> pts_to r full_perm v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine (#a:Type) (#q:perm) (#p:Preorder.preorder a) (#frame:a -> vprop) (r:ref a p) : SteelT a (h_exists (fun (v:a) -> pts_to r q v `star` frame v)) (fun v -> pts_to r q v `star` frame v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a) (r:ref a p) (x:a) : Steel unit (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.MonotonicHigherReference.fsti" }
[ { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.prop" ]
[]
false
false
false
true
true
let property (a: Type) =
a -> prop
false
Point.fst
Point.init_point
val init_point: Prims.unit -> ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1))
val init_point: Prims.unit -> ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1))
let init_point () :ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) = let r1 = alloc 1 in let r2 = alloc 1 in C inv_point [r1; r2] (move_point, get_point)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 85, "start_col": 1, "start_line": 82 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *) private let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y) private let move_point :(move_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.DM4F.Heap.ST.ST Point.point
FStar.DM4F.Heap.ST.ST
[]
[]
[ "Prims.unit", "Point.C", "Point.inv_point", "Prims.Cons", "FStar.DM4F.Heap.ref", "Prims.nat", "Prims.Nil", "FStar.Pervasives.Native.Mktuple2", "Point.move_t", "Point.get_t", "Point.move_point", "Point.get_point", "Point.point", "FStar.DM4F.Heap.ST.alloc", "FStar.DM4F.Heap.heap", "Prims.l_True", "Point.live" ]
[]
false
true
false
false
false
let init_point () : ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) =
let r1 = alloc 1 in let r2 = alloc 1 in C inv_point [r1; r2] (move_point, get_point)
false
Point.fst
Point.inv_point
val inv_point (h: heap) (fp: fp) : Type0
val inv_point (h: heap) (fp: fp) : Type0
let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp))
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 61, "start_col": 8, "start_line": 59 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.DM4F.Heap.heap -> fp: Point.fp -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "Point.fp", "Prims.l_and", "Point.contains_well_typed_refs", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.DM4F.Heap.ref", "Prims.nat", "Prims.op_disEquality", "FStar.DM4F.Heap.addr_of", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl" ]
[]
false
false
false
true
true
let inv_point (h: heap) (fp: fp) : Type0 =
h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp))
false
Steel.MonotonicHigherReference.fsti
Steel.MonotonicHigherReference.stable_property
val stable_property : p: FStar.Preorder.preorder a -> Type
let stable_property (#a:Type) (p:Preorder.preorder a) = fact:property a { Preorder.stable fact p }
{ "file_name": "lib/steel/Steel.MonotonicHigherReference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 77, "start_col": 0, "start_line": 76 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.MonotonicHigherReference open FStar.PCM open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Preorder = FStar.Preorder /// A library for Steel references that are monotonic with respect to a user-specified preorder. /// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1. /// An abstract datatype for monotonic references val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 /// The standard points to separation logic predicate val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector [@@ __steel_reduce__] unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:erased a) : vprop = to_vprop (pts_to_sl r f v) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc (#a:Type) (p:Preorder.preorder a) (v:a) : SteelT (ref a p) emp (fun r -> pts_to r full_perm v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine (#a:Type) (#q:perm) (#p:Preorder.preorder a) (#frame:a -> vprop) (r:ref a p) : SteelT a (h_exists (fun (v:a) -> pts_to r q v `star` frame v)) (fun v -> pts_to r q v `star` frame v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write (#a:Type) (#p:Preorder.preorder a) (#v:erased a) (r:ref a p) (x:a) : Steel unit (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True) /// A wrapper around a predicate that depends on a value of type [a] let property (a:Type) = a -> prop /// A wrapper around a property [fact] that has been witnessed to be true and stable /// with respect to preorder [p] val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a) : Type0 /// The type of properties depending on values of type [a], and that
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.MonotonicHigherReference.fsti" }
[ { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.Preorder.preorder a -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "Steel.MonotonicHigherReference.property", "FStar.Preorder.stable" ]
[]
false
false
false
true
true
let stable_property (#a: Type) (p: Preorder.preorder a) =
fact: property a {Preorder.stable fact p}
false
BinarySearchTreeFirst.fst
BinarySearchTreeFirst.leaf
val leaf (i: _) : tree i
val leaf (i: _) : tree i
let leaf i : tree i = Node #i #i None i None
{ "file_name": "examples/data_structures/BinarySearchTreeFirst.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 41, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* Exercising: -- indexed types -- implicit value parameters -- dependent tuples -- and refinements, of course *) module BinarySearchTreeFirst open FStar.List.Tot (* The type of a binary tree indexed by its max element *) type tree (r:int) = | Node : #l :int -> left :option (tree l) -> n :int -> right:option (tree r){l <= n /\ n <= r /\ (None? right == (n=r)) /\ (None? left == (n=l))} -> tree r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "BinarySearchTreeFirst.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.int -> BinarySearchTreeFirst.tree i
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "BinarySearchTreeFirst.Node", "FStar.Pervasives.Native.None", "BinarySearchTreeFirst.tree" ]
[]
false
false
false
false
false
let leaf i : tree i =
Node #i #i None i None
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.loc_multi_
val loc_multi_ (#lanes: flen) (#len: _) (i: nat{i < lanes}) (b: multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i))
val loc_multi_ (#lanes: flen) (#len: _) (i: nat{i < lanes}) (b: multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i))
let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 47, "start_col": 0, "start_line": 44 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat{i < lanes} -> b: Lib.MultiBuffer.multibuf lanes len -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial", "" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.MultiBuffer.multibuf", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.NTuple.op_Lens_Access", "Lib.Buffer.lbuffer", "Prims.bool", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.MultiBuffer.loc_multi_", "Prims.op_Addition", "LowStar.Monotonic.Buffer.loc" ]
[ "recursion" ]
false
false
false
false
false
let rec loc_multi_ (#lanes: flen) #len (i: nat{i < lanes}) (b: multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) =
if i = lanes - 1 then loc (b.(| i |)) else loc b.(| i |) |+| loc_multi_ (i + 1) b
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.loc_multi
val loc_multi : b: Lib.MultiBuffer.multibuf lanes len -> Prims.GTot LowStar.Monotonic.Buffer.loc
let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b)
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 49, "start_col": 0, "start_line": 49 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "FStar.Pervasives.normalize_term", "LowStar.Monotonic.Buffer.loc", "Lib.MultiBuffer.loc_multi_" ]
[]
false
false
false
false
false
let loc_multi #lanes #len b =
normalize_term (loc_multi_ #lanes #len 0 b)
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.stack_allocated_multi
val stack_allocated_multi : b: Lib.MultiBuffer.multibuf lanes len -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> s: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.v len) -> Prims.logical
let stack_allocated_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) (s:lseq uint8 (v len)) = forall i. i < lanes ==> stack_allocated b.(|i|) h0 h1 s
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 77, "start_col": 0, "start_line": 76 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|) let live_multi #lanes #len (h:mem) (b:multibuf lanes len) = forall i. i < lanes ==> live h b.(|i|) let modifies_multi #lanes #len (b:multibuf lanes len) (h0:mem) (h1:mem) = modifies (loc_multi b) h0 h1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> s: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.v len) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "FStar.Monotonic.HyperStack.mem", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Lib.Buffer.stack_allocated", "Lib.NTuple.op_Lens_Access", "Lib.Buffer.lbuffer", "Prims.logical" ]
[]
false
false
false
false
true
let stack_allocated_multi #lanes #len (b: multibuf lanes len) (h0: mem) (h1: mem) (s: lseq uint8 (v len)) =
forall i. i < lanes ==> stack_allocated b.(| i |) h0 h1 s
false
BinarySearchTreeFirst.fst
BinarySearchTreeFirst.insert
val insert: #k:int -> t:tree k -> i:int -> Tot (tree (max k i)) (decreases t)
val insert: #k:int -> t:tree k -> i:int -> Tot (tree (max k i)) (decreases t)
let rec insert (#k:int) (Node left n right) i = if i = n then Node left n right (* no duplicates *) else if i < n then match left with | None -> Node (Some (leaf i)) n right | Some left -> Node (Some (insert left i)) n right else match right with | None -> Node left n (Some (leaf i)) | Some right -> Node left n (Some (insert right i))
{ "file_name": "examples/data_structures/BinarySearchTreeFirst.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 59, "start_col": 0, "start_line": 46 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* Exercising: -- indexed types -- implicit value parameters -- dependent tuples -- and refinements, of course *) module BinarySearchTreeFirst open FStar.List.Tot (* The type of a binary tree indexed by its max element *) type tree (r:int) = | Node : #l :int -> left :option (tree l) -> n :int -> right:option (tree r){l <= n /\ n <= r /\ (None? right == (n=r)) /\ (None? left == (n=l))} -> tree r (* Need to supply #i for the empty sub-trees, since it can't be inferred by unification *) let leaf i : tree i = Node #i #i None i None let max i j = if i < j then j else i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "BinarySearchTreeFirst.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeFirst.tree k -> i: Prims.int -> Prims.Tot (BinarySearchTreeFirst.tree (BinarySearchTreeFirst.max k i))
Prims.Tot
[ "total", "" ]
[]
[ "Prims.int", "BinarySearchTreeFirst.tree", "FStar.Pervasives.Native.option", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.bool", "FStar.Pervasives.Native.uu___is_None", "Prims.op_Equality", "BinarySearchTreeFirst.Node", "Prims.op_LessThan", "FStar.Pervasives.Native.Some", "BinarySearchTreeFirst.leaf", "BinarySearchTreeFirst.max", "BinarySearchTreeFirst.insert" ]
[ "recursion" ]
false
false
false
false
false
let rec insert (#k: int) (Node left n right) i =
if i = n then Node left n right else if i < n then match left with | None -> Node (Some (leaf i)) n right | Some left -> Node (Some (insert left i)) n right else match right with | None -> Node left n (Some (leaf i)) | Some right -> Node left n (Some (insert right i))
false
BinarySearchTreeFirst.fst
BinarySearchTreeFirst.ins
val ins : lt:t -> n:int -> Tot t
val ins : lt:t -> n:int -> Tot t
let ins (| m, tt |) n = (| max m n, insert tt n |)
{ "file_name": "examples/data_structures/BinarySearchTreeFirst.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 114, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* Exercising: -- indexed types -- implicit value parameters -- dependent tuples -- and refinements, of course *) module BinarySearchTreeFirst open FStar.List.Tot (* The type of a binary tree indexed by its max element *) type tree (r:int) = | Node : #l :int -> left :option (tree l) -> n :int -> right:option (tree r){l <= n /\ n <= r /\ (None? right == (n=r)) /\ (None? left == (n=l))} -> tree r (* Need to supply #i for the empty sub-trees, since it can't be inferred by unification *) let leaf i : tree i = Node #i #i None i None let max i j = if i < j then j else i val insert: #k:int -> t:tree k -> i:int -> Tot (tree (max k i)) (decreases t) let rec insert (#k:int) (Node left n right) i = if i = n then Node left n right (* no duplicates *) else if i < n then match left with | None -> Node (Some (leaf i)) n right | Some left -> Node (Some (insert left i)) n right else match right with | None -> Node left n (Some (leaf i)) | Some right -> Node left n (Some (insert right i)) val contains: #k:int -> t:tree k -> key:int -> Tot bool (decreases t) let rec contains (#k:int) t key = if key > k then false else let Node left i right = t in i=k || (key < i && Some? left && contains (Some?.v left) key) || (Some? right && contains (Some?.v right) key) val in_order_opt: #k:int -> t:option (tree k) -> Tot (list int) (decreases t) let rec in_order_opt (#k:int) t = match t with | None -> [] | Some (Node left i right) -> in_order_opt left@[i]@in_order_opt right val index_is_max : #max:int -> t:option (tree max) -> x:int -> Lemma (ensures (List.Tot.mem x (in_order_opt t) ==> x <= max)) (decreases t) let rec index_is_max (#max:int) t x = admit() (* CH: 2016-07-28 This started failing recently with: ./BinarySearchTreeFirst.fst(91,23-91,24): Subtyping check failed; expected type (x#105346:Prims.int{(Prims.precedes (Prims.LexCons left Prims.LexTop) (Prims.LexCons t Prims.LexTop))}); got type Prims.int CH: this is very strange since it is reported on x, which has no decreases clause match t with | None -> () | Some (Node left i right) -> List.Tot.append_mem (in_order_opt left @ [i]) (in_order_opt right) x; List.Tot.append_mem (in_order_opt left) [i] x; index_is_max left x; index_is_max right x *) val index_is_max2 : #max:int -> t:option (tree max) -> x:int -> Lemma (ensures (List.Tot.mem x (in_order_opt t) ==> x <= max)) (decreases t) let rec index_is_max2 (#max:int) t x = admit() (* CH: 2016-07-28 This started failing recently match t with | None -> () | Some (Node #l left i #r right) -> (* You can also writing the implicit arguments explicitly ... just testing it *) List.Tot.append_mem (in_order_opt #l left @ [i]) (in_order_opt #r right) x; List.Tot.append_mem (in_order_opt #l left) [i] x; index_is_max2 #l left x; index_is_max2 #r right x *) type t = (l:int & tree l)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "BinarySearchTreeFirst.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lt: BinarySearchTreeFirst.t -> n: Prims.int -> BinarySearchTreeFirst.t
Prims.Tot
[ "total" ]
[]
[ "BinarySearchTreeFirst.t", "Prims.int", "BinarySearchTreeFirst.tree", "Prims.Mkdtuple2", "BinarySearchTreeFirst.max", "BinarySearchTreeFirst.insert" ]
[]
false
false
false
true
false
let ins (| m , tt |) n =
(| max m n, insert tt n |)
false
Lib.MultiBuffer.fst
Lib.MultiBuffer.disjoint_multi_multi
val disjoint_multi_multi : b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
let disjoint_multi_multi #lanes #len #len' (b:multibuf lanes len) (b':multibuf lanes len') = forall i. i < lanes ==> disjoint b.(|i|) b'.(|i|)
{ "file_name": "lib/Lib.MultiBuffer.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 68, "start_col": 0, "start_line": 67 }
module Lib.MultiBuffer open FStar.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.NTuple #set-options "--z3rlimit 30 --fuel 0 --ifuel 0" let live4 #a #len (h:mem) (b0 b1 b2 b3: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 let live8 #a #len (h:mem) (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = live h b0 /\ live h b1 /\ live h b2 /\ live h b3 /\ live h b4 /\ live h b5 /\ live h b6 /\ live h b7 let internally_disjoint4 #len #a (b0 b1 b2 b3: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 let internally_disjoint8 #len #a (b0 b1 b2 b3 b4 b5 b6 b7: lbuffer a len) = disjoint b0 b1 /\ disjoint b0 b2 /\ disjoint b0 b3 /\ disjoint b0 b4 /\ disjoint b0 b5 /\ disjoint b0 b6 /\ disjoint b0 b7 /\ disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b1 b4 /\ disjoint b1 b5 /\ disjoint b1 b6 /\ disjoint b1 b7 /\ disjoint b2 b3 /\ disjoint b2 b4 /\ disjoint b2 b5 /\ disjoint b2 b6 /\ disjoint b2 b7 /\ disjoint b3 b4 /\ disjoint b3 b5 /\ disjoint b3 b6 /\ disjoint b3 b7 /\ disjoint b4 b5 /\ disjoint b4 b6 /\ disjoint b4 b7 /\ disjoint b5 b6 /\ disjoint b5 b7 /\ disjoint b6 b7 inline_for_extraction let multibuf (lanes:flen) (len:size_t) = ntuple (lbuffer uint8 len) lanes let internally_disjoint #lanes #len (b:multibuf lanes len) = forall i j. (i < lanes /\ j < lanes /\ i <> j) ==> disjoint b.(|i|) b.(|j|) let disjoint_multi #lanes #len #a #len' (b:multibuf lanes len) (b':lbuffer a len') = forall i. i < lanes ==> disjoint b.(|i|) b' let rec loc_multi_ (#lanes:flen) #len (i:nat{i < lanes}) (b:multibuf lanes len) : GTot LowStar.Buffer.loc (decreases (lanes - i)) = if i = lanes - 1 then loc (b.(|i|)) else loc b.(|i|) |+| loc_multi_ (i+1) b let loc_multi #lanes #len b = normalize_term (loc_multi_ #lanes #len 0 b) let loc_multi1 (#lanes:flen{lanes = 1}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == loc b.(|0|)) = () #push-options "--fuel 4" let loc_multi4 (#lanes:flen{lanes = 4}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| loc b.(|3|))))) = () #pop-options #push-options "--fuel 8" let loc_multi8 (#lanes:flen{lanes = 8}) (#len:size_t) (b:multibuf lanes len) : Lemma (loc_multi #lanes #len b == (loc b.(|0|) |+| (loc b.(|1|) |+| (loc b.(|2|) |+| (loc b.(|3|) |+| (loc b.(|4|) |+| (loc b.(|5|) |+| (loc b.(|6|) |+| loc b.(|7|))))))))) = () #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Lib.MultiBuffer.fst" }
[ { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.MultiBuffer.multibuf lanes len -> b': Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.NTuple.op_Lens_Access", "Lib.Buffer.lbuffer", "Prims.logical" ]
[]
false
false
false
false
true
let disjoint_multi_multi #lanes #len #len' (b: multibuf lanes len) (b': multibuf lanes len') =
forall i. i < lanes ==> disjoint b.(| i |) b'.(| i |)
false
BinarySearchTreeFirst.fst
BinarySearchTreeFirst.contains
val contains: #k:int -> t:tree k -> key:int -> Tot bool (decreases t)
val contains: #k:int -> t:tree k -> key:int -> Tot bool (decreases t)
let rec contains (#k:int) t key = if key > k then false else let Node left i right = t in i=k || (key < i && Some? left && contains (Some?.v left) key) || (Some? right && contains (Some?.v right) key)
{ "file_name": "examples/data_structures/BinarySearchTreeFirst.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 68, "start_col": 0, "start_line": 62 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* Exercising: -- indexed types -- implicit value parameters -- dependent tuples -- and refinements, of course *) module BinarySearchTreeFirst open FStar.List.Tot (* The type of a binary tree indexed by its max element *) type tree (r:int) = | Node : #l :int -> left :option (tree l) -> n :int -> right:option (tree r){l <= n /\ n <= r /\ (None? right == (n=r)) /\ (None? left == (n=l))} -> tree r (* Need to supply #i for the empty sub-trees, since it can't be inferred by unification *) let leaf i : tree i = Node #i #i None i None let max i j = if i < j then j else i val insert: #k:int -> t:tree k -> i:int -> Tot (tree (max k i)) (decreases t) let rec insert (#k:int) (Node left n right) i = if i = n then Node left n right (* no duplicates *) else if i < n then match left with | None -> Node (Some (leaf i)) n right | Some left -> Node (Some (insert left i)) n right else match right with | None -> Node left n (Some (leaf i)) | Some right -> Node left n (Some (insert right i))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "BinarySearchTreeFirst.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeFirst.tree k -> key: Prims.int -> Prims.Tot Prims.bool
Prims.Tot
[ "total", "" ]
[]
[ "Prims.int", "BinarySearchTreeFirst.tree", "Prims.op_GreaterThan", "Prims.bool", "FStar.Pervasives.Native.option", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.eq2", "FStar.Pervasives.Native.uu___is_None", "Prims.op_Equality", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_LessThan", "FStar.Pervasives.Native.uu___is_Some", "BinarySearchTreeFirst.contains", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[ "recursion" ]
false
false
false
false
false
let rec contains (#k: int) t key =
if key > k then false else let Node left i right = t in i = k || (key < i && Some? left && contains (Some?.v left) key) || (Some? right && contains (Some?.v right) key)
false
Point.fst
Point.get_colored_point
val get_colored_point:(get_t inv_colored_point)
val get_colored_point:(get_t inv_colored_point)
let get_colored_point :(get_t inv_colored_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 106, "start_col": 9, "start_line": 101 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *) private let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y) private let move_point :(move_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1) let init_point () :ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) = let r1 = alloc 1 in let r2 = alloc 1 in C inv_point [r1; r2] (move_point, get_point) private let inv_colored_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ length fp = 3 /\ (let r1 = hd fp in let r2 = hd (tl fp) in let r3 = hd (tl (tl fp)) in addr_of r1 <> addr_of r2 /\ addr_of r2 <> addr_of r3 /\ addr_of r3 <> addr_of r1) private let move_colored_point :(move_t inv_colored_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Point.get_t Point.inv_colored_point
Prims.Tot
[ "total" ]
[]
[ "Point.fp", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.Heap.ST.read_weak", "FStar.DM4F.Heap.ref", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl" ]
[]
false
false
false
true
false
let get_colored_point:(get_t inv_colored_point) =
fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y)
false
Point.fst
Point.move_colored_point
val move_colored_point:(move_t inv_colored_point)
val move_colored_point:(move_t inv_colored_point)
let move_colored_point :(move_t inv_colored_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
{ "file_name": "examples/rel/Point.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 99, "start_col": 9, "start_line": 92 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Point open FStar.List.Tot open FStar.DM4F.Heap open FStar.DM4F.Heap.ST private let contains_well_typed_refs (h:heap) (s:list (ref nat)) = forall (r:ref nat). memP r s ==> h `contains_a_well_typed` r private type fp = list (ref nat) private type move_t (inv:heap -> fp -> Type0) = s:fp -> ST unit (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type get_t (inv:heap -> fp -> Type0) = s:fp -> ST (nat * nat) (requires (fun h0 -> inv h0 s)) (ensures (fun h0 _ h1 -> inv h1 s)) private type point_t (inv:heap -> fp -> Type0) = move_t inv * get_t inv noeq type point = | C: inv:(heap -> fp -> Type0) -> fp:fp -> p:(point_t inv) -> point (* * AR: 06/03: proofs below rely on this being non-abstract *) let live (p:point) (h:heap) = (C?.inv p) h (C?.fp p) let move (p:point) :ST unit (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let m, _ = f in m fp let get (p:point) :ST (nat * nat) (fun h0 -> live p h0) (fun h0 _ h1 -> live p h1) = match p with | C _ fp f -> let _, g = f in g fp private let inv_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ List.Tot.length fp = 2 /\ addr_of (List.Tot.hd fp) <> addr_of (List.Tot.hd (List.Tot.tl fp)) (* match fp with *) (* | [r1; r2] -> addr_of r1 <> addr_of r2 /\ *) (* | _ -> False *) private let get_point :(get_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in (x, y) private let move_point :(move_t inv_point) = fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1) let init_point () :ST point (requires (fun h0 -> True)) (ensures (fun _ r h1 -> live r h1)) = let r1 = alloc 1 in let r2 = alloc 1 in C inv_point [r1; r2] (move_point, get_point) private let inv_colored_point (h:heap) (fp:fp) :Type0 = h `contains_well_typed_refs` fp /\ length fp = 3 /\ (let r1 = hd fp in let r2 = hd (tl fp) in let r3 = hd (tl (tl fp)) in addr_of r1 <> addr_of r2 /\ addr_of r2 <> addr_of r3 /\ addr_of r3 <> addr_of r1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.DM4F.Heap.ST.fsti.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "Point.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.Heap.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Point.move_t Point.inv_colored_point
Prims.Tot
[ "total" ]
[]
[ "Point.fp", "FStar.DM4F.Heap.ST.write_weak", "Prims.nat", "Prims.op_Addition", "Prims.unit", "FStar.DM4F.Heap.ST.read_weak", "FStar.DM4F.Heap.ref", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl" ]
[]
false
false
false
true
false
let move_colored_point:(move_t inv_colored_point) =
fun s -> let r1 = hd s in let r2 = hd (tl s) in let x = read_weak r1 in let y = read_weak r2 in write_weak r1 (x + 1); write_weak r2 (y + 1)
false