effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
val test1_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
val test1_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} let test1_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26 ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test1_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[]
Hacl.Test.SHA3.test1_expected_sha3_512
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 64 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 135, "start_col": 2, "start_line": 126 }
Prims.Tot
val test3_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
val test3_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} let test3_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test3_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[]
Hacl.Test.SHA3.test3_expected_sha3_512
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 64 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 248, "start_col": 2, "start_line": 239 }
Prims.Tot
val test3_expected_sha3_384:b: lbuffer uint8 48ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
val test3_expected_sha3_384:b: lbuffer uint8 48ul {recallable b} let test3_expected_sha3_384:b: lbuffer uint8 48ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22 ]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test3_expected_sha3_384:b: lbuffer uint8 48ul {recallable b}
[]
Hacl.Test.SHA3.test3_expected_sha3_384
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 48 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 236, "start_col": 2, "start_line": 228 }
Prims.Tot
val test3_plaintext:b: lbuffer uint8 56ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l
val test3_plaintext:b: lbuffer uint8 56ul {recallable b} let test3_plaintext:b: lbuffer uint8 56ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71 ]) in assert_norm (List.Tot.length l == 56); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test3_plaintext:b: lbuffer uint8 56ul {recallable b}
[]
Hacl.Test.SHA3.test3_plaintext
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 56 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 205, "start_col": 2, "start_line": 196 }
Prims.Tot
val test10_plaintext_shake256:b: lbuffer uint8 17ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l
val test10_plaintext_shake256:b: lbuffer uint8 17ul {recallable b} let test10_plaintext_shake256:b: lbuffer uint8 17ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09 ]) in assert_norm (List.Tot.length l == 17); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test10_plaintext_shake256:b: lbuffer uint8 17ul {recallable b}
[]
Hacl.Test.SHA3.test10_plaintext_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 17 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 428, "start_col": 2, "start_line": 421 }
Prims.Tot
val test10_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test10_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
val test10_expected_shake256:b: lbuffer uint8 32ul {recallable b} let test10_expected_shake256:b: lbuffer uint8 32ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60 ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 // let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test10_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[]
Hacl.Test.SHA3.test10_expected_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 32 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 438, "start_col": 2, "start_line": 431 }
Prims.Tot
val test4_expected_sha3_384:b: lbuffer uint8 48ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
val test4_expected_sha3_384:b: lbuffer uint8 48ul {recallable b} let test4_expected_sha3_384:b: lbuffer uint8 48ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7 ]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test4_expected_sha3_384:b: lbuffer uint8 48ul {recallable b}
[]
Hacl.Test.SHA3.test4_expected_sha3_384
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 48 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 297, "start_col": 2, "start_line": 289 }
Prims.Tot
val test7_plaintext_shake128:b: lbuffer uint8 34ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l
val test7_plaintext_shake128:b: lbuffer uint8 34ul {recallable b} let test7_plaintext_shake128:b: lbuffer uint8 34ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65 ]) in assert_norm (List.Tot.length l == 34); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test7_plaintext_shake128:b: lbuffer uint8 34ul {recallable b}
[]
Hacl.Test.SHA3.test7_plaintext_shake128
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 34 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 361, "start_col": 2, "start_line": 353 }
Prims.Tot
val test11_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test11_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7a; 0xbb; 0xa4; 0xe8; 0xb8; 0xdd; 0x76; 0x6b; 0xba; 0xbe; 0x98; 0xf8; 0xf1; 0x69; 0xcb; 0x62; 0x08; 0x67; 0x4d; 0xe1; 0x9a; 0x51; 0xd7; 0x3c; 0x92; 0xb7; 0xdc; 0x04; 0xa4; 0xb5; 0xee; 0x3d]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
val test11_expected_shake256:b: lbuffer uint8 32ul {recallable b} let test11_expected_shake256:b: lbuffer uint8 32ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x7a; 0xbb; 0xa4; 0xe8; 0xb8; 0xdd; 0x76; 0x6b; 0xba; 0xbe; 0x98; 0xf8; 0xf1; 0x69; 0xcb; 0x62; 0x08; 0x67; 0x4d; 0xe1; 0x9a; 0x51; 0xd7; 0x3c; 0x92; 0xb7; 0xdc; 0x04; 0xa4; 0xb5; 0xee; 0x3d ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 // let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l let test10_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test11_SHAKE256 // let test11_plaintext_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xef; 0x89; 0x6c; 0xdc; 0xb3; 0x63; 0xa6; 0x15; 0x91; 0x78; 0xa1; 0xbb; 0x1c; 0x99; 0x39; 0x46; 0xc5; 0x04; 0x02; 0x09; 0x5c; 0xda; 0xea; 0x4f; 0xd4; 0xd4; 0x19; 0xaa; 0x47; 0x32; 0x1c; 0x88]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test11_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[]
Hacl.Test.SHA3.test11_expected_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 32 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 461, "start_col": 2, "start_line": 454 }
Prims.Tot
val test2_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
val test2_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} let test2_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0 ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test2_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[]
Hacl.Test.SHA3.test2_expected_sha3_512
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 64 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 190, "start_col": 2, "start_line": 181 }
Prims.Tot
val test12_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test12_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x64; 0x2f; 0x3f; 0x23; 0x5a; 0xc7; 0xe3; 0xd4; 0x34; 0x06; 0x3b; 0x5f; 0xc9; 0x21; 0x5f; 0xc3; 0xf0; 0xe5; 0x91; 0xe2; 0xe7; 0xfd; 0x17; 0x66; 0x8d; 0x1a; 0x0c; 0x87; 0x46; 0x87; 0x35; 0xc2]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
val test12_expected_shake256:b: lbuffer uint8 32ul {recallable b} let test12_expected_shake256:b: lbuffer uint8 32ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x64; 0x2f; 0x3f; 0x23; 0x5a; 0xc7; 0xe3; 0xd4; 0x34; 0x06; 0x3b; 0x5f; 0xc9; 0x21; 0x5f; 0xc3; 0xf0; 0xe5; 0x91; 0xe2; 0xe7; 0xfd; 0x17; 0x66; 0x8d; 0x1a; 0x0c; 0x87; 0x46; 0x87; 0x35; 0xc2 ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 // let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l let test10_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test11_SHAKE256 // let test11_plaintext_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xef; 0x89; 0x6c; 0xdc; 0xb3; 0x63; 0xa6; 0x15; 0x91; 0x78; 0xa1; 0xbb; 0x1c; 0x99; 0x39; 0x46; 0xc5; 0x04; 0x02; 0x09; 0x5c; 0xda; 0xea; 0x4f; 0xd4; 0xd4; 0x19; 0xaa; 0x47; 0x32; 0x1c; 0x88]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test11_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7a; 0xbb; 0xa4; 0xe8; 0xb8; 0xdd; 0x76; 0x6b; 0xba; 0xbe; 0x98; 0xf8; 0xf1; 0x69; 0xcb; 0x62; 0x08; 0x67; 0x4d; 0xe1; 0x9a; 0x51; 0xd7; 0x3c; 0x92; 0xb7; 0xdc; 0x04; 0xa4; 0xb5; 0xee; 0x3d]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test12_SHAKE256 // let test12_plaintext_shake256: b:lbuffer uint8 78ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xde; 0x70; 0x1f; 0x10; 0xad; 0x39; 0x61; 0xb0; 0xda; 0xcc; 0x96; 0x87; 0x3a; 0x3c; 0xd5; 0x58; 0x55; 0x81; 0x88; 0xff; 0x69; 0x6d; 0x85; 0x01; 0xb2; 0xe2; 0x7b; 0x67; 0xe9; 0x41; 0x90; 0xcd; 0x0b; 0x25; 0x48; 0xb6; 0x5b; 0x52; 0xa9; 0x22; 0xaa; 0xe8; 0x9d; 0x63; 0xd6; 0xdd; 0x97; 0x2c; 0x91; 0xa9; 0x79; 0xeb; 0x63; 0x43; 0xb6; 0x58; 0xf2; 0x4d; 0xb3; 0x4e; 0x82; 0x8b; 0x74; 0xdb; 0xb8; 0x9a; 0x74; 0x93; 0xa3; 0xdf; 0xd4; 0x29; 0xfd; 0xbd; 0xb8; 0x40; 0xad; 0x0b]) in assert_norm (List.Tot.length l == 78); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test12_expected_shake256:b: lbuffer uint8 32ul {recallable b}
[]
Hacl.Test.SHA3.test12_expected_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 32 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 487, "start_col": 2, "start_line": 480 }
Prims.Tot
val test4_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
val test4_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} let test4_expected_sha3_512:b: lbuffer uint8 64ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85 ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test4_expected_sha3_512:b: lbuffer uint8 64ul {recallable b}
[]
Hacl.Test.SHA3.test4_expected_sha3_512
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 64 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 309, "start_col": 2, "start_line": 300 }
Prims.Tot
val test12_plaintext_shake256:b: lbuffer uint8 78ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test12_plaintext_shake256: b:lbuffer uint8 78ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xde; 0x70; 0x1f; 0x10; 0xad; 0x39; 0x61; 0xb0; 0xda; 0xcc; 0x96; 0x87; 0x3a; 0x3c; 0xd5; 0x58; 0x55; 0x81; 0x88; 0xff; 0x69; 0x6d; 0x85; 0x01; 0xb2; 0xe2; 0x7b; 0x67; 0xe9; 0x41; 0x90; 0xcd; 0x0b; 0x25; 0x48; 0xb6; 0x5b; 0x52; 0xa9; 0x22; 0xaa; 0xe8; 0x9d; 0x63; 0xd6; 0xdd; 0x97; 0x2c; 0x91; 0xa9; 0x79; 0xeb; 0x63; 0x43; 0xb6; 0x58; 0xf2; 0x4d; 0xb3; 0x4e; 0x82; 0x8b; 0x74; 0xdb; 0xb8; 0x9a; 0x74; 0x93; 0xa3; 0xdf; 0xd4; 0x29; 0xfd; 0xbd; 0xb8; 0x40; 0xad; 0x0b]) in assert_norm (List.Tot.length l == 78); createL_mglobal l
val test12_plaintext_shake256:b: lbuffer uint8 78ul {recallable b} let test12_plaintext_shake256:b: lbuffer uint8 78ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xde; 0x70; 0x1f; 0x10; 0xad; 0x39; 0x61; 0xb0; 0xda; 0xcc; 0x96; 0x87; 0x3a; 0x3c; 0xd5; 0x58; 0x55; 0x81; 0x88; 0xff; 0x69; 0x6d; 0x85; 0x01; 0xb2; 0xe2; 0x7b; 0x67; 0xe9; 0x41; 0x90; 0xcd; 0x0b; 0x25; 0x48; 0xb6; 0x5b; 0x52; 0xa9; 0x22; 0xaa; 0xe8; 0x9d; 0x63; 0xd6; 0xdd; 0x97; 0x2c; 0x91; 0xa9; 0x79; 0xeb; 0x63; 0x43; 0xb6; 0x58; 0xf2; 0x4d; 0xb3; 0x4e; 0x82; 0x8b; 0x74; 0xdb; 0xb8; 0x9a; 0x74; 0x93; 0xa3; 0xdf; 0xd4; 0x29; 0xfd; 0xbd; 0xb8; 0x40; 0xad; 0x0b ]) in assert_norm (List.Tot.length l == 78); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 // let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l let test10_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test11_SHAKE256 // let test11_plaintext_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xef; 0x89; 0x6c; 0xdc; 0xb3; 0x63; 0xa6; 0x15; 0x91; 0x78; 0xa1; 0xbb; 0x1c; 0x99; 0x39; 0x46; 0xc5; 0x04; 0x02; 0x09; 0x5c; 0xda; 0xea; 0x4f; 0xd4; 0xd4; 0x19; 0xaa; 0x47; 0x32; 0x1c; 0x88]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test11_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7a; 0xbb; 0xa4; 0xe8; 0xb8; 0xdd; 0x76; 0x6b; 0xba; 0xbe; 0x98; 0xf8; 0xf1; 0x69; 0xcb; 0x62; 0x08; 0x67; 0x4d; 0xe1; 0x9a; 0x51; 0xd7; 0x3c; 0x92; 0xb7; 0xdc; 0x04; 0xa4; 0xb5; 0xee; 0x3d]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test12_SHAKE256 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test12_plaintext_shake256:b: lbuffer uint8 78ul {recallable b}
[]
Hacl.Test.SHA3.test12_plaintext_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 78 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 477, "start_col": 2, "start_line": 467 }
FStar.HyperStack.ST.Stack
val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame ()
val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected =
true
null
false
push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame ()
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "C.exit", "FStar.Int32.__int_to_t", "Prims.bool", "Prims.op_Negation", "Lib.PrintBuffer.result_compare_display", "Lib.Buffer.to_const", "Lib.Buffer.MUT", "Hacl.SHA3.shake128_hacl", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
[]
Hacl.Test.SHA3.test_shake128
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> out_len: Lib.IntTypes.size_t{Lib.IntTypes.v out_len > 0} -> expected: Lib.Buffer.lbuffer Lib.IntTypes.uint8 out_len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 59, "start_col": 2, "start_line": 55 }
FStar.HyperStack.ST.Stack
val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame ()
val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected =
true
null
false
push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame ()
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "C.exit", "FStar.Int32.__int_to_t", "Prims.bool", "Prims.op_Negation", "Lib.PrintBuffer.result_compare_display", "Lib.Buffer.to_const", "Lib.Buffer.MUT", "Hacl.SHA3.shake256_hacl", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1)
[]
Hacl.Test.SHA3.test_shake256
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> out_len: Lib.IntTypes.size_t{Lib.IntTypes.v out_len > 0} -> expected: Lib.Buffer.lbuffer Lib.IntTypes.uint8 out_len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 76, "start_col": 2, "start_line": 72 }
Prims.Tot
val test8_plaintext_shake128:b: lbuffer uint8 83ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l
val test8_plaintext_shake128:b: lbuffer uint8 83ul {recallable b} let test8_plaintext_shake128:b: lbuffer uint8 83ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01 ]) in assert_norm (List.Tot.length l == 83); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test8_plaintext_shake128:b: lbuffer uint8 83ul {recallable b}
[]
Hacl.Test.SHA3.test8_plaintext_shake128
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 83 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 387, "start_col": 2, "start_line": 376 }
Prims.Tot
val test4_plaintext:b: lbuffer uint8 112ul {recallable b}
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l
val test4_plaintext:b: lbuffer uint8 112ul {recallable b} let test4_plaintext:b: lbuffer uint8 112ul {recallable b} =
false
null
false
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75 ]) in assert_norm (List.Tot.length l == 112); createL_mglobal l
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[ "total" ]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA3.u8", "Prims.Cons", "Prims.Nil" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 //
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test4_plaintext:b: lbuffer uint8 112ul {recallable b}
[]
Hacl.Test.SHA3.test4_plaintext
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 112 <: FStar.UInt32.t) {Lib.Buffer.recallable b}
{ "end_col": 19, "end_line": 266, "start_col": 2, "start_line": 254 }
FStar.HyperStack.ST.St
val main: unit -> St C.exit_code
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let main () = C.String.print (C.String.of_literal "\nTEST 1. SHA3\n"); recall test1_expected_sha3_224; recall test1_expected_sha3_256; recall test1_expected_sha3_384; recall test1_expected_sha3_512; recall test1_plaintext; test_sha3 0ul test1_plaintext test1_expected_sha3_224 test1_expected_sha3_256 test1_expected_sha3_384 test1_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 2. SHA3\n"); recall test2_expected_sha3_224; recall test2_expected_sha3_256; recall test2_expected_sha3_384; recall test2_expected_sha3_512; recall test2_plaintext; test_sha3 3ul test2_plaintext test2_expected_sha3_224 test2_expected_sha3_256 test2_expected_sha3_384 test2_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 3. SHA3\n"); recall test3_expected_sha3_224; recall test3_expected_sha3_256; recall test3_expected_sha3_384; recall test3_expected_sha3_512; recall test3_plaintext; test_sha3 56ul test3_plaintext test3_expected_sha3_224 test3_expected_sha3_256 test3_expected_sha3_384 test3_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 4. SHA3\n"); recall test4_expected_sha3_224; recall test4_expected_sha3_256; recall test4_expected_sha3_384; recall test4_expected_sha3_512; recall test4_plaintext; test_sha3 112ul test4_plaintext test4_expected_sha3_224 test4_expected_sha3_256 test4_expected_sha3_384 test4_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 5. SHAKE128\n"); recall test5_plaintext_shake128; recall test5_expected_shake128; test_shake128 0ul test5_plaintext_shake128 16ul test5_expected_shake128; C.String.print (C.String.of_literal "\nTEST 6. SHAKE128\n"); recall test6_plaintext_shake128; recall test6_expected_shake128; test_shake128 14ul test6_plaintext_shake128 16ul test6_expected_shake128; C.String.print (C.String.of_literal "\nTEST 7. SHAKE128\n"); recall test7_plaintext_shake128; recall test7_expected_shake128; test_shake128 34ul test7_plaintext_shake128 16ul test7_expected_shake128; C.String.print (C.String.of_literal "\nTEST 8. SHAKE128\n"); recall test8_plaintext_shake128; recall test8_expected_shake128; test_shake128 83ul test8_plaintext_shake128 16ul test8_expected_shake128; C.String.print (C.String.of_literal "\nTEST 9. SHAKE256\n"); recall test9_plaintext_shake256; recall test9_expected_shake256; test_shake256 0ul test9_plaintext_shake256 32ul test9_expected_shake256; C.String.print (C.String.of_literal "\nTEST 10. SHAKE256\n"); recall test10_plaintext_shake256; recall test10_expected_shake256; test_shake256 17ul test10_plaintext_shake256 32ul test10_expected_shake256; C.String.print (C.String.of_literal "\nTEST 11. SHAKE256\n"); recall test11_plaintext_shake256; recall test11_expected_shake256; test_shake256 32ul test11_plaintext_shake256 32ul test11_expected_shake256; C.String.print (C.String.of_literal "\nTEST 12. SHAKE256\n"); recall test12_plaintext_shake256; recall test12_expected_shake256; test_shake256 78ul test12_plaintext_shake256 32ul test12_expected_shake256; C.EXIT_SUCCESS
val main: unit -> St C.exit_code let main () =
true
null
false
C.String.print (C.String.of_literal "\nTEST 1. SHA3\n"); recall test1_expected_sha3_224; recall test1_expected_sha3_256; recall test1_expected_sha3_384; recall test1_expected_sha3_512; recall test1_plaintext; test_sha3 0ul test1_plaintext test1_expected_sha3_224 test1_expected_sha3_256 test1_expected_sha3_384 test1_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 2. SHA3\n"); recall test2_expected_sha3_224; recall test2_expected_sha3_256; recall test2_expected_sha3_384; recall test2_expected_sha3_512; recall test2_plaintext; test_sha3 3ul test2_plaintext test2_expected_sha3_224 test2_expected_sha3_256 test2_expected_sha3_384 test2_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 3. SHA3\n"); recall test3_expected_sha3_224; recall test3_expected_sha3_256; recall test3_expected_sha3_384; recall test3_expected_sha3_512; recall test3_plaintext; test_sha3 56ul test3_plaintext test3_expected_sha3_224 test3_expected_sha3_256 test3_expected_sha3_384 test3_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 4. SHA3\n"); recall test4_expected_sha3_224; recall test4_expected_sha3_256; recall test4_expected_sha3_384; recall test4_expected_sha3_512; recall test4_plaintext; test_sha3 112ul test4_plaintext test4_expected_sha3_224 test4_expected_sha3_256 test4_expected_sha3_384 test4_expected_sha3_512; C.String.print (C.String.of_literal "\nTEST 5. SHAKE128\n"); recall test5_plaintext_shake128; recall test5_expected_shake128; test_shake128 0ul test5_plaintext_shake128 16ul test5_expected_shake128; C.String.print (C.String.of_literal "\nTEST 6. SHAKE128\n"); recall test6_plaintext_shake128; recall test6_expected_shake128; test_shake128 14ul test6_plaintext_shake128 16ul test6_expected_shake128; C.String.print (C.String.of_literal "\nTEST 7. SHAKE128\n"); recall test7_plaintext_shake128; recall test7_expected_shake128; test_shake128 34ul test7_plaintext_shake128 16ul test7_expected_shake128; C.String.print (C.String.of_literal "\nTEST 8. SHAKE128\n"); recall test8_plaintext_shake128; recall test8_expected_shake128; test_shake128 83ul test8_plaintext_shake128 16ul test8_expected_shake128; C.String.print (C.String.of_literal "\nTEST 9. SHAKE256\n"); recall test9_plaintext_shake256; recall test9_expected_shake256; test_shake256 0ul test9_plaintext_shake256 32ul test9_expected_shake256; C.String.print (C.String.of_literal "\nTEST 10. SHAKE256\n"); recall test10_plaintext_shake256; recall test10_expected_shake256; test_shake256 17ul test10_plaintext_shake256 32ul test10_expected_shake256; C.String.print (C.String.of_literal "\nTEST 11. SHAKE256\n"); recall test11_plaintext_shake256; recall test11_expected_shake256; test_shake256 32ul test11_plaintext_shake256 32ul test11_expected_shake256; C.String.print (C.String.of_literal "\nTEST 12. SHAKE256\n"); recall test12_plaintext_shake256; recall test12_expected_shake256; test_shake256 78ul test12_plaintext_shake256 32ul test12_expected_shake256; C.EXIT_SUCCESS
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[]
[ "Prims.unit", "C.EXIT_SUCCESS", "C.exit_code", "Hacl.Test.SHA3.test_shake256", "FStar.UInt32.__uint_to_t", "Hacl.Test.SHA3.test12_plaintext_shake256", "Hacl.Test.SHA3.test12_expected_shake256", "Lib.Buffer.recall", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "C.String.print", "C.String.of_literal", "Hacl.Test.SHA3.test11_plaintext_shake256", "Hacl.Test.SHA3.test11_expected_shake256", "Hacl.Test.SHA3.test10_plaintext_shake256", "Hacl.Test.SHA3.test10_expected_shake256", "Hacl.Test.SHA3.test9_plaintext_shake256", "Hacl.Test.SHA3.test9_expected_shake256", "Hacl.Test.SHA3.test_shake128", "Hacl.Test.SHA3.test8_plaintext_shake128", "Hacl.Test.SHA3.test8_expected_shake128", "Hacl.Test.SHA3.test7_plaintext_shake128", "Hacl.Test.SHA3.test7_expected_shake128", "Hacl.Test.SHA3.test6_plaintext_shake128", "Hacl.Test.SHA3.test6_expected_shake128", "Hacl.Test.SHA3.test5_plaintext_shake128", "Hacl.Test.SHA3.test5_expected_shake128", "Hacl.Test.SHA3.test_sha3", "Hacl.Test.SHA3.test4_plaintext", "Hacl.Test.SHA3.test4_expected_sha3_224", "Hacl.Test.SHA3.test4_expected_sha3_256", "Hacl.Test.SHA3.test4_expected_sha3_384", "Hacl.Test.SHA3.test4_expected_sha3_512", "Hacl.Test.SHA3.test3_plaintext", "Hacl.Test.SHA3.test3_expected_sha3_224", "Hacl.Test.SHA3.test3_expected_sha3_256", "Hacl.Test.SHA3.test3_expected_sha3_384", "Hacl.Test.SHA3.test3_expected_sha3_512", "Hacl.Test.SHA3.test2_plaintext", "Hacl.Test.SHA3.test2_expected_sha3_224", "Hacl.Test.SHA3.test2_expected_sha3_256", "Hacl.Test.SHA3.test2_expected_sha3_384", "Hacl.Test.SHA3.test2_expected_sha3_512", "Hacl.Test.SHA3.test1_plaintext", "Hacl.Test.SHA3.test1_expected_sha3_224", "Hacl.Test.SHA3.test1_expected_sha3_256", "Hacl.Test.SHA3.test1_expected_sha3_384", "Hacl.Test.SHA3.test1_expected_sha3_512" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() val test_shake128: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake128 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake128_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () val test_shake256: msg_len:size_t -> msg:lbuffer uint8 msg_len -> out_len:size_t{v out_len > 0} -> expected:lbuffer uint8 out_len -> Stack unit (requires fun h -> live h msg /\ live h expected) (ensures fun h0 r h1 -> modifies0 h0 h1) let test_shake256 msg_len msg out_len expected = push_frame (); let test = create out_len (u8 0) in shake256_hacl msg_len msg out_len test; if not (result_compare_display out_len (to_const test) (to_const expected)) then C.exit 255l; pop_frame () inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA3 // let test1_plaintext: b:lbuffer uint8 0ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test1_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x6b; 0x4e; 0x03; 0x42; 0x36; 0x67; 0xdb; 0xb7; 0x3b; 0x6e; 0x15; 0x45; 0x4f; 0x0e; 0xb1; 0xab; 0xd4; 0x59; 0x7f; 0x9a; 0x1b; 0x07; 0x8e; 0x3f; 0x5b; 0x5a; 0x6b; 0xc7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa7; 0xff; 0xc6; 0xf8; 0xbf; 0x1e; 0xd7; 0x66; 0x51; 0xc1; 0x47; 0x56; 0xa0; 0x61; 0xd6; 0x62; 0xf5; 0x80; 0xff; 0x4d; 0xe4; 0x3b; 0x49; 0xfa; 0x82; 0xd8; 0x0a; 0x4b; 0x80; 0xf8; 0x43; 0x4a]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x0c; 0x63; 0xa7; 0x5b; 0x84; 0x5e; 0x4f; 0x7d; 0x01; 0x10; 0x7d; 0x85; 0x2e; 0x4c; 0x24; 0x85; 0xc5; 0x1a; 0x50; 0xaa; 0xaa; 0x94; 0xfc; 0x61; 0x99; 0x5e; 0x71; 0xbb; 0xee; 0x98; 0x3a; 0x2a; 0xc3; 0x71; 0x38; 0x31; 0x26; 0x4a; 0xdb; 0x47; 0xfb; 0x6b; 0xd1; 0xe0; 0x58; 0xd5; 0xf0; 0x04]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa6; 0x9f; 0x73; 0xcc; 0xa2; 0x3a; 0x9a; 0xc5; 0xc8; 0xb5; 0x67; 0xdc; 0x18; 0x5a; 0x75; 0x6e; 0x97; 0xc9; 0x82; 0x16; 0x4f; 0xe2; 0x58; 0x59; 0xe0; 0xd1; 0xdc; 0xc1; 0x47; 0x5c; 0x80; 0xa6; 0x15; 0xb2; 0x12; 0x3a; 0xf1; 0xf5; 0xf9; 0x4c; 0x11; 0xe3; 0xe9; 0x40; 0x2c; 0x3a; 0xc5; 0x58; 0xf5; 0x00; 0x19; 0x9d; 0x95; 0xb6; 0xd3; 0xe3; 0x01; 0x75; 0x85; 0x86; 0x28; 0x1d; 0xcd; 0x26]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA3 // let test2_plaintext: b:lbuffer uint8 3ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test2_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe6; 0x42; 0x82; 0x4c; 0x3f; 0x8c; 0xf2; 0x4a; 0xd0; 0x92; 0x34; 0xee; 0x7d; 0x3c; 0x76; 0x6f; 0xc9; 0xa3; 0xa5; 0x16; 0x8d; 0x0c; 0x94; 0xad; 0x73; 0xb4; 0x6f; 0xdf]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x3a; 0x98; 0x5d; 0xa7; 0x4f; 0xe2; 0x25; 0xb2; 0x04; 0x5c; 0x17; 0x2d; 0x6b; 0xd3; 0x90; 0xbd; 0x85; 0x5f; 0x08; 0x6e; 0x3e; 0x9d; 0x52; 0x5b; 0x46; 0xbf; 0xe2; 0x45; 0x11; 0x43; 0x15; 0x32]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xec; 0x01; 0x49; 0x82; 0x88; 0x51; 0x6f; 0xc9; 0x26; 0x45; 0x9f; 0x58; 0xe2; 0xc6; 0xad; 0x8d; 0xf9; 0xb4; 0x73; 0xcb; 0x0f; 0xc0; 0x8c; 0x25; 0x96; 0xda; 0x7c; 0xf0; 0xe4; 0x9b; 0xe4; 0xb2; 0x98; 0xd8; 0x8c; 0xea; 0x92; 0x7a; 0xc7; 0xf5; 0x39; 0xf1; 0xed; 0xf2; 0x28; 0x37; 0x6d; 0x25]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xb7; 0x51; 0x85; 0x0b; 0x1a; 0x57; 0x16; 0x8a; 0x56; 0x93; 0xcd; 0x92; 0x4b; 0x6b; 0x09; 0x6e; 0x08; 0xf6; 0x21; 0x82; 0x74; 0x44; 0xf7; 0x0d; 0x88; 0x4f; 0x5d; 0x02; 0x40; 0xd2; 0x71; 0x2e; 0x10; 0xe1; 0x16; 0xe9; 0x19; 0x2a; 0xf3; 0xc9; 0x1a; 0x7e; 0xc5; 0x76; 0x47; 0xe3; 0x93; 0x40; 0x57; 0x34; 0x0b; 0x4c; 0xf4; 0x08; 0xd5; 0xa5; 0x65; 0x92; 0xf8; 0x27; 0x4e; 0xec; 0x53; 0xf0]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA3 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x8a; 0x24; 0x10; 0x8b; 0x15; 0x4a; 0xda; 0x21; 0xc9; 0xfd; 0x55; 0x74; 0x49; 0x44; 0x79; 0xba; 0x5c; 0x7e; 0x7a; 0xb7; 0x6e; 0xf2; 0x64; 0xea; 0xd0; 0xfc; 0xce; 0x33]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x41; 0xc0; 0xdb; 0xa2; 0xa9; 0xd6; 0x24; 0x08; 0x49; 0x10; 0x03; 0x76; 0xa8; 0x23; 0x5e; 0x2c; 0x82; 0xe1; 0xb9; 0x99; 0x8a; 0x99; 0x9e; 0x21; 0xdb; 0x32; 0xdd; 0x97; 0x49; 0x6d; 0x33; 0x76]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x99; 0x1c; 0x66; 0x57; 0x55; 0xeb; 0x3a; 0x4b; 0x6b; 0xbd; 0xfb; 0x75; 0xc7; 0x8a; 0x49; 0x2e; 0x8c; 0x56; 0xa2; 0x2c; 0x5c; 0x4d; 0x7e; 0x42; 0x9b; 0xfd; 0xbc; 0x32; 0xb9; 0xd4; 0xad; 0x5a; 0xa0; 0x4a; 0x1f; 0x07; 0x6e; 0x62; 0xfe; 0xa1; 0x9e; 0xef; 0x51; 0xac; 0xd0; 0x65; 0x7c; 0x22]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x04; 0xa3; 0x71; 0xe8; 0x4e; 0xcf; 0xb5; 0xb8; 0xb7; 0x7c; 0xb4; 0x86; 0x10; 0xfc; 0xa8; 0x18; 0x2d; 0xd4; 0x57; 0xce; 0x6f; 0x32; 0x6a; 0x0f; 0xd3; 0xd7; 0xec; 0x2f; 0x1e; 0x91; 0x63; 0x6d; 0xee; 0x69; 0x1f; 0xbe; 0x0c; 0x98; 0x53; 0x02; 0xba; 0x1b; 0x0d; 0x8d; 0xc7; 0x8c; 0x08; 0x63; 0x46; 0xb5; 0x33; 0xb4; 0x9c; 0x03; 0x0d; 0x99; 0xa2; 0x7d; 0xaf; 0x11; 0x39; 0xd6; 0xe7; 0x5e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA3 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha3_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x54; 0x3e; 0x68; 0x68; 0xe1; 0x66; 0x6c; 0x1a; 0x64; 0x36; 0x30; 0xdf; 0x77; 0x36; 0x7a; 0xe5; 0xa6; 0x2a; 0x85; 0x07; 0x0a; 0x51; 0xc1; 0x4c; 0xbf; 0x66; 0x5c; 0xbc]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test4_expected_sha3_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x91; 0x6f; 0x60; 0x61; 0xfe; 0x87; 0x97; 0x41; 0xca; 0x64; 0x69; 0xb4; 0x39; 0x71; 0xdf; 0xdb; 0x28; 0xb1; 0xa3; 0x2d; 0xc3; 0x6c; 0xb3; 0x25; 0x4e; 0x81; 0x2b; 0xe2; 0x7a; 0xad; 0x1d; 0x18]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test4_expected_sha3_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x79; 0x40; 0x7d; 0x3b; 0x59; 0x16; 0xb5; 0x9c; 0x3e; 0x30; 0xb0; 0x98; 0x22; 0x97; 0x47; 0x91; 0xc3; 0x13; 0xfb; 0x9e; 0xcc; 0x84; 0x9e; 0x40; 0x6f; 0x23; 0x59; 0x2d; 0x04; 0xf6; 0x25; 0xdc; 0x8c; 0x70; 0x9b; 0x98; 0xb4; 0x3b; 0x38; 0x52; 0xb3; 0x37; 0x21; 0x61; 0x79; 0xaa; 0x7f; 0xc7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test4_expected_sha3_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xaf; 0xeb; 0xb2; 0xef; 0x54; 0x2e; 0x65; 0x79; 0xc5; 0x0c; 0xad; 0x06; 0xd2; 0xe5; 0x78; 0xf9; 0xf8; 0xdd; 0x68; 0x81; 0xd7; 0xdc; 0x82; 0x4d; 0x26; 0x36; 0x0f; 0xee; 0xbf; 0x18; 0xa4; 0xfa; 0x73; 0xe3; 0x26; 0x11; 0x22; 0x94; 0x8e; 0xfc; 0xfd; 0x49; 0x2e; 0x74; 0xe8; 0x2e; 0x21; 0x89; 0xed; 0x0f; 0xb4; 0x40; 0xd1; 0x87; 0xf3; 0x82; 0x27; 0x0c; 0xb4; 0x55; 0xf2; 0x1d; 0xd1; 0x85]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test5_SHAKE128 // let test5_plaintext_shake128: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test5_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7f; 0x9c; 0x2b; 0xa4; 0xe8; 0x8f; 0x82; 0x7d; 0x61; 0x60; 0x45; 0x50; 0x76; 0x05; 0x85; 0x3e]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test6_SHAKE128 // let test6_plaintext_shake128: b:lbuffer uint8 14ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x52; 0x97; 0x7e; 0x53; 0x2b; 0xcc; 0xdb; 0x89; 0xdf; 0xef; 0xf7; 0xe9; 0xe4; 0xad]) in assert_norm (List.Tot.length l == 14); createL_mglobal l let test6_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xfb; 0xfb; 0xa5; 0xc1; 0xe1; 0x79; 0xdf; 0x14; 0x69; 0xfc; 0xc8; 0x58; 0x8a; 0xe5; 0xd2; 0xcc]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test7_SHAKE128 // let test7_plaintext_shake128: b:lbuffer uint8 34ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x4a; 0x20; 0x6a; 0x5b; 0x8a; 0xa3; 0x58; 0x6c; 0x06; 0x67; 0xa4; 0x00; 0x20; 0xd6; 0x5f; 0xf5; 0x11; 0xd5; 0x2b; 0x73; 0x2e; 0xf7; 0xa0; 0xc5; 0x69; 0xf1; 0xee; 0x68; 0x1a; 0x4f; 0xc3; 0x62; 0x00; 0x65]) in assert_norm (List.Tot.length l == 34); createL_mglobal l let test7_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7b; 0xb4; 0x33; 0x75; 0x2b; 0x98; 0xf9; 0x15; 0xbe; 0x51; 0x82; 0xbc; 0x1f; 0x09; 0x66; 0x48]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test8_SHAKE128 // let test8_plaintext_shake128: b:lbuffer uint8 83ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x69; 0xf1; 0x01; 0xc9; 0xb4; 0x99; 0xa9; 0x30; 0xa9; 0x7e; 0xf1; 0xb3; 0x46; 0x73; 0xec; 0x74; 0x39; 0x3f; 0xd9; 0xfa; 0xf6; 0x58; 0xe3; 0x1f; 0x06; 0xee; 0x0b; 0x29; 0xa2; 0x2b; 0x62; 0x37; 0x80; 0xba; 0x7b; 0xdf; 0xed; 0x86; 0x20; 0x15; 0x1c; 0xc4; 0x44; 0x4e; 0xbe; 0x33; 0x39; 0xe6; 0xd2; 0xa2; 0x23; 0xbf; 0xbf; 0xb4; 0xad; 0x2c; 0xa0; 0xe0; 0xfa; 0x0d; 0xdf; 0xbb; 0xdf; 0x3b; 0x05; 0x7a; 0x4f; 0x26; 0xd0; 0xb2; 0x16; 0xbc; 0x87; 0x63; 0xca; 0x8d; 0x8a; 0x35; 0xff; 0x2d; 0x2d; 0x01]) in assert_norm (List.Tot.length l == 83); createL_mglobal l let test8_expected_shake128: b:lbuffer uint8 16ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x00; 0xff; 0x5e; 0xf0; 0xcd; 0x7f; 0x8f; 0x90; 0xad; 0x94; 0xb7; 0x97; 0xe9; 0xd4; 0xdd; 0x30]) in assert_norm (List.Tot.length l == 16); createL_mglobal l // // Test9_SHAKE256 // let test9_plaintext_shake256: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test9_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x46; 0xb9; 0xdd; 0x2b; 0x0b; 0xa8; 0x8d; 0x13; 0x23; 0x3b; 0x3f; 0xeb; 0x74; 0x3e; 0xeb; 0x24; 0x3f; 0xcd; 0x52; 0xea; 0x62; 0xb8; 0x1b; 0x82; 0xb5; 0x0c; 0x27; 0x64; 0x6e; 0xd5; 0x76; 0x2f]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test10_SHAKE256 // let test10_plaintext_shake256: b:lbuffer uint8 17ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xf9; 0xda; 0x78; 0xc8; 0x90; 0x84; 0x70; 0x40; 0x45; 0x4b; 0xa6; 0x42; 0x98; 0x82; 0xb0; 0x54; 0x09]) in assert_norm (List.Tot.length l == 17); createL_mglobal l let test10_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xa8; 0x49; 0x83; 0xc9; 0xfe; 0x75; 0xad; 0x0d; 0xe1; 0x9e; 0x2c; 0x84; 0x20; 0xa7; 0xea; 0x85; 0xb2; 0x51; 0x02; 0x19; 0x56; 0x14; 0xdf; 0xa5; 0x34; 0x7d; 0xe6; 0x0a; 0x1c; 0xe1; 0x3b; 0x60]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test11_SHAKE256 // let test11_plaintext_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xef; 0x89; 0x6c; 0xdc; 0xb3; 0x63; 0xa6; 0x15; 0x91; 0x78; 0xa1; 0xbb; 0x1c; 0x99; 0x39; 0x46; 0xc5; 0x04; 0x02; 0x09; 0x5c; 0xda; 0xea; 0x4f; 0xd4; 0xd4; 0x19; 0xaa; 0x47; 0x32; 0x1c; 0x88]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test11_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x7a; 0xbb; 0xa4; 0xe8; 0xb8; 0xdd; 0x76; 0x6b; 0xba; 0xbe; 0x98; 0xf8; 0xf1; 0x69; 0xcb; 0x62; 0x08; 0x67; 0x4d; 0xe1; 0x9a; 0x51; 0xd7; 0x3c; 0x92; 0xb7; 0xdc; 0x04; 0xa4; 0xb5; 0xee; 0x3d]) in assert_norm (List.Tot.length l == 32); createL_mglobal l // // Test12_SHAKE256 // let test12_plaintext_shake256: b:lbuffer uint8 78ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xde; 0x70; 0x1f; 0x10; 0xad; 0x39; 0x61; 0xb0; 0xda; 0xcc; 0x96; 0x87; 0x3a; 0x3c; 0xd5; 0x58; 0x55; 0x81; 0x88; 0xff; 0x69; 0x6d; 0x85; 0x01; 0xb2; 0xe2; 0x7b; 0x67; 0xe9; 0x41; 0x90; 0xcd; 0x0b; 0x25; 0x48; 0xb6; 0x5b; 0x52; 0xa9; 0x22; 0xaa; 0xe8; 0x9d; 0x63; 0xd6; 0xdd; 0x97; 0x2c; 0x91; 0xa9; 0x79; 0xeb; 0x63; 0x43; 0xb6; 0x58; 0xf2; 0x4d; 0xb3; 0x4e; 0x82; 0x8b; 0x74; 0xdb; 0xb8; 0x9a; 0x74; 0x93; 0xa3; 0xdf; 0xd4; 0x29; 0xfd; 0xbd; 0xb8; 0x40; 0xad; 0x0b]) in assert_norm (List.Tot.length l == 78); createL_mglobal l let test12_expected_shake256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x64; 0x2f; 0x3f; 0x23; 0x5a; 0xc7; 0xe3; 0xd4; 0x34; 0x06; 0x3b; 0x5f; 0xc9; 0x21; 0x5f; 0xc3; 0xf0; 0xe5; 0x91; 0xe2; 0xe7; 0xfd; 0x17; 0x66; 0x8d; 0x1a; 0x0c; 0x87; 0x46; 0x87; 0x35; 0xc2]) in assert_norm (List.Tot.length l == 32); createL_mglobal l val main: unit -> St C.exit_code
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val main: unit -> St C.exit_code
[]
Hacl.Test.SHA3.main
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.HyperStack.ST.St C.exit_code
{ "end_col": 16, "end_line": 600, "start_col": 2, "start_line": 492 }
FStar.HyperStack.ST.Stack
val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True)
[ { "abbrev": false, "full_module": "Hacl.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_sha3 msg_len msg expected224 expected256 expected384 expected512 = push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame()
val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha3 msg_len msg expected224 expected256 expected384 expected512 =
true
null
false
push_frame (); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in sha3_224 msg_len msg test224; sha3_256 msg_len msg test256; sha3_384 msg_len msg test384; sha3_512 msg_len msg test512; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame ()
{ "checked_file": "Hacl.Test.SHA3.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA3.fst" }
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "C.exit", "FStar.Int32.__int_to_t", "Prims.bool", "Prims.op_Negation", "Lib.PrintBuffer.result_compare_display", "Lib.Buffer.to_const", "Lib.Buffer.MUT", "Hacl.SHA3.sha3_512", "Hacl.SHA3.sha3_384", "Hacl.SHA3.sha3_256", "Hacl.SHA3.sha3_224", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Test.SHA3 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.SHA3 #reset-options "--z3rlimit 100 --fuel 0 --ifuel 0" val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True)
false
false
Hacl.Test.SHA3.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_sha3: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True)
[]
Hacl.Test.SHA3.test_sha3
{ "file_name": "code/tests/Hacl.Test.SHA3.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> expected224: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> expected256: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> expected384: Lib.Buffer.lbuffer Lib.IntTypes.uint8 48ul -> expected512: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 42, "start_col": 2, "start_line": 27 }
Prims.Tot
val clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t)
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: parse_fldata_strong_t s sz) -> (x <: t)); }
val clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) =
false
null
false
{ clens_cond = (fun _ -> True); clens_get = (fun (x: parse_fldata_strong_t s sz) -> (x <: t)) }
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Low.Base.Spec.Mkclens", "LowParse.Spec.FLData.parse_fldata_strong_t", "Prims.l_True", "LowParse.Low.Base.Spec.clens" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz inline_for_extraction let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t)
[]
LowParse.Low.FLData.clens_fldata_strong
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> LowParse.Low.Base.Spec.clens (LowParse.Spec.FLData.parse_fldata_strong_t s sz) t
{ "end_col": 64, "end_line": 277, "start_col": 2, "start_line": 276 }
Prims.Tot
val jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 ()
val jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata p sz)) let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata p sz)) =
false
null
false
jump_constant_size (parse_fldata p sz) sz32 ()
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "LowParse.Low.Base.jumper" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata p sz))
[]
LowParse.Low.FLData.jump_fldata
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.Low.Base.jumper (LowParse.Spec.FLData.parse_fldata p sz)
{ "end_col": 48, "end_line": 217, "start_col": 2, "start_line": 217 }
Prims.Tot
val validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32
val validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz)) let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz)) =
false
null
false
if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.validator", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.op_Equality", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserConsumesAll", "LowParse.Low.FLData.validate_fldata_consumes_all", "Prims.bool", "LowParse.Low.FLData.validate_fldata_gen", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz))
[]
LowParse.Low.FLData.validate_fldata
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: LowParse.Low.Base.validator p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.Low.Base.validator (LowParse.Spec.FLData.parse_fldata p sz)
{ "end_col": 36, "end_line": 132, "start_col": 2, "start_line": 130 }
Prims.Tot
val gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) = gaccessor_prop_equiv (parse_fldata_strong s sz) p (clens_fldata_strong s sz) (gaccessor_fldata_strong' s sz); gaccessor_fldata_strong' s sz
val gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) let gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) =
false
null
false
gaccessor_prop_equiv (parse_fldata_strong s sz) p (clens_fldata_strong s sz) (gaccessor_fldata_strong' s sz); gaccessor_fldata_strong' s sz
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.FLData.gaccessor_fldata_strong'", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Low.FLData.clens_fldata_strong", "LowParse.Low.Base.Spec.gaccessor" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz inline_for_extraction let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: parse_fldata_strong_t s sz) -> (x <: t)); } inline_for_extraction let gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) = fun (input: bytes) -> let _ = match parse (parse_fldata_strong s sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 inline_for_extraction let gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz))
[]
LowParse.Low.FLData.gaccessor_fldata_strong
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.FLData.parse_fldata_strong s sz) p (LowParse.Low.FLData.clens_fldata_strong s sz)
{ "end_col": 31, "end_line": 307, "start_col": 2, "start_line": 306 }
Prims.Tot
val gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz
val gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) =
false
null
false
gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.FLData.gaccessor_fldata'", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "LowParse.Low.Base.Spec.clens_id", "LowParse.Low.Base.Spec.gaccessor" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _))
[]
LowParse.Low.FLData.gaccessor_fldata
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.FLData.parse_fldata p sz) p (LowParse.Low.Base.Spec.clens_id t)
{ "end_col": 24, "end_line": 254, "start_col": 2, "start_line": 253 }
Prims.Tot
val gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 )
val gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) =
false
null
false
fun (input: bytes) -> (let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input in 0)
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Bytes.bytes", "Prims.unit", "LowParse.Spec.Base.parse", "LowParse.Spec.FLData.parse_fldata", "LowParse.Spec.Base.consumed_length", "Prims.op_Equality", "LowParse.Spec.Base.parse_strong_prefix", "FStar.Seq.Base.slice", "LowParse.Bytes.byte", "Prims.bool", "LowParse.Low.Base.Spec.gaccessor'", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Low.Base.Spec.clens_id" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _))
[]
LowParse.Low.FLData.gaccessor_fldata'
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.FLData.parse_fldata p sz) p (LowParse.Low.Base.Spec.clens_id t)
{ "end_col": 3, "end_line": 245, "start_col": 2, "start_line": 236 }
Prims.Tot
val jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 ()
val jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata_strong s sz)) let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata_strong s sz)) =
false
null
false
jump_constant_size (parse_fldata_strong s sz) sz32 ()
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Low.Base.jumper" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (jumper (parse_fldata_strong s sz))
[]
LowParse.Low.FLData.jump_fldata_strong
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.Low.Base.jumper (LowParse.Spec.FLData.parse_fldata_strong s sz)
{ "end_col": 55, "end_line": 228, "start_col": 2, "start_line": 228 }
Prims.Tot
val accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos
val accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "LowParse.Low.Base.Spec.clens_id", "LowParse.Low.FLData.gaccessor_fldata", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz inline_for_extraction let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata p sz))
[]
LowParse.Low.FLData.accessor_fldata
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.accessor (LowParse.Low.FLData.gaccessor_fldata p sz)
{ "end_col": 5, "end_line": 266, "start_col": 2, "start_line": 263 }
Prims.Tot
val gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) = fun (input: bytes) -> let _ = match parse (parse_fldata_strong s sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0
val gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) let gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) =
false
null
false
fun (input: bytes) -> let _ = match parse (parse_fldata_strong s sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input in 0
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Bytes.bytes", "Prims.unit", "LowParse.Spec.Base.parse", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Spec.Base.consumed_length", "Prims.op_Equality", "LowParse.Spec.Base.parse_strong_prefix", "FStar.Seq.Base.slice", "LowParse.Bytes.byte", "Prims.bool", "LowParse.Low.Base.Spec.gaccessor'", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Low.FLData.clens_fldata_strong" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz inline_for_extraction let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: parse_fldata_strong_t s sz) -> (x <: t)); } inline_for_extraction let gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz))
[]
LowParse.Low.FLData.gaccessor_fldata_strong'
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.FLData.parse_fldata_strong s sz) p (LowParse.Low.FLData.clens_fldata_strong s sz)
{ "end_col": 5, "end_line": 296, "start_col": 2, "start_line": 288 }
Prims.Tot
val accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (accessor (gaccessor_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata_strong s sz) input pos in pos
val accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata_strong s sz)) let accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata_strong s sz)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = slice_access_eq h (gaccessor_fldata_strong s sz) input pos in pos
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Low.FLData.clens_fldata_strong", "LowParse.Low.FLData.gaccessor_fldata_strong", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos inline_for_extraction let jump_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata p sz)) = jump_constant_size (parse_fldata p sz) sz32 () inline_for_extraction let jump_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_fldata_strong s sz)) = jump_constant_size (parse_fldata_strong s sz) sz32 () let gaccessor_fldata' (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor' (parse_fldata p sz) p (clens_id _)) = fun (input: bytes) -> ( let _ = match parse (parse_fldata p sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 ) let gaccessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (gaccessor (parse_fldata p sz) p (clens_id _)) = gaccessor_prop_equiv (parse_fldata p sz) p (clens_id _) (gaccessor_fldata' p sz); gaccessor_fldata' p sz inline_for_extraction let accessor_fldata (#k: parser_kind) (#t: Type) (p: parser k t { k.parser_kind_subkind == Some ParserStrong } ) (sz: nat) : Tot (accessor (gaccessor_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fldata p sz) input pos in pos let clens_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (clens (parse_fldata_strong_t s sz) t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: parse_fldata_strong_t s sz) -> (x <: t)); } inline_for_extraction let gaccessor_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (gaccessor' (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) = fun (input: bytes) -> let _ = match parse (parse_fldata_strong s sz) input with | None -> () | Some (_, consumed) -> if consumed = sz then parse_strong_prefix p (Seq.slice input 0 sz) input else () in 0 inline_for_extraction let gaccessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat) : Tot (gaccessor (parse_fldata_strong s sz) p (clens_fldata_strong s sz)) = gaccessor_prop_equiv (parse_fldata_strong s sz) p (clens_fldata_strong s sz) (gaccessor_fldata_strong' s sz); gaccessor_fldata_strong' s sz inline_for_extraction let accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong }) (sz: nat)
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (sz: nat) : Tot (accessor (gaccessor_fldata_strong s sz))
[]
LowParse.Low.FLData.accessor_fldata_strong
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sz: Prims.nat -> LowParse.Low.Base.accessor (LowParse.Low.FLData.gaccessor_fldata_strong s sz)
{ "end_col": 5, "end_line": 320, "start_col": 2, "start_line": 317 }
Prims.Tot
val validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata_strong s sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata_strong s sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos
val validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata_strong s sz)) let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata_strong s sz)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in [@@ inline_let ]let _ = valid_facts (parse_fldata_strong s sz) h input (uint64_to_uint32 pos) in validate_fldata v sz sz32 input pos
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.Low.Base.validator", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "LowParse.Low.FLData.validate_fldata", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Low.ErrorCode.uint64_to_uint32", "LowParse.Spec.FLData.parse_fldata", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata_strong s sz))
[]
LowParse.Low.FLData.validate_fldata_strong
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> v: LowParse.Low.Base.validator p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.Low.Base.validator (LowParse.Spec.FLData.parse_fldata_strong s sz)
{ "end_col": 37, "end_line": 207, "start_col": 2, "start_line": 203 }
FStar.Pervasives.Lemma
val valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata p sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos')))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
val valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata p sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'))) let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata p sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'))) =
false
null
true
valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` (U32.uint_to_t sz) in let input' = { base = input.base; len = pos' } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Base.Spec.contents_exact_eq", "Prims.unit", "LowParse.Low.Base.Spec.valid_exact_equiv", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "LowParse.Low.Base.Spec.valid", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.UInt32.v", "LowParse.Low.Base.Spec.valid_exact", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata p sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos')))
[]
LowParse.Low.FLData.valid_fldata_gen_elim
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.FLData.parse_fldata p sz) h input pos) (ensures FStar.UInt32.v pos + sz < 4294967296 /\ (let pos' = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid_exact p h input pos (FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz)) /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.FLData.parse_fldata p sz) h input pos (LowParse.Low.Base.Spec.contents_exact p h input pos pos') pos'))
{ "end_col": 38, "end_line": 62, "start_col": 2, "start_line": 57 }
Prims.Tot
val validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos'
val validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if ((Cast.uint32_to_uint64 input.len) `U64.sub` pos) `U64.lt` (Cast.uint32_to_uint64 sz32) then validator_error_not_enough_data else [@@ inline_let ]let input' = { base = input.base; len = (uint64_to_uint32 pos) `U32.add` sz32 } in [@@ inline_let ]let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic else pos' else pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.validator", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.squash", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserConsumesAll", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "FStar.UInt64.lt", "FStar.UInt64.sub", "FStar.Int.Cast.uint32_to_uint64", "LowParse.Slice.__proj__Mkslice__item__len", "LowParse.Low.ErrorCode.validator_error_not_enough_data", "Prims.bool", "LowParse.Low.ErrorCode.is_error", "Prims.op_Equality", "LowParse.Low.ErrorCode.validator_error_generic", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Low.ErrorCode.uint64_to_uint32", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "LowParse.Spec.FLData.parse_fldata_consumes_all_correct", "LowParse.Slice.bytes_of_slice_from", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll))
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz))
[]
LowParse.Low.FLData.validate_fldata_consumes_all
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: LowParse.Low.Base.validator p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> sq: Prims.squash (Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll) -> LowParse.Low.Base.validator (LowParse.Spec.FLData.parse_fldata p sz)
{ "end_col": 13, "end_line": 119, "start_col": 2, "start_line": 102 }
FStar.Pervasives.Lemma
val valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos')))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
val valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'))) let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'))) =
false
null
true
valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` (U32.uint_to_t sz) in let input' = { base = input.base; len = pos' } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Base.Spec.contents_exact_eq", "Prims.unit", "LowParse.Low.Base.Spec.valid_exact_equiv", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.UInt32.v", "LowParse.Low.Base.Spec.valid_exact", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos'
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos')))
[]
LowParse.Low.FLData.valid_fldata_gen
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.UInt32.v pos + sz < 4294967296 /\ LowParse.Low.Base.Spec.valid_exact p h input pos (FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz))) (ensures FStar.UInt32.v pos + sz < 4294967296 /\ (let pos' = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.FLData.parse_fldata p sz) h input pos (LowParse.Low.Base.Spec.contents_exact p h input pos pos') pos'))
{ "end_col": 38, "end_line": 36, "start_col": 2, "start_line": 31 }
FStar.Pervasives.Lemma
val valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata_strong s sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'))))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' )))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
val valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata_strong s sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos')))) let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata_strong s sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos')))) =
false
null
true
valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` (U32.uint_to_t sz) in let input' = { base = input.base; len = pos' } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Base.Spec.contents_exact_eq", "Prims.unit", "LowParse.Low.Base.Spec.valid_exact_equiv", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "LowParse.Low.Base.Spec.valid", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.UInt32.v", "LowParse.Low.Base.Spec.valid_exact", "Prims.eq2", "FStar.Seq.Base.length", "LowParse.Spec.Base.serialize", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata_strong s sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_fldata_strong_gen_elim (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid (parse_fldata_strong s sz) h input pos)) (ensures (U32.v pos + sz < 4294967296 /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'))))
[]
LowParse.Low.FLData.valid_fldata_strong_gen_elim
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.FLData.parse_fldata_strong s sz) h input pos) (ensures FStar.UInt32.v pos + sz < 4294967296 /\ (let pos' = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid_exact p h input pos (FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz)) /\ (let x = LowParse.Low.Base.Spec.contents_exact p h input pos pos' in FStar.Seq.Base.length (LowParse.Spec.Base.serialize s x) == sz /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.FLData.parse_fldata_strong s sz) h input pos x pos')))
{ "end_col": 38, "end_line": 191, "start_col": 2, "start_line": 186 }
Prims.Tot
val validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos'
val validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz)) let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if ((Cast.uint32_to_uint64 input.len) `U64.sub` pos) `U64.lt` (Cast.uint32_to_uint64 sz32) then validator_error_not_enough_data else [@@ inline_let ]let input' = { base = input.base; len = (uint64_to_uint32 pos) `U32.add` sz32 } in [@@ inline_let ]let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic else pos' else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.validator", "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "FStar.UInt64.lt", "FStar.UInt64.sub", "FStar.Int.Cast.uint32_to_uint64", "LowParse.Slice.__proj__Mkslice__item__len", "LowParse.Low.ErrorCode.validator_error_not_enough_data", "Prims.bool", "LowParse.Low.ErrorCode.is_error", "Prims.op_Equality", "LowParse.Low.ErrorCode.validator_error_generic", "Prims.op_disEquality", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Low.ErrorCode.uint64_to_uint32", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } )
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t{U32.v sz32 == sz}) : Tot (validator (parse_fldata p sz))
[]
LowParse.Low.FLData.validate_fldata_gen
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: LowParse.Low.Base.validator p -> sz: Prims.nat -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz} -> LowParse.Low.Base.validator (LowParse.Spec.FLData.parse_fldata p sz)
{ "end_col": 13, "end_line": 90, "start_col": 2, "start_line": 73 }
FStar.Pervasives.Lemma
val valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos')))
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos' ))) = valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
val valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'))) let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'))) =
false
null
true
valid_facts (parse_fldata_strong s sz) h input pos; let pos' = pos `U32.add` (U32.uint_to_t sz) in let input' = { base = input.base; len = pos' } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos'
{ "checked_file": "LowParse.Low.FLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.FLData.fst" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Base.Spec.contents_exact_eq", "Prims.unit", "LowParse.Low.Base.Spec.valid_exact_equiv", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Slice.Mkslice", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.UInt32.v", "LowParse.Low.Base.Spec.valid_exact", "Prims.squash", "Prims.eq2", "FStar.Seq.Base.length", "LowParse.Spec.Base.serialize", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.FLData include LowParse.Low.Combinators include LowParse.Spec.FLData module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_fldata_gen (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' let valid_fldata_gen_elim (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid (parse_fldata p sz) h input pos )) (ensures ( U32.v pos + sz < 4294967296 /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ valid_content_pos (parse_fldata p sz) h input pos (contents_exact p h input pos pos') pos' ))) = valid_facts (parse_fldata p sz) h input pos; let pos' = pos `U32.add` U32.uint_to_t sz in let input' = { base = input.base; len = pos'; } in valid_facts p h input' pos; valid_exact_equiv p h input pos pos'; contents_exact_eq p h input pos pos' inline_for_extraction let validate_fldata_gen (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else if pos' `U64.sub` pos <> Cast.uint32_to_uint64 sz32 then validator_error_generic else pos' inline_for_extraction let validate_fldata_consumes_all (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) (sq: squash (k.parser_kind_subkind == Some ParserConsumesAll)) : Tot (validator (parse_fldata p sz)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_fldata p sz) h input (uint64_to_uint32 pos); parse_fldata_consumes_all_correct p sz (bytes_of_slice_from h input (uint64_to_uint32 pos)) in if (Cast.uint32_to_uint64 input.len `U64.sub` pos) `U64.lt` Cast.uint32_to_uint64 sz32 then validator_error_not_enough_data else [@inline_let] let input' = { base = input.base; len = uint64_to_uint32 pos `U32.add` sz32; } in [@inline_let] let _ = valid_facts p h input' (uint64_to_uint32 pos) in let pos' = v input' pos in if is_error pos' then if pos' = validator_error_not_enough_data then validator_error_generic (* the size was fixed ahead of time, so if the parser runs out of data, then that size was wrong in the first place. *) else pos' // error propagation else pos' inline_for_extraction let validate_fldata (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p) (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (validator (parse_fldata p sz)) = if k.parser_kind_subkind = Some ParserConsumesAll then validate_fldata_consumes_all v sz sz32 () else validate_fldata_gen v sz sz32 let valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) )) (ensures ( U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` U32.uint_to_t sz) /\ ( let pos' = pos `U32.add` U32.uint_to_t sz in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos'
false
false
LowParse.Low.FLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_fldata_strong_gen (#k: parser_kind) (#t: Type0) (#p: parser k t) (s: serializer p) (sz: nat) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) )) (ensures (U32.v pos + sz < 4294967296 /\ valid_exact p h input pos (pos `U32.add` (U32.uint_to_t sz)) /\ (let pos' = pos `U32.add` (U32.uint_to_t sz) in let x = contents_exact p h input pos pos' in Seq.length (serialize s x) == sz /\ valid_content_pos (parse_fldata_strong s sz) h input pos x pos')))
[]
LowParse.Low.FLData.valid_fldata_strong_gen
{ "file_name": "src/lowparse/LowParse.Low.FLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.UInt32.v pos + sz < 4294967296 /\ LowParse.Low.Base.Spec.valid_exact p h input pos (FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz))) (ensures FStar.UInt32.v pos + sz < 4294967296 /\ LowParse.Low.Base.Spec.valid_exact p h input pos (FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz)) /\ (let pos' = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in let x = LowParse.Low.Base.Spec.contents_exact p h input pos pos' in FStar.Seq.Base.length (LowParse.Spec.Base.serialize s x) == sz /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.FLData.parse_fldata_strong s sz) h input pos x pos'))
{ "end_col": 38, "end_line": 162, "start_col": 2, "start_line": 157 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true })
let nonempty_set (t: eqtype) =
false
null
false
(s: Set.set t {exists x. set_def s x == true})
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.Set.set", "Prims.l_Exists", "Prims.eq2", "Prims.bool", "Steel.ST.C.Types.UserStruct.set_def" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract
false
true
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonempty_set : t: Prims.eqtype -> Type0
[]
Steel.ST.C.Types.UserStruct.nonempty_set
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.eqtype -> Type0
{ "end_col": 51, "end_line": 20, "start_col": 2, "start_line": 20 }
Prims.Tot
val set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s
val set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool =
false
null
false
FStar.Set.mem x s
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.Set.set", "FStar.Set.mem", "Prims.bool" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t)
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool
[]
Steel.ST.C.Types.UserStruct.set_def
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
s: FStar.Set.set t -> x: t -> Prims.bool
{ "end_col": 19, "end_line": 16, "start_col": 2, "start_line": 16 }
Prims.Tot
val field_t (s: Set.set string) : Tot eqtype
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s })
val field_t (s: Set.set string) : Tot eqtype let field_t (s: Set.set string) : Tot eqtype =
false
null
false
(f: string{Set.mem f s})
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "total" ]
[ "FStar.Set.set", "Prims.string", "Prims.b2t", "FStar.Set.mem", "Prims.eqtype" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"]
false
true
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val field_t (s: Set.set string) : Tot eqtype
[]
Steel.ST.C.Types.UserStruct.field_t
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
s: FStar.Set.set Prims.string -> Prims.eqtype
{ "end_col": 29, "end_line": 33, "start_col": 2, "start_line": 33 }
Prims.Tot
val set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t = sd.mk (set_aux sd x f v)
val set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t =
false
null
false
sd.mk (set_aux sd x f v)
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "total" ]
[ "Steel.ST.C.Types.UserStruct.struct_def", "Steel.ST.C.Types.UserStruct.field_t", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__mk", "Steel.ST.C.Types.UserStruct.set_aux" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x [@@noextract_to "krml"] let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') = if f = f' then v else sd.get x f' [@@noextract_to "krml"]
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t
[]
Steel.ST.C.Types.UserStruct.set
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
sd: Steel.ST.C.Types.UserStruct.struct_def t -> x: t -> f: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> v: Mkfield_description_gen_t?.fd_type (Mkstruct_def?.field_desc sd) f -> t
{ "end_col": 26, "end_line": 61, "start_col": 2, "start_line": 61 }
Prims.Pure
val set_snoc (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q))))
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a
val set_snoc (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)))) let set_snoc (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)))) =
false
null
false
q `FStar.Set.union` (FStar.Set.singleton a)
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[]
[ "Prims.eqtype", "FStar.Set.set", "FStar.Set.union", "FStar.Set.singleton", "Steel.ST.C.Types.UserStruct.nonempty_set", "Prims.l_True", "Prims.l_Forall", "Prims.eq2", "Prims.bool", "FStar.Set.mem", "Prims.op_BarBar", "Prims.op_Equality" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q))
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_snoc (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q))))
[]
Steel.ST.C.Types.UserStruct.set_snoc
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
q: FStar.Set.set t -> a: t -> Prims.Pure (Steel.ST.C.Types.UserStruct.nonempty_set t)
{ "end_col": 43, "end_line": 29, "start_col": 2, "start_line": 29 }
FStar.Pervasives.Lemma
val nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s). True))
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x
val nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s). True)) let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s). True)) =
false
null
true
Classical.exists_intro (fun (_: field_t s) -> True) x
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "lemma" ]
[ "Prims.string", "FStar.Set.set", "FStar.Classical.exists_intro", "Steel.ST.C.Types.UserStruct.field_t", "Prims.l_True", "Prims.unit", "Prims.b2t", "FStar.Set.mem", "Prims.squash", "Prims.l_Exists", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s))
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s). True))
[]
Steel.ST.C.Types.UserStruct.nonempty_set_nonempty_type
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: Prims.string -> s: FStar.Set.set Prims.string -> FStar.Pervasives.Lemma (requires FStar.Set.mem x s) (ensures exists (x: Steel.ST.C.Types.UserStruct.field_t s). Prims.l_True)
{ "end_col": 55, "end_line": 51, "start_col": 2, "start_line": 51 }
Prims.Tot
val set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f')
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') = if f = f' then v else sd.get x f'
val set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') =
false
null
false
if f = f' then v else sd.get x f'
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "total" ]
[ "Steel.ST.C.Types.UserStruct.struct_def", "Steel.ST.C.Types.UserStruct.field_t", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc", "Prims.op_Equality", "Prims.bool", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x [@@noextract_to "krml"] let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields)
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f')
[]
Steel.ST.C.Types.UserStruct.set_aux
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
sd: Steel.ST.C.Types.UserStruct.struct_def t -> x: t -> f: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> v: Mkfield_description_gen_t?.fd_type (Mkstruct_def?.field_desc sd) f -> f': Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> Mkfield_description_gen_t?.fd_type (Mkstruct_def?.field_desc sd) f'
{ "end_col": 35, "end_line": 57, "start_col": 2, "start_line": 57 }
FStar.Pervasives.Lemma
val get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')]
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')] = sd.get_mk (set_aux sd x f v) f'
val get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')] let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')] =
false
null
true
sd.get_mk (set_aux sd x f v) f'
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[ "lemma" ]
[ "Steel.ST.C.Types.UserStruct.struct_def", "Steel.ST.C.Types.UserStruct.field_t", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get_mk", "Steel.ST.C.Types.UserStruct.set_aux", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get", "Steel.ST.C.Types.UserStruct.set", "Prims.op_Equality", "Prims.bool", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x [@@noextract_to "krml"] let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') = if f = f' then v else sd.get x f' [@@noextract_to "krml"] let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t = sd.mk (set_aux sd x f v) let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f'))
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')]
[]
Steel.ST.C.Types.UserStruct.get_set
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
sd: Steel.ST.C.Types.UserStruct.struct_def t -> x: t -> f: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> v: Mkfield_description_gen_t?.fd_type (Mkstruct_def?.field_desc sd) f -> f': Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> FStar.Pervasives.Lemma (ensures Mkstruct_def?.get sd (Steel.ST.C.Types.UserStruct.set sd x f v) f' == (match f = f' with | true -> v | _ -> Mkstruct_def?.get sd x f')) [SMTPat (Mkstruct_def?.get sd (Steel.ST.C.Types.UserStruct.set sd x f v) f')]
{ "end_col": 33, "end_line": 66, "start_col": 2, "start_line": 66 }
Steel.ST.Effect.Ghost.STGhost
val unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v')) (fun s' -> (has_struct_field r field r') `star` (pts_to r s')) (sd.get v field == unknown (sd.field_desc.fd_typedef field)) (fun s' -> Ghost.reveal s' == set sd v field v')
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (has_struct_field r field r' `star` pts_to r v `star` pts_to r' v') (fun s' -> has_struct_field r field r' `star` pts_to r s') ( sd.get v field == unknown (sd.field_desc.fd_typedef field) ) (fun s' -> Ghost.reveal s' == set sd v field v') = unstruct_field r field r'; _
val unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v')) (fun s' -> (has_struct_field r field r') `star` (pts_to r s')) (sd.get v field == unknown (sd.field_desc.fd_typedef field)) (fun s' -> Ghost.reveal s' == set sd v field v') let unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v')) (fun s' -> (has_struct_field r field r') `star` (pts_to r s')) (sd.get v field == unknown (sd.field_desc.fd_typedef field)) (fun s' -> Ghost.reveal s' == set sd v field v') =
true
null
false
unstruct_field r field r'; _
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[]
[ "Steel.Memory.inames", "Steel.ST.C.Types.UserStruct.struct_def", "FStar.Ghost.erased", "Steel.ST.C.Types.Base.ref", "Steel.ST.C.Types.UserStruct.struct_typedef", "Steel.ST.C.Types.UserStruct.field_t", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_typedef", "FStar.Ghost.hide", "Steel.ST.C.Types.UserStruct.set", "FStar.Ghost.reveal", "Prims.unit", "Steel.ST.C.Types.UserStruct.unstruct_field", "Steel.Effect.Common.star", "Steel.ST.C.Types.UserStruct.has_struct_field", "Steel.ST.C.Types.Base.pts_to", "Steel.Effect.Common.vprop", "Prims.eq2", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get", "Steel.ST.C.Types.Base.unknown", "Prims.l_True" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x [@@noextract_to "krml"] let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') = if f = f' then v else sd.get x f' [@@noextract_to "krml"] let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t = sd.mk (set_aux sd x f v) let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')] = sd.get_mk (set_aux sd x f v) f' [@@noextract_to "krml"] val struct_typedef (#t: Type) (sd: struct_def t) : Tot (typedef t) val has_struct_field (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : Tot vprop val has_struct_field_dup (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r') (fun _ -> has_struct_field r field r' `star` has_struct_field r field r') val has_struct_field_inj (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r1 r2: ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r1 `star` has_struct_field r field r2) (fun _ -> has_struct_field r field r1 `star` has_struct_field r field r2 `star` ref_equiv r1 r2) val has_struct_field_equiv_from (#opened: _) (#t: Type) (#sd: struct_def t) (r1: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) (r2: ref (struct_typedef sd)) : STGhostT unit opened (ref_equiv r1 r2 `star` has_struct_field r1 field r') (fun _ -> ref_equiv r1 r2 `star` has_struct_field r2 field r') val has_struct_field_equiv_to (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r1' r2': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (ref_equiv r1' r2' `star` has_struct_field r field r1') (fun _ -> ref_equiv r1' r2' `star` has_struct_field r field r2') val ghost_struct_field_focus (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r' `star` pts_to r v) (fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field)) val ghost_struct_field (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STGhostT (Ghost.erased (ref (sd.field_desc.fd_typedef field))) opened (pts_to r v) (fun r' -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field)) [@@noextract_to "krml"] // primitive val struct_field0 (#t: Type) (t': Type0) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (td': typedef t' { t' == sd.field_desc.fd_type field /\ td' == sd.field_desc.fd_typedef field }) : STT (ref td') (pts_to r v) (fun r' -> has_struct_field r field (coerce_eq () r') `star` pts_to r (set sd (Ghost.reveal v) field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #_ #(sd.field_desc.fd_typedef field) (coerce_eq () r') (sd.get (Ghost.reveal v) field)) inline_for_extraction [@@noextract_to "krml"] // primitive let struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field) `star` has_struct_field r field r') = struct_field0 (norm norm_field_steps (sd.field_desc.fd_type field)) r field (sd.field_desc.fd_typedef field) val unstruct_field (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost unit opened (has_struct_field r field r' `star` pts_to r v `star` pts_to r' v') (fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field v')) ( sd.get v field == unknown (sd.field_desc.fd_typedef field) ) (fun _ -> True) let unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (has_struct_field r field r' `star` pts_to r v `star` pts_to r' v') (fun s' -> has_struct_field r field r' `star` pts_to r s') ( sd.get v field == unknown (sd.field_desc.fd_typedef field) )
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unstruct_field_alt (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (#v': Ghost.erased (sd.field_desc.fd_type field)) (r': ref (sd.field_desc.fd_typedef field)) : STGhost (Ghost.erased t) opened (((has_struct_field r field r') `star` (pts_to r v)) `star` (pts_to r' v')) (fun s' -> (has_struct_field r field r') `star` (pts_to r s')) (sd.get v field == unknown (sd.field_desc.fd_typedef field)) (fun s' -> Ghost.reveal s' == set sd v field v')
[]
Steel.ST.C.Types.UserStruct.unstruct_field_alt
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.UserStruct.struct_typedef sd) -> field: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> r': Steel.ST.C.Types.Base.ref (Mkfield_description_gen_t?.fd_typedef (Mkstruct_def?.field_desc sd) field) -> Steel.ST.Effect.Ghost.STGhost (FStar.Ghost.erased t)
{ "end_col": 3, "end_line": 216, "start_col": 2, "start_line": 215 }
Steel.ST.Effect.STT
val struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> ((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field)))) `star` (pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field))) `star` (has_struct_field r field r'))
[ { "abbrev": true, "full_module": "FStar.Set", "short_module": "Set" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field) `star` has_struct_field r field r') = struct_field0 (norm norm_field_steps (sd.field_desc.fd_type field)) r field (sd.field_desc.fd_typedef field)
val struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> ((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field)))) `star` (pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field))) `star` (has_struct_field r field r')) let struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> ((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field)))) `star` (pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field))) `star` (has_struct_field r field r')) =
true
null
false
struct_field0 (norm norm_field_steps (sd.field_desc.fd_type field)) r field (sd.field_desc.fd_typedef field)
{ "checked_file": "Steel.ST.C.Types.UserStruct.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.UserStruct.fsti" }
[]
[ "Steel.ST.C.Types.UserStruct.struct_def", "FStar.Ghost.erased", "Steel.ST.C.Types.Base.ref", "Steel.ST.C.Types.UserStruct.struct_typedef", "Steel.ST.C.Types.UserStruct.field_t", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__fields", "Steel.ST.C.Types.UserStruct.struct_field0", "FStar.Pervasives.norm", "Steel.ST.C.Types.Base.norm_field_steps", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__field_desc", "Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_typedef", "Steel.ST.C.Types.Base.pts_to", "Steel.Effect.Common.star", "FStar.Ghost.hide", "Steel.ST.C.Types.UserStruct.set", "FStar.Ghost.reveal", "Steel.ST.C.Types.Base.unknown", "Steel.ST.C.Types.UserStruct.__proj__Mkstruct_def__item__get", "Steel.ST.C.Types.UserStruct.has_struct_field", "Steel.Effect.Common.vprop" ]
[]
module Steel.ST.C.Types.UserStruct open Steel.ST.Util open Steel.ST.C.Types.Struct.Aux module Set = FStar.Set (* This library allows the user to define their own struct type, with a constructor from field values, and a destructor to field values for each field. This may be necessary for recursive structs *) let set_def (#t: eqtype) (s: FStar.Set.set t) (x: t) : Tot bool = FStar.Set.mem x s noextract let nonempty_set (t: eqtype) = (s: Set.set t { exists x . set_def s x == true }) noextract let set_snoc // for associativity reasons (#t: eqtype) (q: FStar.Set.set t) (a: t) : Pure (nonempty_set t) (requires True) (ensures (fun s -> (forall (x: t). {:pattern FStar.Set.mem x s} FStar.Set.mem x s == (x = a || FStar.Set.mem x q)) )) = q `FStar.Set.union` FStar.Set.singleton a [@@noextract_to "krml"] let field_t (s: Set.set string) : Tot eqtype = (f: string { Set.mem f s }) [@@noextract_to "krml"; norm_field_attr] inline_for_extraction // for field_desc.fd_type noeq type struct_def (t: Type) = { fields: Set.set string; field_desc: field_description_gen_t (field_t fields); mk: ((f: field_t fields) -> Tot (field_desc.fd_type f)) -> Tot t; get: (t -> (f: field_t fields) -> Tot (field_desc.fd_type f)); get_mk: (phi: ((f: field_t fields) -> Tot (field_desc.fd_type f))) -> (f: field_t fields) -> Lemma (get (mk phi) f == phi f); extensionality: (x1: t) -> (x2: t) -> ((f: field_t fields) -> Lemma (get x1 f == get x2 f)) -> Lemma (x1 == x2); } let nonempty_set_nonempty_type (x: string) (s: Set.set string) : Lemma (requires (x `Set.mem` s)) (ensures (exists (x: field_t s) . True)) = Classical.exists_intro (fun (_: field_t s) -> True) x [@@noextract_to "krml"] let set_aux (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f': field_t sd.fields) : Tot (sd.field_desc.fd_type f') = if f = f' then v else sd.get x f' [@@noextract_to "krml"] let set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) : Tot t = sd.mk (set_aux sd x f v) let get_set (#t: Type) (sd: struct_def t) (x: t) (f: field_t sd.fields) (v: sd.field_desc.fd_type f) (f' : field_t sd.fields) : Lemma (sd.get (set sd x f v) f' == (if f = f' then v else sd.get x f')) [SMTPat (sd.get (set sd x f v) f')] = sd.get_mk (set_aux sd x f v) f' [@@noextract_to "krml"] val struct_typedef (#t: Type) (sd: struct_def t) : Tot (typedef t) val has_struct_field (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : Tot vprop val has_struct_field_dup (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r') (fun _ -> has_struct_field r field r' `star` has_struct_field r field r') val has_struct_field_inj (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r1 r2: ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r1 `star` has_struct_field r field r2) (fun _ -> has_struct_field r field r1 `star` has_struct_field r field r2 `star` ref_equiv r1 r2) val has_struct_field_equiv_from (#opened: _) (#t: Type) (#sd: struct_def t) (r1: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) (r2: ref (struct_typedef sd)) : STGhostT unit opened (ref_equiv r1 r2 `star` has_struct_field r1 field r') (fun _ -> ref_equiv r1 r2 `star` has_struct_field r2 field r') val has_struct_field_equiv_to (#opened: _) (#t: Type) (#sd: struct_def t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r1' r2': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (ref_equiv r1' r2' `star` has_struct_field r field r1') (fun _ -> ref_equiv r1' r2' `star` has_struct_field r field r2') val ghost_struct_field_focus (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (r': ref (sd.field_desc.fd_typedef field)) : STGhostT unit opened (has_struct_field r field r' `star` pts_to r v) (fun _ -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field)) val ghost_struct_field (#opened: _) (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STGhostT (Ghost.erased (ref (sd.field_desc.fd_typedef field))) opened (pts_to r v) (fun r' -> has_struct_field r field r' `star` pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to r' (sd.get v field)) [@@noextract_to "krml"] // primitive val struct_field0 (#t: Type) (t': Type0) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) (td': typedef t' { t' == sd.field_desc.fd_type field /\ td' == sd.field_desc.fd_typedef field }) : STT (ref td') (pts_to r v) (fun r' -> has_struct_field r field (coerce_eq () r') `star` pts_to r (set sd (Ghost.reveal v) field (unknown (sd.field_desc.fd_typedef field))) `star` pts_to #_ #(sd.field_desc.fd_typedef field) (coerce_eq () r') (sd.get (Ghost.reveal v) field)) inline_for_extraction [@@noextract_to "krml"] // primitive let struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v)
false
false
Steel.ST.C.Types.UserStruct.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val struct_field (#t: Type) (#sd: struct_def t) (#v: Ghost.erased t) (r: ref (struct_typedef sd)) (field: field_t sd.fields) : STT (ref #(norm norm_field_steps (sd.field_desc.fd_type field)) (sd.field_desc.fd_typedef field)) (pts_to r v) (fun r' -> ((pts_to r (set sd v field (unknown (sd.field_desc.fd_typedef field)))) `star` (pts_to #(norm norm_field_steps (sd.field_desc.fd_type field)) r' (sd.get v field))) `star` (has_struct_field r field r'))
[]
Steel.ST.C.Types.UserStruct.struct_field
{ "file_name": "lib/steel/c/Steel.ST.C.Types.UserStruct.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.UserStruct.struct_typedef sd) -> field: Steel.ST.C.Types.UserStruct.field_t (Mkstruct_def?.fields sd) -> Steel.ST.Effect.STT (Steel.ST.C.Types.Base.ref (Mkfield_description_gen_t?.fd_typedef (Mkstruct_def?.field_desc sd) field))
{ "end_col": 36, "end_line": 180, "start_col": 2, "start_line": 176 }
Prims.Tot
val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm
[ { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm let null (#a: Type u#a) (#pcm: pcm a) : ref a pcm =
false
null
false
core_ref_null
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.Heap.core_ref_null", "Steel.Heap.ref" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm
[]
Steel.Heap.null
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Steel.Heap.ref a pcm
{ "end_col": 63, "end_line": 53, "start_col": 50, "start_line": 53 }
Prims.Tot
val ref (a: Type u#a) (pcm: pcm a) : Type u#0
[ { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
val ref (a: Type u#a) (pcm: pcm a) : Type u#0 let ref (a: Type u#a) (pcm: pcm a) : Type u#0 =
false
null
false
core_ref
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.Heap.core_ref" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ref (a: Type u#a) (pcm: pcm a) : Type u#0
[]
Steel.Heap.ref
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> pcm: FStar.PCM.pcm a -> Type0
{ "end_col": 54, "end_line": 47, "start_col": 46, "start_line": 47 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m
let equiv (p1 p2: slprop) =
false
null
false
forall m. interp p1 m <==> interp p2 m
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Prims.l_Forall", "Steel.Heap.heap", "Prims.l_iff", "Steel.Heap.interp", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *)
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val equiv : p1: Steel.Heap.slprop -> p2: Steel.Heap.slprop -> Prims.logical
[]
Steel.Heap.equiv
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p1: Steel.Heap.slprop -> p2: Steel.Heap.slprop -> Prims.logical
{ "end_col": 40, "end_line": 158, "start_col": 2, "start_line": 158 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x))
let pre_action (fp: slprop u#a) (a: Type u#b) (fp': (a -> slprop u#a)) =
false
null
false
full_hheap fp -> (x: a & full_hheap (fp' x))
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.full_hheap", "Prims.dtuple2" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *)
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pre_action : fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
[]
Steel.Heap.pre_action
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
{ "end_col": 45, "end_line": 406, "start_col": 2, "start_line": 406 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r)
let ptr (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) =
false
null
false
h_exists (pts_to r)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.Heap.ref", "Steel.Heap.h_exists", "Steel.Heap.pts_to", "Steel.Heap.slprop" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *)
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ptr : r: Steel.Heap.ref a pcm -> Steel.Heap.slprop
[]
Steel.Heap.ptr
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Heap.ref a pcm -> Steel.Heap.slprop
{ "end_col": 23, "end_line": 241, "start_col": 4, "start_line": 241 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) }
let hprop (fp: slprop u#a) =
false
null
false
q: (heap u#a -> prop) {forall (h0: heap{interp fp h0}) (h1: heap{disjoint h0 h1}). q h0 <==> q (join h0 h1)}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.heap", "Prims.prop", "Prims.l_Forall", "Steel.Heap.interp", "Steel.Heap.disjoint", "Prims.l_iff", "Steel.Heap.join" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *)
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hprop : fp: Steel.Heap.slprop -> Type
[]
Steel.Heap.hprop
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp: Steel.Heap.slprop -> Type
{ "end_col": 3, "end_line": 148, "start_col": 2, "start_line": 145 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p }
let a_heap_prop =
false
null
false
p: (heap -> prop){heap_prop_is_affine p}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.heap", "Prims.prop", "Steel.Heap.heap_prop_is_affine" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val a_heap_prop : Type
[]
Steel.Heap.a_heap_prop
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Type
{ "end_col": 60, "end_line": 117, "start_col": 18, "start_line": 117 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1)
let action_related_heaps (frame: slprop) (h0 h1: full_heap) =
false
null
false
heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp: hprop frame). hp h0 == hp h1)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.full_heap", "Prims.l_and", "Steel.Heap.heap_evolves", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Steel.Heap.free_above_addr", "Steel.Heap.hprop", "Prims.eq2", "Prims.prop", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_related_heaps : frame: Steel.Heap.slprop -> h0: Steel.Heap.full_heap -> h1: Steel.Heap.full_heap -> Prims.logical
[]
Steel.Heap.action_related_heaps
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
frame: Steel.Heap.slprop -> h0: Steel.Heap.full_heap -> h1: Steel.Heap.full_heap -> Prims.logical
{ "end_col": 43, "end_line": 418, "start_col": 2, "start_line": 416 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let hheap (p:slprop u#a) = m:heap u#a {interp p m}
let hheap (p: slprop u#a) =
false
null
false
m: heap u#a {interp p m}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.heap", "Steel.Heap.interp" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) }
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hheap : p: Steel.Heap.slprop -> Type
[]
Steel.Heap.hheap
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.Heap.slprop -> Type
{ "end_col": 50, "end_line": 151, "start_col": 27, "start_line": 151 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let full_heap = h:heap { full_heap_pred h }
let full_heap =
false
null
false
h: heap{full_heap_pred h}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.heap", "Steel.Heap.full_heap_pred" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val full_heap : Type
[]
Steel.Heap.full_heap
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Type
{ "end_col": 43, "end_line": 379, "start_col": 16, "start_line": 379 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f }
let action (fp: slprop u#b) (a: Type u#a) (fp': (a -> slprop u#b)) =
false
null
false
f: pre_action fp a fp' {is_frame_preserving f}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.pre_action", "Steel.Heap.is_frame_preserving" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *)
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action : fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
[]
Steel.Heap.action
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
{ "end_col": 48, "end_line": 441, "start_col": 2, "start_line": 441 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let stronger (p q:slprop) = forall h. interp p h ==> interp q h
let stronger (p q: slprop) =
false
null
false
forall h. interp p h ==> interp q h
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Prims.l_Forall", "Steel.Heap.heap", "Prims.l_imp", "Steel.Heap.interp", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *)
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val stronger : p: Steel.Heap.slprop -> q: Steel.Heap.slprop -> Prims.logical
[]
Steel.Heap.stronger
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.Heap.slprop -> q: Steel.Heap.slprop -> Prims.logical
{ "end_col": 37, "end_line": 363, "start_col": 2, "start_line": 363 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let full_hheap fp = h:hheap fp { full_heap_pred h }
let full_hheap fp =
false
null
false
h: hheap fp {full_heap_pred h}
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.hheap", "Steel.Heap.full_heap_pred" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h }
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val full_hheap : fp: Steel.Heap.slprop -> Type
[]
Steel.Heap.full_hheap
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp: Steel.Heap.slprop -> Type
{ "end_col": 51, "end_line": 381, "start_col": 20, "start_line": 381 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let frame_related_heaps (h0 h1:full_heap) (fp0 fp1 frame:slprop) (allocates:bool) = interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp:hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr))
let frame_related_heaps (h0 h1: full_heap) (fp0 fp1 frame: slprop) (allocates: bool) =
false
null
false
interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp: hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr))
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.full_heap", "Steel.Heap.slprop", "Prims.bool", "Prims.l_imp", "Steel.Heap.interp", "Steel.Heap.star", "Prims.l_and", "Steel.Heap.heap_evolves", "Prims.l_Forall", "Steel.Heap.hprop", "Prims.eq2", "Prims.prop", "Prims.b2t", "Prims.op_Negation", "Prims.nat", "Steel.Heap.free_above_addr", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1) (** Two heaps [h0] and [h1] are frame-related if you can get from [h0] to [h1] with a frame-preserving update. *)
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frame_related_heaps : h0: Steel.Heap.full_heap -> h1: Steel.Heap.full_heap -> fp0: Steel.Heap.slprop -> fp1: Steel.Heap.slprop -> frame: Steel.Heap.slprop -> allocates: Prims.bool -> Prims.logical
[]
Steel.Heap.frame_related_heaps
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
h0: Steel.Heap.full_heap -> h1: Steel.Heap.full_heap -> fp0: Steel.Heap.slprop -> fp1: Steel.Heap.slprop -> frame: Steel.Heap.slprop -> allocates: Prims.bool -> Prims.logical
{ "end_col": 89, "end_line": 469, "start_col": 2, "start_line": 465 }
Prims.Tot
val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let is_frame_monotonic #a (p : a -> slprop) : prop = forall x y m frame. interp (p x `star` frame) m /\ interp (p y) m ==> interp (p y `star` frame) m
val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop let is_frame_monotonic #a (p: (a -> slprop)) : prop =
false
null
false
forall x y m frame. interp ((p x) `star` frame) m /\ interp (p y) m ==> interp ((p y) `star` frame) m
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Prims.l_Forall", "Steel.Heap.heap", "Prims.l_imp", "Prims.l_and", "Steel.Heap.interp", "Steel.Heap.star", "Prims.prop" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1) (** Two heaps [h0] and [h1] are frame-related if you can get from [h0] to [h1] with a frame-preserving update. *) let frame_related_heaps (h0 h1:full_heap) (fp0 fp1 frame:slprop) (allocates:bool) = interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp:hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr)) (** A frame-preserving action applied on [h0] produces an [h1] such that [h0] and [h1] are frame-related *) let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) ($f:action fp a fp') (frame:slprop) (h0:full_hheap (fp `star` frame)) : Lemma ( affine_star fp frame h0; let (| x, h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false ) = affine_star fp frame h0; emp_unit fp (** [sel] is a ghost read of the value contained in a heap reference *) val sel (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (m:full_hheap (ptr r)) : a (** [sel_v] is a ghost read of the value contained in a heap reference *) val sel_v (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (v:erased a) (m:full_hheap (pts_to r v)) : v':a{ compatible pcm v v' /\ pcm.refine v' /\ interp (ptr r) m /\ v' == sel r m } (** [sel] respect [pts_to] *) val sel_lemma (#a:_) (#pcm:_) (r:ref a pcm) (m:full_hheap (ptr r)) : Lemma (interp (pts_to r (sel r m)) m) let witnessed_ref (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop) (h:full_heap) = interp (ptr r) h /\ fact (sel r h) val witnessed_ref_stability (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop) : Lemma (requires FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)) (ensures FStar.Preorder.stable (witnessed_ref r fact) heap_evolves) (** The action variant of [sel], returning the "true" value inside the heap. This "true" value can be different of the [pts_to] value you assumed at the beginning, because of the PCM structure *) val sel_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : action (pts_to r v0) (v:a{compatible pcm v0 v}) (fun _ -> pts_to r v0) (** A version of select that incorporates a ghost update of local knowledge of a ref cell based on the value that was read *) val select_refine (#a:_) (#p:_) (r:ref a p) (x:erased a) (f:(v:a{compatible p x v} -> GTot (y:a{compatible p y v /\ FStar.PCM.frame_compatible p x v y}))) : action (pts_to r x) (v:a{compatible p x v /\ p.refine v}) (fun v -> pts_to r (f v)) (** Updating a ref cell for a user-defined PCM *) val upd_gen_action (#a:Type) (#p:pcm a) (r:ref a p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : action (pts_to r x) unit (fun _ -> pts_to r y) (** The update action needs you to prove that the mutation from [v0] to [v1] is frame-preserving with respect to the individual PCM governing the reference [r]. See [FStar.PCM.frame_preserving] *) val upd_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1}) : action (pts_to r v0) unit (fun _ -> pts_to r v1) (** Deallocating a reference, by actually replacing its value by the unit of the PCM *) val free_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a {exclusive pcm v0 /\ pcm.refine pcm.FStar.PCM.p.one}) : action (pts_to r v0) unit (fun _ -> pts_to r pcm.FStar.PCM.p.one) (** Splitting a permission on a composite resource into two separate permissions *) val split_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : action (pts_to r (v0 `op pcm` v1)) unit (fun _ -> pts_to r v0 `star` pts_to r v1) (** Combining separate permissions into a single composite permission *) val gather_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : action (pts_to r v0 `star` pts_to r v1) (_:unit{composable pcm v0 v1}) (fun _ -> pts_to r (op pcm v0 v1)) (** Allocating is a pseudo action here, the context needs to provide a fresh address *) val extend (#a:Type u#a) (#pcm:pcm a) (x:a{compatible pcm x x /\ pcm.refine x}) (addr:nat) (h:full_heap{h `free_above_addr` addr}) : ( r:ref a pcm & h':full_heap{ (forall (frame: slprop u#a). frame_related_heaps h h' emp (pts_to r x) frame (true)) /\ h' `free_above_addr` (addr + 1) /\ heap_evolves h h' } ) val frame (#a:Type) (#pre:slprop) (#post:a -> slprop) (frame:slprop) ($f:action pre a post) : action (pre `star` frame) a (fun x -> post x `star` frame) val change_slprop (p q:slprop) (proof: (h:heap -> Lemma (requires interp p h) (ensures interp q h))) : action p unit (fun _ -> q) module U = FStar.Universe val id_elim_star (p q:slprop) (h:heap) : Pure (erased heap & erased heap ) (requires (interp (p `star` q) h)) (ensures (fun (hl, hr) -> disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr)) val id_elim_exists (#a:Type) (p : a -> slprop) (h:heap) : Pure (erased a) (requires (interp (h_exists p) h)) (ensures (fun x -> interp (p x) h))
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop
[]
Steel.Heap.is_frame_monotonic
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: (_: a -> Steel.Heap.slprop) -> Prims.prop
{ "end_col": 99, "end_line": 635, "start_col": 2, "start_line": 635 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let is_witness_invariant #a (p : a -> slprop) = forall x y m. interp (p x) m /\ interp (p y) m ==> x == y
let is_witness_invariant #a (p: (a -> slprop)) =
false
null
false
forall x y m. interp (p x) m /\ interp (p y) m ==> x == y
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Prims.l_Forall", "Steel.Heap.heap", "Prims.l_imp", "Prims.l_and", "Steel.Heap.interp", "Prims.eq2", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1) (** Two heaps [h0] and [h1] are frame-related if you can get from [h0] to [h1] with a frame-preserving update. *) let frame_related_heaps (h0 h1:full_heap) (fp0 fp1 frame:slprop) (allocates:bool) = interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp:hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr)) (** A frame-preserving action applied on [h0] produces an [h1] such that [h0] and [h1] are frame-related *) let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) ($f:action fp a fp') (frame:slprop) (h0:full_hheap (fp `star` frame)) : Lemma ( affine_star fp frame h0; let (| x, h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false ) = affine_star fp frame h0; emp_unit fp (** [sel] is a ghost read of the value contained in a heap reference *) val sel (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (m:full_hheap (ptr r)) : a (** [sel_v] is a ghost read of the value contained in a heap reference *) val sel_v (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (v:erased a) (m:full_hheap (pts_to r v)) : v':a{ compatible pcm v v' /\ pcm.refine v' /\ interp (ptr r) m /\ v' == sel r m } (** [sel] respect [pts_to] *) val sel_lemma (#a:_) (#pcm:_) (r:ref a pcm) (m:full_hheap (ptr r)) : Lemma (interp (pts_to r (sel r m)) m) let witnessed_ref (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop) (h:full_heap) = interp (ptr r) h /\ fact (sel r h) val witnessed_ref_stability (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop) : Lemma (requires FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)) (ensures FStar.Preorder.stable (witnessed_ref r fact) heap_evolves) (** The action variant of [sel], returning the "true" value inside the heap. This "true" value can be different of the [pts_to] value you assumed at the beginning, because of the PCM structure *) val sel_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : action (pts_to r v0) (v:a{compatible pcm v0 v}) (fun _ -> pts_to r v0) (** A version of select that incorporates a ghost update of local knowledge of a ref cell based on the value that was read *) val select_refine (#a:_) (#p:_) (r:ref a p) (x:erased a) (f:(v:a{compatible p x v} -> GTot (y:a{compatible p y v /\ FStar.PCM.frame_compatible p x v y}))) : action (pts_to r x) (v:a{compatible p x v /\ p.refine v}) (fun v -> pts_to r (f v)) (** Updating a ref cell for a user-defined PCM *) val upd_gen_action (#a:Type) (#p:pcm a) (r:ref a p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : action (pts_to r x) unit (fun _ -> pts_to r y) (** The update action needs you to prove that the mutation from [v0] to [v1] is frame-preserving with respect to the individual PCM governing the reference [r]. See [FStar.PCM.frame_preserving] *) val upd_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1}) : action (pts_to r v0) unit (fun _ -> pts_to r v1) (** Deallocating a reference, by actually replacing its value by the unit of the PCM *) val free_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a {exclusive pcm v0 /\ pcm.refine pcm.FStar.PCM.p.one}) : action (pts_to r v0) unit (fun _ -> pts_to r pcm.FStar.PCM.p.one) (** Splitting a permission on a composite resource into two separate permissions *) val split_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : action (pts_to r (v0 `op pcm` v1)) unit (fun _ -> pts_to r v0 `star` pts_to r v1) (** Combining separate permissions into a single composite permission *) val gather_action (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : action (pts_to r v0 `star` pts_to r v1) (_:unit{composable pcm v0 v1}) (fun _ -> pts_to r (op pcm v0 v1)) (** Allocating is a pseudo action here, the context needs to provide a fresh address *) val extend (#a:Type u#a) (#pcm:pcm a) (x:a{compatible pcm x x /\ pcm.refine x}) (addr:nat) (h:full_heap{h `free_above_addr` addr}) : ( r:ref a pcm & h':full_heap{ (forall (frame: slprop u#a). frame_related_heaps h h' emp (pts_to r x) frame (true)) /\ h' `free_above_addr` (addr + 1) /\ heap_evolves h h' } ) val frame (#a:Type) (#pre:slprop) (#post:a -> slprop) (frame:slprop) ($f:action pre a post) : action (pre `star` frame) a (fun x -> post x `star` frame) val change_slprop (p q:slprop) (proof: (h:heap -> Lemma (requires interp p h) (ensures interp q h))) : action p unit (fun _ -> q) module U = FStar.Universe val id_elim_star (p q:slprop) (h:heap) : Pure (erased heap & erased heap ) (requires (interp (p `star` q) h)) (ensures (fun (hl, hr) -> disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr)) val id_elim_exists (#a:Type) (p : a -> slprop) (h:heap) : Pure (erased a) (requires (interp (h_exists p) h)) (ensures (fun x -> interp (p x) h)) let is_frame_monotonic #a (p : a -> slprop) : prop = forall x y m frame. interp (p x `star` frame) m /\ interp (p y) m ==> interp (p y `star` frame) m
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_witness_invariant : p: (_: a -> Steel.Heap.slprop) -> Prims.logical
[]
Steel.Heap.is_witness_invariant
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: (_: a -> Steel.Heap.slprop) -> Prims.logical
{ "end_col": 59, "end_line": 638, "start_col": 2, "start_line": 638 }
Prims.Tot
val heap_prop_is_affine (p: (heap u#a -> prop)) : prop
[ { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1)
val heap_prop_is_affine (p: (heap u#a -> prop)) : prop let heap_prop_is_affine (p: (heap u#a -> prop)) : prop =
false
null
false
forall (h0: heap u#a) (h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.heap", "Prims.prop", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Steel.Heap.disjoint", "Steel.Heap.join" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *)
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val heap_prop_is_affine (p: (heap u#a -> prop)) : prop
[]
Steel.Heap.heap_prop_is_affine
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: (_: Steel.Heap.heap -> Prims.prop) -> Prims.prop
{ "end_col": 69, "end_line": 112, "start_col": 2, "start_line": 112 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1)
let action_with_frame (fp: slprop u#a) (a: Type u#b) (fp': (a -> slprop u#a)) =
false
null
false
frame: slprop u#a -> h0: full_hheap (fp `star` frame) -> Pure (x: a & full_hheap ((fp' x) `star` frame)) (requires True) (ensures fun (| x , h1 |) -> action_related_heaps frame h0 h1)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.full_hheap", "Steel.Heap.star", "Prims.dtuple2", "Prims.l_True", "Steel.Heap.action_related_heaps" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b)
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_with_frame : fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
[]
Steel.Heap.action_with_frame
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fp: Steel.Heap.slprop -> a: Type -> fp': (_: a -> Steel.Heap.slprop) -> Type
{ "end_col": 67, "end_line": 458, "start_col": 4, "start_line": 454 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let witnessed_ref (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop) (h:full_heap) = interp (ptr r) h /\ fact (sel r h)
let witnessed_ref (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) (fact: (a -> prop)) (h: full_heap) =
false
null
false
interp (ptr r) h /\ fact (sel r h)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.Heap.ref", "Prims.prop", "Steel.Heap.full_heap", "Prims.l_and", "Steel.Heap.interp", "Steel.Heap.ptr", "Steel.Heap.sel", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1) (** Two heaps [h0] and [h1] are frame-related if you can get from [h0] to [h1] with a frame-preserving update. *) let frame_related_heaps (h0 h1:full_heap) (fp0 fp1 frame:slprop) (allocates:bool) = interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp:hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr)) (** A frame-preserving action applied on [h0] produces an [h1] such that [h0] and [h1] are frame-related *) let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) ($f:action fp a fp') (frame:slprop) (h0:full_hheap (fp `star` frame)) : Lemma ( affine_star fp frame h0; let (| x, h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false ) = affine_star fp frame h0; emp_unit fp (** [sel] is a ghost read of the value contained in a heap reference *) val sel (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (m:full_hheap (ptr r)) : a (** [sel_v] is a ghost read of the value contained in a heap reference *) val sel_v (#a:Type u#h) (#pcm:pcm a) (r:ref a pcm) (v:erased a) (m:full_hheap (pts_to r v)) : v':a{ compatible pcm v v' /\ pcm.refine v' /\ interp (ptr r) m /\ v' == sel r m } (** [sel] respect [pts_to] *) val sel_lemma (#a:_) (#pcm:_) (r:ref a pcm) (m:full_hheap (ptr r)) : Lemma (interp (pts_to r (sel r m)) m) let witnessed_ref (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) (fact:a -> prop)
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val witnessed_ref : r: Steel.Heap.ref a pcm -> fact: (_: a -> Prims.prop) -> h: Steel.Heap.full_heap -> Prims.logical
[]
Steel.Heap.witnessed_ref
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Heap.ref a pcm -> fact: (_: a -> Prims.prop) -> h: Steel.Heap.full_heap -> Prims.logical
{ "end_col": 18, "end_line": 511, "start_col": 4, "start_line": 510 }
Prims.Tot
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1)
let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': (a -> slprop u#b)) (f: pre_action fp a fp') =
false
null
false
forall (frame: slprop u#b) (h0: full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x , h1 |) = f h0 in interp ((fp' x) `star` frame) h1 /\ action_related_heaps frame h0 h1)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Steel.Heap.slprop", "Steel.Heap.pre_action", "Prims.l_Forall", "Steel.Heap.full_hheap", "Steel.Heap.star", "Prims.l_and", "Steel.Heap.interp", "Steel.Heap.action_related_heaps", "Prims.dtuple2", "Prims.unit", "Steel.Heap.affine_star", "Prims.logical" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp')
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_frame_preserving : f: Steel.Heap.pre_action fp a fp' -> Prims.logical
[]
Steel.Heap.is_frame_preserving
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: Steel.Heap.pre_action fp a fp' -> Prims.logical
{ "end_col": 39, "end_line": 437, "start_col": 2, "start_line": 433 }
Prims.Tot
val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null})
[ { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null}) let is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null}) =
false
null
false
core_ref_is_null r
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.Heap.ref", "Steel.Heap.core_ref_is_null", "Prims.bool", "Prims.l_iff", "Prims.b2t", "Prims.eq2", "Steel.Heap.null" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null]
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null})
[]
Steel.Heap.is_null
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Heap.ref a pcm -> b: Prims.bool{b <==> r == Steel.Heap.null}
{ "end_col": 102, "end_line": 61, "start_col": 84, "start_line": 61 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let pure (p:prop) = h_refine emp (fun _ -> p)
let pure (p: prop) =
false
null
false
h_refine emp (fun _ -> p)
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "total" ]
[ "Prims.prop", "Steel.Heap.h_refine", "Steel.Heap.emp", "Steel.Heap.heap", "Steel.Heap.slprop" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world
false
true
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pure : p: Prims.prop -> Steel.Heap.slprop
[]
Steel.Heap.pure
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Prims.prop -> Steel.Heap.slprop
{ "end_col": 45, "end_line": 344, "start_col": 20, "start_line": 344 }
FStar.Pervasives.Lemma
val action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': (a -> slprop u#b)) ($f: action fp a fp') (frame: slprop) (h0: full_hheap (fp `star` frame)) : Lemma (affine_star fp frame h0; let (| x , h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false)
[ { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "PP" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "W" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "Frac" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "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 } ]
false
let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) ($f:action fp a fp') (frame:slprop) (h0:full_hheap (fp `star` frame)) : Lemma ( affine_star fp frame h0; let (| x, h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false ) = affine_star fp frame h0; emp_unit fp
val action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': (a -> slprop u#b)) ($f: action fp a fp') (frame: slprop) (h0: full_hheap (fp `star` frame)) : Lemma (affine_star fp frame h0; let (| x , h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false) let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': (a -> slprop u#b)) ($f: action fp a fp') (frame: slprop) (h0: full_hheap (fp `star` frame)) : Lemma (affine_star fp frame h0; let (| x , h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false) =
false
null
true
affine_star fp frame h0; emp_unit fp
{ "checked_file": "Steel.Heap.fsti.checked", "dependencies": [ "Steel.Preorder.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Heap.fsti" }
[ "lemma" ]
[ "Steel.Heap.slprop", "Steel.Heap.action", "Steel.Heap.full_hheap", "Steel.Heap.star", "Steel.Heap.emp_unit", "Prims.unit", "Steel.Heap.affine_star", "Prims.l_True", "Prims.squash", "Steel.Heap.frame_related_heaps", "Prims.dtuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Heap open FStar.Ghost open FStar.PCM /// This module defines the behavior of a structured heap where each memory cell is governed by /// a partial commutative monoid. This PCM structure is reused for the entire heap as it is possible /// to talk about disjoint heaps and join them together. /// /// In a sense, a heap here can be seen as a partial heap, containing a partial view of the state of /// the memory. Combining disjoint heaps is then equivalent to conciling two partial views of the /// memory together. This is our base for separation logic. /// /// The heap is instrumented with affine heap predicates, heap predicates that don't change if you /// augment the heap on which they're valid by joining another partial heap. These affine heap /// predicates are the terms of our separation logic. /// /// Finally, the module defines actions for heap, which are frame-preserving heap updates. (**** The base : partial heaps *) (** Abstract type of heaps. Can conceptually be thought of as a map from addresses to contents of memory cells. *) val heap : Type u#(a + 1) (** A [core_ref] is a key into the [heap] or [null] *) val core_ref : Type u#0 (** We index a [core_ref] by the type of its heap contents and a [pcm] governing it, for ease of type inference *) let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref val core_ref_null : core_ref (** [null] is a specific reference, that is not associated to any value *) let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null (** Checking whether [r] is the null pointer is decidable through [is_null] *) val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null } (** Checking whether [r] is the null pointer is decidable through [is_null] *) let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r (** The predicate describing non-overlapping heaps *) val disjoint (h0 h1:heap u#h) : prop (** Disjointness is symmetric *) val disjoint_sym (h0 h1:heap u#h) : Lemma (disjoint h0 h1 <==> disjoint h1 h0) [SMTPat (disjoint h0 h1)] (** Disjoint heaps can be combined into a bigger heap*) val join (h0:heap u#h) (h1:heap u#h{disjoint h0 h1}) : heap u#h (** The join operation is commutative *) val join_commutative (h0 h1:heap) : Lemma (requires disjoint h0 h1) (ensures (disjoint h1 h0 /\ join h0 h1 == join h1 h0)) (** Disjointness distributes over join *) val disjoint_join (h0 h1 h2:heap) : Lemma (disjoint h1 h2 /\ disjoint h0 (join h1 h2) ==> disjoint h0 h1 /\ disjoint h0 h2 /\ disjoint (join h0 h1) h2 /\ disjoint (join h0 h2) h1) (** Join is associative *) val join_associative (h0 h1 h2:heap) : Lemma (requires disjoint h1 h2 /\ disjoint h0 (join h1 h2)) (ensures (disjoint h0 h1 /\ disjoint (join h0 h1) h2 /\ join h0 (join h1 h2) == join (join h0 h1) h2)) (**** Separation logic over heaps *) (** An affine heap proposition or affine heap predicate is a proposition whose validity does not change if the heap on which it is valid grows. In other terms, it is a proposition that is compatible with the disjoint/join operations for partial heaps. These affine heap predicates are the base of our separation logic. *) let heap_prop_is_affine (p:heap u#a -> prop) : prop = forall (h0 h1: heap u#a). p h0 /\ disjoint h0 h1 ==> p (join h0 h1) (** An affine heap proposition *) let a_heap_prop = p:(heap -> prop) { heap_prop_is_affine p } (** [slprop] is an abstract "separation logic proposition" The [erasable] attribute says that it is computationally irrelevant and will be extracted to [()] *) [@@erasable] val slprop : Type u#(a + 1) (** [slprop]s can be "interpreted" over any heap, yielding a [prop] *) val interp (p:slprop u#a) (m:heap u#a) : prop (** Promoting an affine heap proposition to an slprop *) val as_slprop (f:a_heap_prop) : p:slprop{forall h.interp p h <==> f h} (** An [hprop] is heap predicate indexed by a footprint [fp:slprop]. Its validity depends only on the fragment of the heap that satisfies [fp]. Note, it is unrelated to affinity, since the forward implication only applies to heaps [h0] that validate [fp] *) let hprop (fp:slprop u#a) = q:(heap u#a -> prop){ forall (h0:heap{interp fp h0}) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) } (** A common abbreviation: [hheap p] is a heap on which [p] is valid *) let hheap (p:slprop u#a) = m:heap u#a {interp p m} (** Equivalence relation on [slprop]s is just equivalence of their interpretations *) let equiv (p1 p2:slprop) = forall m. interp p1 m <==> interp p2 m (** An extensional equivalence principle for slprop *) val slprop_extensionality (p q:slprop) : Lemma (requires p `equiv` q) (ensures p == q) /// We can now define all the standard connectives of separation logic (** [emp] is the empty [slprop], valid on all heaps. It acts as the unit element *) val emp : slprop u#a (** "Points to" allows to talk about the heap contents *) val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a val h_and (p1 p2:slprop u#a) : slprop u#a val h_or (p1 p2:slprop u#a) : slprop u#a val star (p1 p2:slprop u#a) : slprop u#a val wand (p1 p2:slprop u#a) : slprop u#a val h_exists (#[@@@strictly_positive] a:Type u#b) ([@@@strictly_positive] f: (a -> slprop u#a)) : slprop u#a val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a (** [h_refine] consists of refining a separation logic proposition [p] with an affine heap predicate [r]. Since both types are equal, this is equivalent to [h_and]. *) val h_refine (p:slprop u#a) (r:a_heap_prop u#a) : slprop u#a (***** Basic properties of separation logic *) (** If [p * q] is valid on [h], then [p] and [q] are valid on [h] *) val affine_star (p q:slprop) (h:heap) : Lemma ((interp (p `star` q) h ==> interp p h /\ interp q h)) (** Equivalence of separation logic propositions is symmetric *) val equiv_symmetric (p1 p2:slprop) : squash (p1 `equiv` p2 ==> p2 `equiv` p1) (** If [p1 ~ p2] then [p1 * p3 ~ p2 * p3] *) val equiv_extensional_on_star (p1 p2 p3:slprop) : squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3)) (** [p ~~ p * emp] *) val emp_unit (p:slprop) : Lemma (p `equiv` (p `star` emp)) (** [emp] is trivial *) val intro_emp (h:heap) : Lemma (interp emp h) (** Introduction rule for equivalence of [h_exists] propositions *) val h_exists_cong (#a:Type) (p q : a -> slprop) : Lemma (requires (forall x. p x `equiv` q x)) (ensures (h_exists p `equiv` h_exists q)) (** Introducing [h_exists] by presenting a witness *) val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (h:heap) : Lemma (interp (p x) h ==> interp (h_exists p) h) (** Eliminate an existential by simply getting a proposition. *) val elim_h_exists (#a:_) (p:a -> slprop) (h:heap) : Lemma (interp (h_exists p) h ==> (exists x. interp (p x) h)) (** The interpretation of a separation logic proposition [hp] is itself an [hprop] of footprint [hp] *) val interp_depends_only_on (hp:slprop u#a) : Lemma (forall (h0:hheap hp) (h1:heap u#a{disjoint h0 h1}). interp hp h0 <==> interp hp (join h0 h1)) (***** [pts_to] properties *) (** [ptr r] is a separation logic proposition asserting the existence of an allocated cell at reference [r] *) let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) = h_exists (pts_to r) (** If we have [pts_to x v0] and [pts_to y v1] on the same heap, then [v0] and [v1] are are related by the PCM governing [x]. Indeed, the [pts_to] predicate is not stricly injective, as our partial heaps offer only a partial view on the contents of the memory cell. This partial view is governed by [pcm], and this lemma shows that you can combine two [pts_to] predicates into a third, with a new value with is the composition of [v0] and [v1] by [pcm]. This lemma is equivalent to injectivity of [pts_to] if you instantiate [pcm] with the exclusive PCM. *) val pts_to_compatible (#a:Type u#a) (#pcm: pcm a) (x:ref a pcm) (v0 v1:a) (h:heap u#a) : Lemma (interp (pts_to x v0 `star` pts_to x v1) h <==> (composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) h)) (** If a reference points to two different values, they must be joinable in the PCM, even when the pointing does not happen separately. *) val pts_to_join (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures joinable pcm v1 v2) (** Further, the value in the heap is a witness for that property *) val pts_to_join' (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v1 v2:a) (m:heap) : Lemma (requires (interp (pts_to r v1) m /\ interp (pts_to r v2) m)) (ensures (exists z. compatible pcm v1 z /\ compatible pcm v2 z /\ interp (pts_to r z) m)) val pts_to_compatible_equiv (#a:Type) (#pcm:_) (x:ref a pcm) (v0:a) (v1:a{composable pcm v0 v1}) : Lemma (equiv (pts_to x v0 `star` pts_to x v1) (pts_to x (op pcm v0 v1))) val pts_to_not_null (#a:Type) (#pcm:_) (x:ref a pcm) (v:a) (m:heap) : Lemma (requires interp (pts_to x v) m) (ensures x =!= null) (***** Properties of separating conjunction *) (** The separating conjunction [star] arises from the disjointness of partial heaps *) val intro_star (p q:slprop) (hp:hheap p) (hq:hheap q) : Lemma (requires disjoint hp hq) (ensures interp (p `star` q) (join hp hq)) val elim_star (p q:slprop) (h:hheap (p `star` q)) : Lemma (requires interp (p `star` q) h) (ensures exists hl hr. disjoint hl hr /\ h == join hl hr /\ interp p hl /\ interp q hr) (** [star] is commutative *) val star_commutative (p1 p2:slprop) : Lemma ((p1 `star` p2) `equiv` (p2 `star` p1)) (** [star] is associative *) val star_associative (p1 p2 p3:slprop) : Lemma ( (p1 `star` (p2 `star` p3)) `equiv` ((p1 `star` p2) `star` p3) ) (** If [p1 ~ p3] and [p2 ~ p4], then [p1 * p2 ~ p3 * p4] *) val star_congruence (p1 p2 p3 p4:slprop) : Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4) (ensures (p1 `star` p2) `equiv` (p3 `star` p4)) (***** Properties of the refinement *) (** [h_refine p q] is just interpreting the affine heap prop [q] when [p] is valid *) val refine_interp (p:slprop u#a) (q:a_heap_prop u#a) (h:heap u#a) : Lemma (interp p h /\ q h <==> interp (h_refine p q) h) (** Equivalence on [h_refine] propositions is define by logical equivalence of the refinements on all heaps *) val refine_equiv (p0 p1:slprop u#a) (q0 q1:a_heap_prop u#a) : Lemma (p0 `equiv` p1 /\ (forall h. q0 h <==> q1 h) ==> equiv (h_refine p0 q0) (h_refine p1 q1)) (** A [pure] separation logic predicate is a refinement on the empty heap. That is how we lift pure propositions to the separation logic world *) let pure (p:prop) = h_refine emp (fun _ -> p) (** Equivalence of pure propositions is the equivalence of the underlying propositions *) val pure_equiv (p q:prop) : Lemma ((p <==> q) ==> (pure p `equiv` pure q)) (** And the interpretation of pure propositions is their underlying propositions *) val pure_interp (q:prop) (h:heap u#a) : Lemma (interp (pure q) h <==> q) (** A helper lemma for interpreting a pure proposition with another [slprop] *) val pure_star_interp (p:slprop u#a) (q:prop) (h:heap u#a) : Lemma (interp (p `star` pure q) h <==> interp (p `star` emp) h /\ q) (***** Magic wand and implications properties *) (** We can define a [stronger] relation on [slprops], defined by interpretation implication *) let stronger (p q:slprop) = forall h. interp p h ==> interp q h (** [stronger] is stable when adding another starred [slprop] *) val stronger_star (p q r:slprop) : Lemma (stronger q r ==> stronger (p `star` q) (p `star` r)) (** If [q > r] and [p * q] is valid, then [p * r] is valid *) val weaken (p q r:slprop) (h:heap u#a) : Lemma (q `stronger` r /\ interp (p `star` q) h ==> interp (p `star` r) h) (**** Actions *) (** An abstract predicate classifying a "full" heap, i.e., the entire heap of the executing program, not just a fragment of it *) val full_heap_pred : heap -> prop let full_heap = h:heap { full_heap_pred h } let full_hheap fp = h:hheap fp { full_heap_pred h } (** This modules exposes a preorder that is respected for every well-formed update of the heap. The preorder represents the fact that once a reference is allocated, its type and PCM cannot change and the trace of values contained in the PCM respects the preorder induced by the PCM (see Steel.Preorder). *) val heap_evolves : FStar.Preorder.preorder full_heap (** This predicate allows us to maintain an allocation counter, as all references above [a] in [h] are free. *) val free_above_addr (h:heap u#a) (a:nat) : prop (** [free_above_addr] is abstract but can be weakened consistently with its intended behavior *) val weaken_free_above (h:heap) (a b:nat) : Lemma (free_above_addr h a /\ a <= b ==> free_above_addr h b) (** The base type for an action is indexed by two separation logic propositions, representing the heap specification of the action before and after. *) let pre_action (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = full_hheap fp -> (x:a & full_hheap (fp' x)) (** This is how the heaps before and after the action relate: - evolving the heap according to the heap preorder; - not allocating any new references; - preserving the validity of any heap proposition affecting any frame *) unfold let action_related_heaps (frame:slprop) (h0 h1:full_heap) = heap_evolves h0 h1 /\ (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr) /\ (forall (hp:hprop frame). hp h0 == hp h1) (** We only want to consider heap updates that are "frame-preserving", meaning that they only modify the portion of the heap that they're allowed to, without messing with any other partial view of the heap that is compatible with the one you own. This includes : - preserving correct interpretation in presence of a frame; - heaps are related as defined above *) let is_frame_preserving (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) (f:pre_action fp a fp') = forall (frame: slprop u#b) (h0:full_hheap (fp `star` frame)). (affine_star fp frame h0; let (| x, h1 |) = f h0 in interp (fp' x `star` frame) h1 /\ action_related_heaps frame h0 h1) (** Every action is frame-preserving *) let action (fp:slprop u#b) (a:Type u#a) (fp':a -> slprop u#b) = f:pre_action fp a fp'{ is_frame_preserving f } (** We define a second, but equivalent, type for actions that instead of quantifying over the frame, are explicitly passed a frame from outside This notion of action is useful for defining actions like witness_h_exists, see comments at the declaration of witness_h_exists *) let action_with_frame (fp:slprop u#a) (a:Type u#b) (fp':a -> slprop u#a) = frame:slprop u#a -> h0:full_hheap (fp `star` frame) -> Pure (x:a & full_hheap (fp' x `star` frame)) (requires True) (ensures fun (| x, h1 |) -> action_related_heaps frame h0 h1) (** Two heaps [h0] and [h1] are frame-related if you can get from [h0] to [h1] with a frame-preserving update. *) let frame_related_heaps (h0 h1:full_heap) (fp0 fp1 frame:slprop) (allocates:bool) = interp (fp0 `star` frame) h0 ==> interp (fp1 `star` frame) h1 /\ heap_evolves h0 h1 /\ (forall (hp:hprop frame). hp h0 == hp h1) /\ (not allocates ==> (forall ctr. h0 `free_above_addr` ctr ==> h1 `free_above_addr` ctr)) (** A frame-preserving action applied on [h0] produces an [h1] such that [h0] and [h1] are frame-related *) let action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': a -> slprop u#b) ($f:action fp a fp') (frame:slprop) (h0:full_hheap (fp `star` frame)) : Lemma ( affine_star fp frame h0; let (| x, h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false )
false
false
Steel.Heap.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_framing (#a: Type u#a) (#fp: slprop u#b) (#fp': (a -> slprop u#b)) ($f: action fp a fp') (frame: slprop) (h0: full_hheap (fp `star` frame)) : Lemma (affine_star fp frame h0; let (| x , h1 |) = f h0 in frame_related_heaps h0 h1 fp (fp' x) frame false)
[]
Steel.Heap.action_framing
{ "file_name": "lib/steel/Steel.Heap.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
$f: Steel.Heap.action fp a fp' -> frame: Steel.Heap.slprop -> h0: Steel.Heap.full_hheap (Steel.Heap.star fp frame) -> FStar.Pervasives.Lemma (ensures ([@@ FStar.Pervasives.inline_let ]let _ = Steel.Heap.affine_star fp frame h0 in let _ = f h0 in (let Prims.Mkdtuple2 #_ #_ x h1 = _ in Steel.Heap.frame_related_heaps h0 h1 fp (fp' x) frame false) <: Type0))
{ "end_col": 13, "end_line": 489, "start_col": 2, "start_line": 488 }
Prims.Tot
val to_seq (#a: Type0) (#len: size_nat) (l: lseq a len) : seq a
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l
val to_seq (#a: Type0) (#len: size_nat) (l: lseq a len) : seq a let to_seq (#a: Type0) (#len: size_nat) (l: lseq a len) : seq a =
false
null
false
l
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Lib.Sequence.seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_seq (#a: Type0) (#len: size_nat) (l: lseq a len) : seq a
[]
Lib.Sequence.to_seq
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Lib.Sequence.lseq a len -> Lib.Sequence.seq a
{ "end_col": 64, "end_line": 28, "start_col": 63, "start_line": 28 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let seq (a:Type0) = Seq.seq a
let seq (a: Type0) =
false
null
false
Seq.seq a
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*)
false
true
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq : a: Type0 -> Type0
[]
Lib.Sequence.seq
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> Type0
{ "end_col": 29, "end_line": 15, "start_col": 20, "start_line": 15 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len}
let lseq (a: Type0) (len: size_nat) =
false
null
false
s: seq a {Seq.length s == len}
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.seq", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *)
false
true
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lseq : a: Type0 -> len: Lib.IntTypes.size_nat -> Type0
[]
Lib.Sequence.lseq
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> len: Lib.IntTypes.size_nat -> Type0
{ "end_col": 64, "end_line": 27, "start_col": 36, "start_line": 27 }
Prims.Tot
val length (#a: Type0) (s: seq a) : nat
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let length (#a:Type0) (s:seq a) : nat = Seq.length s
val length (#a: Type0) (s: seq a) : nat let length (#a: Type0) (s: seq a) : nat =
false
null
false
Seq.length s
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.Sequence.seq", "FStar.Seq.Base.length", "Prims.nat" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length (#a: Type0) (s: seq a) : nat
[]
Lib.Sequence.length
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.seq a -> Prims.nat
{ "end_col": 52, "end_line": 18, "start_col": 40, "start_line": 18 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1
let op_At_Bar #a #len0 #len1 s0 s1 =
false
null
false
concat #a #len0 #len1 s0 s1
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.Sequence.concat", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)})
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_At_Bar : s0: Lib.Sequence.lseq a len0 -> s1: Lib.Sequence.lseq a len1 -> s2: Lib.Sequence.lseq a (len0 + len1) { Lib.Sequence.to_seq s2 == FStar.Seq.Base.append (Lib.Sequence.to_seq s0) (Lib.Sequence.to_seq s1) }
[]
Lib.Sequence.op_At_Bar
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Lib.Sequence.lseq a len0 -> s1: Lib.Sequence.lseq a len1 -> s2: Lib.Sequence.lseq a (len0 + len1) { Lib.Sequence.to_seq s2 == FStar.Seq.Base.append (Lib.Sequence.to_seq s0) (Lib.Sequence.to_seq s1) }
{ "end_col": 61, "end_line": 61, "start_col": 34, "start_line": 61 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let createL #a l = of_list #a l
let createL #a l =
false
null
false
of_list #a l
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Prims.list", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Lib.IntTypes.max_size_t", "Lib.Sequence.of_list", "Lib.Sequence.lseq", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Properties.seq_of_list" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)]
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val createL : l: Prims.list a {FStar.List.Tot.Base.length l <= Lib.IntTypes.max_size_t} -> s: Lib.Sequence.lseq a (FStar.List.Tot.Base.length l) {Lib.Sequence.to_seq s == FStar.Seq.Properties.seq_of_list l}
[]
Lib.Sequence.createL
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Prims.list a {FStar.List.Tot.Base.length l <= Lib.IntTypes.max_size_t} -> s: Lib.Sequence.lseq a (FStar.List.Tot.Base.length l) {Lib.Sequence.to_seq s == FStar.Seq.Properties.seq_of_list l}
{ "end_col": 38, "end_line": 98, "start_col": 26, "start_line": 98 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let op_String_Access #a #len = index #a #len
let op_String_Access #a #len =
false
null
false
index #a #len
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.index", "Lib.Sequence.lseq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Lib.Sequence.to_seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_String_Access : s: Lib.Sequence.lseq a len -> i: (n: Prims.nat{n <= Prims.pow2 32 - 1}){i < len} -> r: a{r == FStar.Seq.Base.index (Lib.Sequence.to_seq s) i}
[]
Lib.Sequence.op_String_Access
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.lseq a len -> i: (n: Prims.nat{n <= Prims.pow2 32 - 1}){i < len} -> r: a{r == FStar.Seq.Base.index (Lib.Sequence.to_seq s) i}
{ "end_col": 44, "end_line": 115, "start_col": 31, "start_line": 115 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let op_String_Assignment #a #len = upd #a #len
let op_String_Assignment #a #len =
false
null
false
upd #a #len
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.upd", "Lib.Sequence.lseq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_LessThan", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.Sequence.index", "Prims.l_Forall", "Prims.l_imp", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_String_Assignment : s: Lib.Sequence.lseq a len -> n: (n: Prims.nat{n <= Prims.pow2 32 - 1}){n < len} -> x: a -> o: Lib.Sequence.lseq a len { Lib.Sequence.to_seq o == FStar.Seq.Base.upd (Lib.Sequence.to_seq s) n x /\ Lib.Sequence.index o n == x /\ (forall (i: n: Prims.nat{n <= Prims.pow2 32 - 1}). {:pattern Lib.Sequence.index s i} i < len /\ i <> n ==> Lib.Sequence.index o i == Lib.Sequence.index s i) }
[]
Lib.Sequence.op_String_Assignment
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.lseq a len -> n: (n: Prims.nat{n <= Prims.pow2 32 - 1}){n < len} -> x: a -> o: Lib.Sequence.lseq a len { Lib.Sequence.to_seq o == FStar.Seq.Base.upd (Lib.Sequence.to_seq s) n x /\ Lib.Sequence.index o n == x /\ (forall (i: n: Prims.nat{n <= Prims.pow2 32 - 1}). {:pattern Lib.Sequence.index s i} i < len /\ i <> n ==> Lib.Sequence.index o i == Lib.Sequence.index s i) }
{ "end_col": 46, "end_line": 119, "start_col": 35, "start_line": 119 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let map_blocks_a (a: Type) (bs: size_nat) (max: nat) (i: nat{i <= max}) =
false
null
false
s: seq a {length s == i * bs}
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d))
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map_blocks_a : a: Type0 -> bs: Lib.IntTypes.size_nat -> max: Prims.nat -> i: Prims.nat{i <= max} -> Type0
[]
Lib.Sequence.map_blocks_a
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> bs: Lib.IntTypes.size_nat -> max: Prims.nat -> i: Prims.nat{i <= max} -> Type0
{ "end_col": 97, "end_line": 378, "start_col": 70, "start_line": 378 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let block (len:nat) (blocksize:size_pos) = i:nat{i < len / blocksize}
let block (len: nat) (blocksize: size_pos) =
false
null
false
i: nat{i < len / blocksize}
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) = Math.Lemmas.lemma_mult_le_right bs (i+1) max; let block = Seq.slice inp (i*bs) ((i+1)*bs) in Seq.append acc (f i block) val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize}) val lemma_map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (map_blocks_multi #a blocksize max n inp f == LoopCombinators.repeat_gen n (map_blocks_a a blocksize max) (map_blocks_f #a blocksize max inp f) Seq.empty) #restart-solver val index_map_blocks_multi: #a:Type0 -> bs:size_pos -> max:pos -> n:pos{n <= max} -> inp:seq a{length inp == max * bs} -> f:(i:nat{i < max} -> lseq a bs -> lseq a bs) -> i:nat{i < n * bs} -> Lemma ( div_mul_lt bs i n; let j = i / bs in let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) (* A full block index *)
false
true
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block : len: Prims.nat -> blocksize: Lib.IntTypes.size_pos -> Type0
[]
Lib.Sequence.block
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Prims.nat -> blocksize: Lib.IntTypes.size_pos -> Type0
{ "end_col": 69, "end_line": 433, "start_col": 43, "start_line": 433 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let last (len:nat) (blocksize:size_pos) = i:nat{i = len / blocksize}
let last (len: nat) (blocksize: size_pos) =
false
null
false
i: nat{i = len / blocksize}
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Division" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) = Math.Lemmas.lemma_mult_le_right bs (i+1) max; let block = Seq.slice inp (i*bs) ((i+1)*bs) in Seq.append acc (f i block) val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize}) val lemma_map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (map_blocks_multi #a blocksize max n inp f == LoopCombinators.repeat_gen n (map_blocks_a a blocksize max) (map_blocks_f #a blocksize max inp f) Seq.empty) #restart-solver val index_map_blocks_multi: #a:Type0 -> bs:size_pos -> max:pos -> n:pos{n <= max} -> inp:seq a{length inp == max * bs} -> f:(i:nat{i < max} -> lseq a bs -> lseq a bs) -> i:nat{i < n * bs} -> Lemma ( div_mul_lt bs i n; let j = i / bs in let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) (* A full block index *) unfold let block (len:nat) (blocksize:size_pos) = i:nat{i < len / blocksize} (* Index of last (incomplete) block *)
false
true
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val last : len: Prims.nat -> blocksize: Lib.IntTypes.size_pos -> Type0
[]
Lib.Sequence.last
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Prims.nat -> blocksize: Lib.IntTypes.size_pos -> Type0
{ "end_col": 69, "end_line": 437, "start_col": 43, "start_line": 437 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start)
let slice (#a: Type) (#len: size_nat) (s1: lseq a len) (start: size_nat) (fin: size_nat{start <= fin /\ fin <= len}) =
false
null
false
sub #a s1 start (fin - start)
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.sub", "Prims.op_Subtraction", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Addition", "Prims.l_Forall", "Prims.nat", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len})
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice : s1: Lib.Sequence.lseq a len -> start: Lib.IntTypes.size_nat -> fin: Lib.IntTypes.size_nat{start <= fin /\ fin <= len} -> s2: Lib.Sequence.lseq a (fin - start) { Lib.Sequence.to_seq s2 == FStar.Seq.Base.slice (Lib.Sequence.to_seq s1) start (start + (fin - start)) /\ (forall (k: Prims.nat{k < fin - start}). {:pattern Lib.Sequence.index s2 k} Lib.Sequence.index s2 k == Lib.Sequence.index s1 (start + k)) }
[]
Lib.Sequence.slice
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: Lib.Sequence.lseq a len -> start: Lib.IntTypes.size_nat -> fin: Lib.IntTypes.size_nat{start <= fin /\ fin <= len} -> s2: Lib.Sequence.lseq a (fin - start) { Lib.Sequence.to_seq s2 == FStar.Seq.Base.slice (Lib.Sequence.to_seq s1) start (start + (fin - start)) /\ (forall (k: Prims.nat{k < fin - start}). {:pattern Lib.Sequence.index s2 k} Lib.Sequence.index s2 k == Lib.Sequence.index s1 (start + k)) }
{ "end_col": 31, "end_line": 139, "start_col": 2, "start_line": 139 }
Prims.Tot
val to_lseq (#a: Type0) (s: seq a {length s <= max_size_t}) : l: lseq a (length s) {l == s}
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s
val to_lseq (#a: Type0) (s: seq a {length s <= max_size_t}) : l: lseq a (length s) {l == s} let to_lseq (#a: Type0) (s: seq a {length s <= max_size_t}) : l: lseq a (length s) {l == s} =
false
null
false
s
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.Sequence.seq", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Prims.eq2", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len}
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_lseq (#a: Type0) (s: seq a {length s <= max_size_t}) : l: lseq a (length s) {l == s}
[]
Lib.Sequence.to_lseq
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.seq a {Lib.Sequence.length s <= Lib.IntTypes.max_size_t} -> l: Lib.Sequence.lseq a (Lib.Sequence.length s) {l == s}
{ "end_col": 90, "end_line": 29, "start_col": 89, "start_line": 29 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd
let update_slice (#a: Type) (#len: size_nat) (i: lseq a len) (start: size_nat) (fin: size_nat{start <= fin /\ fin <= len}) (upd: lseq a (fin - start)) =
false
null
false
update_sub #a i start (fin - start) upd
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.Sequence.update_sub", "Prims.eq2", "Lib.Sequence.sub", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start))
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_slice : i: Lib.Sequence.lseq a len -> start: Lib.IntTypes.size_nat -> fin: Lib.IntTypes.size_nat{start <= fin /\ fin <= len} -> upd: Lib.Sequence.lseq a (fin - start) -> o: Lib.Sequence.lseq a len { Lib.Sequence.sub o start (fin - start) == upd /\ (forall (k: Prims.nat{0 <= k /\ k < start \/ start + (fin - start) <= k /\ k < len}). {:pattern Lib.Sequence.index o k} Lib.Sequence.index o k == Lib.Sequence.index i k) }
[]
Lib.Sequence.update_slice
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Lib.Sequence.lseq a len -> start: Lib.IntTypes.size_nat -> fin: Lib.IntTypes.size_nat{start <= fin /\ fin <= len} -> upd: Lib.Sequence.lseq a (fin - start) -> o: Lib.Sequence.lseq a len { Lib.Sequence.sub o start (fin - start) == upd /\ (forall (k: Prims.nat{0 <= k /\ k < start \/ start + (fin - start) <= k /\ k < len}). {:pattern Lib.Sequence.index o k} Lib.Sequence.index o k == Lib.Sequence.index i k) }
{ "end_col": 41, "end_line": 209, "start_col": 2, "start_line": 209 }
Prims.Tot
val repeat_blocks_f (#a #b: Type0) (bs: size_nat{bs > 0}) (inp: seq a) (f: (lseq a bs -> b -> b)) (nb: nat{nb == length inp / bs}) (i: nat{i < nb}) (acc: b) : b
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc
val repeat_blocks_f (#a #b: Type0) (bs: size_nat{bs > 0}) (inp: seq a) (f: (lseq a bs -> b -> b)) (nb: nat{nb == length inp / bs}) (i: nat{i < nb}) (acc: b) : b let repeat_blocks_f (#a #b: Type0) (bs: size_nat{bs > 0}) (inp: seq a) (f: (lseq a bs -> b -> b)) (nb: nat{nb == length inp / bs}) (i: nat{i < nb}) (acc: b) : b =
false
null
false
assert ((i + 1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_GreaterThan", "Lib.Sequence.seq", "Lib.Sequence.lseq", "Prims.nat", "Prims.eq2", "Prims.int", "Prims.op_Division", "Lib.Sequence.length", "Prims.op_LessThan", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.unit", "Prims._assert", "Prims.op_LessThanOrEqual" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_blocks_f (#a #b: Type0) (bs: size_nat{bs > 0}) (inp: seq a) (f: (lseq a bs -> b -> b)) (nb: nat{nb == length inp / bs}) (i: nat{i < nb}) (acc: b) : b
[]
Lib.Sequence.repeat_blocks_f
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bs: Lib.IntTypes.size_nat{bs > 0} -> inp: Lib.Sequence.seq a -> f: (_: Lib.Sequence.lseq a bs -> _: b -> b) -> nb: Prims.nat{nb == Lib.Sequence.length inp / bs} -> i: Prims.nat{i < nb} -> acc: b -> b
{ "end_col": 13, "end_line": 280, "start_col": 2, "start_line": 278 }
Prims.Tot
val map_blocks_f (#a: Type) (bs: size_nat{bs > 0}) (max: nat) (inp: seq a {length inp == max * bs}) (f: (i: nat{i < max} -> lseq a bs -> lseq a bs)) (i: nat{i < max}) (acc: map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) = Math.Lemmas.lemma_mult_le_right bs (i+1) max; let block = Seq.slice inp (i*bs) ((i+1)*bs) in Seq.append acc (f i block)
val map_blocks_f (#a: Type) (bs: size_nat{bs > 0}) (max: nat) (inp: seq a {length inp == max * bs}) (f: (i: nat{i < max} -> lseq a bs -> lseq a bs)) (i: nat{i < max}) (acc: map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) let map_blocks_f (#a: Type) (bs: size_nat{bs > 0}) (max: nat) (inp: seq a {length inp == max * bs}) (f: (i: nat{i < max} -> lseq a bs -> lseq a bs)) (i: nat{i < max}) (acc: map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) =
false
null
false
Math.Lemmas.lemma_mult_le_right bs (i + 1) max; let block = Seq.slice inp (i * bs) ((i + 1) * bs) in Seq.append acc (f i block)
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_GreaterThan", "Prims.nat", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.map_blocks_a", "FStar.Seq.Base.append", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "Prims.op_Addition", "Prims.unit", "FStar.Math.Lemmas.lemma_mult_le_right" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map_blocks_f (#a: Type) (bs: size_nat{bs > 0}) (max: nat) (inp: seq a {length inp == max * bs}) (f: (i: nat{i < max} -> lseq a bs -> lseq a bs)) (i: nat{i < max}) (acc: map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1)
[]
Lib.Sequence.map_blocks_f
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bs: Lib.IntTypes.size_nat{bs > 0} -> max: Prims.nat -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == max * bs} -> f: (i: Prims.nat{i < max} -> _: Lib.Sequence.lseq a bs -> Lib.Sequence.lseq a bs) -> i: Prims.nat{i < max} -> acc: Lib.Sequence.map_blocks_a a bs max i -> Lib.Sequence.map_blocks_a a bs max (i + 1)
{ "end_col": 28, "end_line": 391, "start_col": 2, "start_line": 389 }
Prims.Pure
val get_last (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (g: (last len blocksize -> rem: size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let get_last (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (g:(last len blocksize -> rem:size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize) = mod_div_lt blocksize i len; let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in g (len / blocksize) rem b
val get_last (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (g: (last len blocksize -> rem: size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize) let get_last (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (g: (last len blocksize -> rem: size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize) =
false
null
false
mod_div_lt blocksize i len; let rem = len % blocksize in let b:lseq a rem = Seq.slice inp (len - rem) len in g (len / blocksize) rem b
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Lib.Sequence.last", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Prims.l_and", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Prims.int", "Prims.op_Modulus", "Prims.unit", "Lib.Sequence.mod_div_lt", "Prims.l_True" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) = Math.Lemmas.lemma_mult_le_right bs (i+1) max; let block = Seq.slice inp (i*bs) ((i+1)*bs) in Seq.append acc (f i block) val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize}) val lemma_map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (map_blocks_multi #a blocksize max n inp f == LoopCombinators.repeat_gen n (map_blocks_a a blocksize max) (map_blocks_f #a blocksize max inp f) Seq.empty) #restart-solver val index_map_blocks_multi: #a:Type0 -> bs:size_pos -> max:pos -> n:pos{n <= max} -> inp:seq a{length inp == max * bs} -> f:(i:nat{i < max} -> lseq a bs -> lseq a bs) -> i:nat{i < n * bs} -> Lemma ( div_mul_lt bs i n; let j = i / bs in let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) (* A full block index *) unfold let block (len:nat) (blocksize:size_pos) = i:nat{i < len / blocksize} (* Index of last (incomplete) block *) unfold let last (len:nat) (blocksize:size_pos) = i:nat{i = len / blocksize} val map_blocks: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Tot (out:seq a{length out == length inp}) val lemma_map_blocks: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma ( let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; let bs = map_blocks_multi #a blocksize nb nb blocks f in let res = if (rem > 0) then Seq.append bs (g nb rem last) else bs in res == map_blocks #a blocksize inp f g) (* Computes the block of the i-th element of (map_blocks blocksize input f g) *) let get_block (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (f:(block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize) = div_mul_lt blocksize i (len / blocksize); let j: block len blocksize = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in f j b (* Computes the last block of (map_blocks blocksize input f g) *) let get_last (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (g:(last len blocksize -> rem:size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_last (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (g: (last len blocksize -> rem: size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{(len / blocksize) * blocksize <= i /\ i < len}) : Pure (lseq a (len % blocksize)) True (fun _ -> i % blocksize < len % blocksize)
[]
Lib.Sequence.get_last
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == len} -> g: ( _: Lib.Sequence.last len blocksize -> rem: Lib.IntTypes.size_nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem) -> i: Prims.nat{(len / blocksize) * blocksize <= i /\ i < len} -> Prims.Pure (Lib.Sequence.lseq a (len % blocksize))
{ "end_col": 27, "end_line": 494, "start_col": 2, "start_line": 491 }
Prims.Pure
val get_block (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (f: (block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "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 } ]
false
let get_block (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (f:(block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize) = div_mul_lt blocksize i (len / blocksize); let j: block len blocksize = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in f j b
val get_block (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (f: (block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize) let get_block (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (f: (block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize) =
false
null
false
div_mul_lt blocksize i (len / blocksize); let j:block len blocksize = i / blocksize in let b:lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in f j b
{ "checked_file": "Lib.Sequence.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.fsti" }
[]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Lib.Sequence.block", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Seq.Base.slice", "Prims.op_Addition", "Prims.unit", "Lib.Sequence.div_mul_lt", "Prims.l_True" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" /// Variable length Sequences, derived from FStar.Seq (* This is the type of unbounded sequences. Use this only when dealing with, say, user input whose length is unbounded. As far as possible use the API for bounded sequences defined later in this file.*) (** Definition of a Sequence *) let seq (a:Type0) = Seq.seq a (** Length of a Sequence *) let length (#a:Type0) (s:seq a) : nat = Seq.length s /// Fixed length Sequences (* This is the type of bounded sequences. Use this as much as possible. It adds additional length checks that you'd have to prove in the implementation otherwise *) (** Definition of a fixed-length Sequence *) let lseq (a:Type0) (len:size_nat) = s:seq a{Seq.length s == len} let to_seq (#a:Type0) (#len:size_nat) (l:lseq a len) : seq a = l let to_lseq (#a:Type0) (s:seq a{length s <= max_size_t}) : l:lseq a (length s){l == s} = s (* If you want to prove your code with an abstract lseq use the following: *) // val lseq: a:Type0 -> len:size_nat -> Type0 // val to_seq: #a:Type0 -> #len:size_nat -> lseq a len -> s:seq a{length s == len} // val to_lseq: #a:Type0 -> s:seq a{length s <= max_size_t} -> lseq a (length s) val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) (** Creation of a fixed-length Sequence from an initial value *) val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)}) (** Concatenate sequences: use with care, may make implementation hard to verify *) val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let ( @| ) #a #len0 #len1 s0 s1 = concat #a #len0 #len1 s0 s1 (** Conversion of a Sequence to a list *) val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) (** Creation of a fixed-length Sequence from a list of values *) val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] (* Alias for creation from a list *) unfold let createL #a l = of_list #a l (** Updating an element of a fixed-length Sequence *) val upd: #a:Type -> #len:size_nat -> s:lseq a len -> n:size_nat{n < len} -> x:a -> Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat). {:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) (** Membership of an element to a fixed-length Sequence *) val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool (** Operator for accessing an element of a fixed-length Sequence *) unfold let op_String_Access #a #len = index #a #len (** Operator for updating an element of a fixed-length Sequence *) unfold let op_String_Assignment #a #len = upd #a #len (** Selecting a subset of a fixed-length Sequence *) val sub: #a:Type -> #len:size_nat -> s1:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\ (forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) (** Selecting a subset of a fixed-length Sequence *) let slice (#a:Type) (#len:size_nat) (s1:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) = sub #a s1 start (fin - start) (** Updating a sub-Sequence from another fixed-length Sequence *) val update_sub: #a:Type -> #len:size_nat -> i:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> x:lseq a n -> Tot (o:lseq a len{sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}). {:pattern (index o k)} index o k == index i k)}) (** Lemma regarding updating a sub-Sequence with another Sequence *) val lemma_update_sub: #a:Type -> #len:size_nat -> dst:lseq a len -> start:size_nat -> n:size_nat{start + n <= len} -> src:lseq a n -> res:lseq a len -> Lemma (requires sub res 0 start == sub dst 0 start /\ sub res start n == src /\ sub res (start + n) (len - start - n) == sub dst (start + n) (len - start - n)) (ensures res == update_sub dst start n src) val lemma_concat2: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> s:lseq a (len0 + len1) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1) (ensures s == concat s0 s1) val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) (** Updating a sub-Sequence from another fixed-length Sequence *) let update_slice (#a:Type) (#len:size_nat) (i:lseq a len) (start:size_nat) (fin:size_nat{start <= fin /\ fin <= len}) (upd:lseq a (fin - start)) = update_sub #a i start (fin - start) upd (** Creation of a fixed-length Sequence from an initialization function *) val createi: #a:Type -> len:size_nat -> init:(i:nat{i < len} -> a) -> Tot (s:lseq a len{(forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init i)}) (** Mapi function for fixed-length Sequences *) val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) (** Map function for fixed-length Sequences *) val map:#a:Type -> #b:Type -> #len:size_nat -> f:(a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) (** Map2i function for fixed-length Sequences *) val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) (** Map2 function for fixed-length Sequences *) val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) (** Forall function for fixed-length Sequences *) val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool (** Forall2 function for fixed-length Sequences *) val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeat_blocks_f (#a:Type0) (#b:Type0) (bs:size_nat{bs > 0}) (inp:seq a) (f:(lseq a bs -> b -> b)) (nb:nat{nb == length inp / bs}) (i:nat{i < nb}) (acc:b) : b = assert ((i+1) * bs <= nb * bs); let block = Seq.slice inp (i * bs) (i * bs + bs) in f block acc val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c val lemma_repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> bs:size_pos -> inp:seq a -> f:(lseq a bs -> b -> b) -> l:(len:nat{len < bs} -> s:lseq a len -> b -> c) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in let rem = len % bs in let acc = Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init in let last = Seq.slice inp (nb * bs) len in let acc = l rem last acc in repeat_blocks #a #b bs inp f l init == acc) val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b val lemma_repeat_blocks_multi: #a:Type0 -> #b:Type0 -> bs:size_pos -> inp:seq a{length inp % bs = 0} -> f:(lseq a bs -> b -> b) -> init:b -> Lemma ( let len = length inp in let nb = len / bs in repeat_blocks_multi #a #b bs inp f init == Lib.LoopCombinators.repeati nb (repeat_blocks_f bs inp f nb) init) (** Generates `n` blocks of length `len` by iteratively applying a function with an accumulator *) val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) (** Generates `n` blocks of length `len` by iteratively applying a function without an accumulator *) val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) (** The following functions allow us to bridge between unbounded and bounded sequences *) val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) val div_mul_lt: b:pos -> a:int -> n:int -> Lemma (requires a < n * b) (ensures a / b < n) val mod_div_lt: b:pos -> i:int -> j:int -> Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let map_blocks_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let map_blocks_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (inp:seq a{length inp == max * bs}) (f:(i:nat{i < max} -> lseq a bs -> lseq a bs)) (i:nat{i < max}) (acc:map_blocks_a a bs max i) : map_blocks_a a bs max (i + 1) = Math.Lemmas.lemma_mult_le_right bs (i+1) max; let block = Seq.slice inp (i*bs) ((i+1)*bs) in Seq.append acc (f i block) val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize}) val lemma_map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (map_blocks_multi #a blocksize max n inp f == LoopCombinators.repeat_gen n (map_blocks_a a blocksize max) (map_blocks_f #a blocksize max inp f) Seq.empty) #restart-solver val index_map_blocks_multi: #a:Type0 -> bs:size_pos -> max:pos -> n:pos{n <= max} -> inp:seq a{length inp == max * bs} -> f:(i:nat{i < max} -> lseq a bs -> lseq a bs) -> i:nat{i < n * bs} -> Lemma ( div_mul_lt bs i n; let j = i / bs in let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) (* A full block index *) unfold let block (len:nat) (blocksize:size_pos) = i:nat{i < len / blocksize} (* Index of last (incomplete) block *) unfold let last (len:nat) (blocksize:size_pos) = i:nat{i = len / blocksize} val map_blocks: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Tot (out:seq a{length out == length inp}) val lemma_map_blocks: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma ( let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; let bs = map_blocks_multi #a blocksize nb nb blocks f in let res = if (rem > 0) then Seq.append bs (g nb rem last) else bs in res == map_blocks #a blocksize inp f g) (* Computes the block of the i-th element of (map_blocks blocksize input f g) *) let get_block (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (f:(block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize)
false
false
Lib.Sequence.fsti
{ "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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_block (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (f: (block len blocksize -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < (len / blocksize) * blocksize}) : Pure (lseq a blocksize) True (fun _ -> i / blocksize < len / blocksize)
[]
Lib.Sequence.get_block
{ "file_name": "lib/Lib.Sequence.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == len} -> f: (_: Lib.Sequence.block len blocksize -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize) -> i: Prims.nat{i < (len / blocksize) * blocksize} -> Prims.Pure (Lib.Sequence.lseq a blocksize)
{ "end_col": 7, "end_line": 478, "start_col": 2, "start_line": 475 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y)
let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) =
false
null
false
(forall x. g (f x) == x) /\ (forall y. f (g y) == y)
{ "checked_file": "LowStar.BufferView.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.fsti" }
[ "total" ]
[ "Prims.l_and", "Prims.l_Forall", "Prims.eq2", "Prims.logical" ]
[]
(* 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 LowStar.BufferView (** * A "view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a view requires providing a pair of mutually inverse functions * from sequences of `a` (sub-sequences of the source buffer) * to elements of `b`. * **) open LowStar.Monotonic.Buffer module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b))
false
false
LowStar.BufferView.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inverses : f: (_: a -> Prims.GTot b) -> g: (_: b -> Prims.GTot a) -> Prims.logical
[]
LowStar.BufferView.inverses
{ "file_name": "ulib/LowStar.BufferView.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.GTot b) -> g: (_: b -> Prims.GTot a) -> Prims.logical
{ "end_col": 26, "end_line": 43, "start_col": 2, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b)
let as_buffer_t (#dest: Type) (b: buffer dest) =
false
null
false
B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b)
{ "checked_file": "LowStar.BufferView.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.fsti" }
[ "total" ]
[ "LowStar.BufferView.buffer", "LowStar.Monotonic.Buffer.mbuffer", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3" ]
[]
(* 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 LowStar.BufferView (** * A "view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a view requires providing a pair of mutually inverse functions * from sequences of `a` (sub-sequences of the source buffer) * to elements of `b`. * **) open LowStar.Monotonic.Buffer module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps `n`-lengthed sequences of `a` to a single `b` noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(Seq.lseq a n -> GTot b) -> put:(b -> GTot (Seq.lseq a n)) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type has a higher universe, and /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max a 1) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest)
false
false
LowStar.BufferView.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_buffer_t : b: LowStar.BufferView.buffer dest -> Type0
[]
LowStar.BufferView.as_buffer_t
{ "file_name": "ulib/LowStar.BufferView.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: LowStar.BufferView.buffer dest -> Type0
{ "end_col": 110, "end_line": 82, "start_col": 47, "start_line": 82 }
Prims.Tot
val buffer (dest: Type u#a) : Type u#(max a 1)
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let buffer (dest:Type u#a) : Type u#(max a 1) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest)
val buffer (dest: Type u#a) : Type u#(max a 1) let buffer (dest: Type u#a) : Type u#(max a 1) =
false
null
false
(src: Type0 & rrel: B.srel src & rel: B.srel src & buffer_view src rrel rel dest)
{ "checked_file": "LowStar.BufferView.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.fsti" }
[ "total" ]
[ "FStar.Pervasives.dtuple4", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.buffer_view" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.BufferView (** * A "view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a view requires providing a pair of mutually inverse functions * from sequences of `a` (sub-sequences of the source buffer) * to elements of `b`. * **) open LowStar.Monotonic.Buffer module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps `n`-lengthed sequences of `a` to a single `b` noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(Seq.lseq a n -> GTot b) -> put:(b -> GTot (Seq.lseq a n)) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type has a higher universe, and /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe)
false
true
LowStar.BufferView.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val buffer (dest: Type u#a) : Type u#(max a 1)
[]
LowStar.BufferView.buffer
{ "file_name": "ulib/LowStar.BufferView.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
dest: Type -> Type
{ "end_col": 126, "end_line": 80, "start_col": 48, "start_line": 80 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let live #b h (vb:buffer b) = live h (as_buffer vb)
let live #b h (vb: buffer b) =
false
null
false
live h (as_buffer vb)
{ "checked_file": "LowStar.BufferView.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.fsti" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowStar.BufferView.buffer", "LowStar.Monotonic.Buffer.live", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3", "LowStar.BufferView.as_buffer" ]
[]
(* 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 LowStar.BufferView (** * A "view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a view requires providing a pair of mutually inverse functions * from sequences of `a` (sub-sequences of the source buffer) * to elements of `b`. * **) open LowStar.Monotonic.Buffer module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps `n`-lengthed sequences of `a` to a single `b` noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(Seq.lseq a n -> GTot b) -> put:(b -> GTot (Seq.lseq a n)) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type has a higher universe, and /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max a 1) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest) let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b) /// `mk_buffer_view`: The main constructor val mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : GTot (buffer dest) /// `as_buffer`: Projecting the underlying B.buffer from its view val as_buffer (#b:Type) (v:buffer b) : as_buffer_t v /// A lemma-relating projector to constructor val as_buffer_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ Mkdtuple4?._2 bv == rrel /\ Mkdtuple4?._3 bv == rel /\ as_buffer bv == b) [SMTPat (as_buffer (mk_buffer_view b v))] /// `get_view`: Projecting the view functions itself val get_view (#b : Type) (v:buffer b) : view (Mkdtuple4?._1 v) b /// A lemma-relating projector to constructor val get_view_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ get_view bv == v) [SMTPat (get_view (mk_buffer_view b v))] /// `live h vb`: liveness of a buffer view corresponds to liveness of /// the underlying buffer
false
false
LowStar.BufferView.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val live : h: FStar.Monotonic.HyperStack.mem -> vb: LowStar.BufferView.buffer b -> Type0
[]
LowStar.BufferView.live
{ "file_name": "ulib/LowStar.BufferView.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: FStar.Monotonic.HyperStack.mem -> vb: LowStar.BufferView.buffer b -> Type0
{ "end_col": 51, "end_line": 126, "start_col": 30, "start_line": 126 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies (#b: _) (vb:buffer b) (h h':HS.mem) = B.modifies (B.loc_buffer (as_buffer vb)) h h'
let modifies (#b: _) (vb: buffer b) (h h': HS.mem) =
false
null
false
B.modifies (B.loc_buffer (as_buffer vb)) h h'
{ "checked_file": "LowStar.BufferView.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "LowStar.BufferView.fsti" }
[ "total" ]
[ "LowStar.BufferView.buffer", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Pervasives.__proj__Mkdtuple4__item___1", "LowStar.Monotonic.Buffer.srel", "LowStar.BufferView.buffer_view", "FStar.Pervasives.__proj__Mkdtuple4__item___2", "FStar.Pervasives.__proj__Mkdtuple4__item___3", "LowStar.BufferView.as_buffer" ]
[]
(* 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 LowStar.BufferView (** * A "view" on a buffer allows treating a * `Buffer.buffer a` as a * `BufferView.buffer b` * * A "view" on a buffer is intended for specification purposes only * It does not correspond to a pointer cast in C. * * Building a view requires providing a pair of mutually inverse functions * from sequences of `a` (sub-sequences of the source buffer) * to elements of `b`. * **) open LowStar.Monotonic.Buffer module HS=FStar.HyperStack module B=LowStar.Monotonic.Buffer (** Definition of a view **) /// `f` and `g` are mutual inverses let inverses #a #b (f: (a -> GTot b)) (g: (b -> GTot a)) = (forall x. g (f x) == x) /\ (forall y. f (g y) == y) /// `view a b` maps `n`-lengthed sequences of `a` to a single `b` noeq type view (a:Type) (b:Type) = | View : n:pos -> get:(Seq.lseq a n -> GTot b) -> put:(b -> GTot (Seq.lseq a n)) { inverses get put } -> view a b /// `buffer_views src dest`: /// /// The main abstract type provided by this module. This type is /// indexed by both the `src` and `dest` types. The former (`src`) is /// the type of the underlying B.buffer's contents: as such, it is /// forced to be in universe 0. /// /// The destination type `dest` is for specification only and is not /// subject to the same universe constraints by the memory model. val buffer_view (src:Type0) (rrel rel:B.srel src) (dest:Type u#b) : Type u#b /// `buffer b`: In contrast to `buffer_view`, `buffer b` hides the /// source type of the view. As such, it is likely more convenient to /// use in specifications and the rest of this interface is designed /// around this type. /// /// However, the type has a higher universe, and /// this means, for instance, that values of `buffer b` cannot be /// stored in the heap. /// /// We leave its definition transparent in case clients wish to /// manipulate both the `src` and `dest` types explicitly (e.g., to /// stay in a lower universe) let buffer (dest:Type u#a) : Type u#(max a 1) = (src:Type0 & rrel:B.srel src & rel:B.srel src & buffer_view src rrel rel dest) let as_buffer_t (#dest:Type) (b:buffer dest) = B.mbuffer (Mkdtuple4?._1 b) (Mkdtuple4?._2 b) (Mkdtuple4?._3 b) /// `mk_buffer_view`: The main constructor val mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : GTot (buffer dest) /// `as_buffer`: Projecting the underlying B.buffer from its view val as_buffer (#b:Type) (v:buffer b) : as_buffer_t v /// A lemma-relating projector to constructor val as_buffer_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ Mkdtuple4?._2 bv == rrel /\ Mkdtuple4?._3 bv == rel /\ as_buffer bv == b) [SMTPat (as_buffer (mk_buffer_view b v))] /// `get_view`: Projecting the view functions itself val get_view (#b : Type) (v:buffer b) : view (Mkdtuple4?._1 v) b /// A lemma-relating projector to constructor val get_view_mk_buffer_view (#src:Type0) (#rrel #rel:B.srel src) (#dest:Type) (b:B.mbuffer src rrel rel) (v:view src dest{ length b % View?.n v == 0 }) : Lemma (let bv = mk_buffer_view b v in Mkdtuple4?._1 bv == src /\ get_view bv == v) [SMTPat (get_view (mk_buffer_view b v))] /// `live h vb`: liveness of a buffer view corresponds to liveness of /// the underlying buffer unfold let live #b h (vb:buffer b) = live h (as_buffer vb) /// `length vb`: is defined in terms of the underlying buffer /// /// Internally, it is defined as /// /// ``` /// length (as_buffer vb) / View?.n (get_view vb) /// ``` /// /// However, rather than expose this definition (which uses non-linear /// arithmetic) to callers, we treat length abstractly. /// /// To reveal its definition explicitly, use the `length_eq` lemma below. val length (#b: _) (vb:buffer b) : GTot nat /// `length_eq`: Reveals the definition of the `length` function val length_eq (#b: _) (vb:buffer b) : Lemma (length vb = B.length (as_buffer vb) / View?.n (get_view vb)) /// `view_indexing`: A lemma that requires a bit of non-linear /// arithmetic, necessary for some of the specs below and convenient /// when relating the underlying buffer to its view. val view_indexing (#b: _) (vb:buffer b) (i:nat{i < length vb}) : Lemma (let open FStar.Mul in let n = View?.n (get_view vb) in n <= length vb * n - i * n) /// `sel h vb i` : selects element at index `i` from the buffer `vb` in heap `h` val sel (#b: _) (h:HS.mem) (vb:buffer b) (i:nat{i < length vb}) : GTot b /// `upd h vb i x`: stores `x` at index `i` in the buffer `vb` in heap `h` val upd (#b: _) (h:HS.mem) (vb:buffer b{live h vb}) (i:nat{i < length vb}) (x:b) : GTot HS.mem /// `sel_upd`: A classic select/update lemma for reasoning about maps val sel_upd (#b:_) (vb:buffer b) (i:nat{i < length vb}) (j:nat{j < length vb}) (x:b) (h:HS.mem{live h vb}) : Lemma (if i = j then sel (upd h vb i x) vb j == x else sel (upd h vb i x) vb j == sel h vb j) [SMTPat (sel (upd h vb i x) vb j)] val lemma_upd_with_sel (#b:_) (vb:buffer b) (i:nat{i < length vb}) (h:HS.mem{live h vb}) :Lemma (upd h vb i (sel h vb i) == h) /// `modifies` on views is just defined in terms of the underlying buffer unfold let modifies (#b: _) (vb:buffer b)
false
false
LowStar.BufferView.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies : vb: LowStar.BufferView.buffer b -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Type0
[]
LowStar.BufferView.modifies
{ "file_name": "ulib/LowStar.BufferView.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
vb: LowStar.BufferView.buffer b -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Type0
{ "end_col": 51, "end_line": 193, "start_col": 6, "start_line": 193 }
Prims.Tot
val blake2_update' (a: alg) (kk: size_nat{kk <= max_key a}) (k: lbytes kk) (d: bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a}) (s: state a) : Tot (state a)
[ { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Blake2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Blake2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_update' (a:alg) (kk:size_nat{kk <= max_key a}) (k:lbytes kk) (d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a}) (s:state a): Tot (state a) = let ll = length d in let key_block: bytes = if kk > 0 then blake2_key_block a kk k else Seq.empty in blake2_update_blocks a 0 (key_block `Seq.append` d) s
val blake2_update' (a: alg) (kk: size_nat{kk <= max_key a}) (k: lbytes kk) (d: bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a}) (s: state a) : Tot (state a) let blake2_update' (a: alg) (kk: size_nat{kk <= max_key a}) (k: lbytes kk) (d: bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a}) (s: state a) : Tot (state a) =
false
null
false
let ll = length d in let key_block:bytes = if kk > 0 then blake2_key_block a kk k else Seq.empty in blake2_update_blocks a 0 (key_block `Seq.append` d) s
{ "checked_file": "Spec.Blake2.Alternative.fsti.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.Blake2.Alternative.fsti" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.op_Equality", "Prims.int", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.max_limb", "Prims.bool", "Prims.op_Addition", "Spec.Blake2.size_block", "Spec.Blake2.state", "Spec.Blake2.blake2_update_blocks", "FStar.Seq.Base.append", "Lib.IntTypes.int_t", "Lib.Sequence.seq", "Prims.op_GreaterThan", "Spec.Blake2.blake2_key_block", "FStar.Seq.Base.empty", "Prims.nat" ]
[]
module Spec.Blake2.Alternative open Spec.Blake2 open Lib.IntTypes open Lib.ByteSequence open Lib.Sequence let blake2_update' (a:alg) (kk:size_nat{kk <= max_key a}) (k:lbytes kk) (d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a})
false
false
Spec.Blake2.Alternative.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_update' (a: alg) (kk: size_nat{kk <= max_key a}) (k: lbytes kk) (d: bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a}) (s: state a) : Tot (state a)
[]
Spec.Blake2.Alternative.blake2_update'
{ "file_name": "specs/lemmas/Spec.Blake2.Alternative.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> kk: Lib.IntTypes.size_nat{kk <= Spec.Blake2.max_key a} -> k: Lib.ByteSequence.lbytes kk -> d: Lib.ByteSequence.bytes { (match kk = 0 with | true -> Lib.Sequence.length d <= Spec.Blake2.max_limb a | _ -> Lib.Sequence.length d + Spec.Blake2.size_block a <= Spec.Blake2.max_limb a) <: Type0 } -> s: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 55, "end_line": 17, "start_col": 1, "start_line": 15 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f)
let pts_to_body #a #p (r: ref a p) (f: perm) (v: a) (h: history a p) =
false
null
false
(PR.pts_to r h) `star` (pure (history_val h v f))
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "Steel.Preorder.history", "Steel.Effect.Common.star", "Steel.GhostPCMReference.pts_to", "Steel.Preorder.pcm_history", "Steel.Effect.Common.pure", "Steel.Preorder.history_val", "FStar.Ghost.hide", "Steel.Effect.Common.vprop" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__]
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pts_to_body : r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> h: Steel.Preorder.history a p -> Steel.Effect.Common.vprop
[]
Steel.GhostMonotonicHigherReference.pts_to_body
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> h: Steel.Preorder.history a p -> Steel.Effect.Common.vprop
{ "end_col": 30, "end_line": 42, "start_col": 6, "start_line": 41 }
Prims.Tot
val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let ref a p = PR.ref (history a p) pcm_history
val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0 let ref a p =
false
null
false
PR.ref (history a p) pcm_history
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostPCMReference.ref", "Steel.Preorder.history", "Steel.Preorder.pcm_history" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off"
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ref (a:Type u#1) (p:Preorder.preorder a) : Type u#0
[]
Steel.GhostMonotonicHigherReference.ref
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> p: FStar.Preorder.preorder a -> Type0
{ "end_col": 46, "end_line": 37, "start_col": 14, "start_line": 37 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) = h_exists (pts_to_body r f v)
let pts_to' (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) =
false
null
false
h_exists (pts_to_body r f v)
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Atomic.h_exists", "Steel.Preorder.history", "Steel.GhostMonotonicHigherReference.pts_to_body", "Steel.Effect.Common.vprop" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f)
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pts_to' : r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
[]
Steel.GhostMonotonicHigherReference.pts_to'
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
{ "end_col": 32, "end_line": 45, "start_col": 4, "start_line": 45 }
Prims.Tot
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let pts_to_sl r f v = hp_of (pts_to' r f v)
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1 let pts_to_sl r f v =
false
null
false
hp_of (pts_to' r f v)
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.hp_of", "Steel.GhostMonotonicHigherReference.pts_to'", "Steel.Memory.slprop" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f) let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) = h_exists (pts_to_body r f v)
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : slprop u#1
[]
Steel.GhostMonotonicHigherReference.pts_to_sl
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> Steel.Memory.slprop
{ "end_col": 43, "end_line": 47, "start_col": 22, "start_line": 47 }
Prims.Tot
val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a) : Type0
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let witnessed #a #p r fact = PR.witnessed r (lift_fact fact)
val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a) : Type0 let witnessed #a #p r fact =
false
null
false
PR.witnessed r (lift_fact fact)
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.GhostMonotonicHigherReference.property", "Steel.GhostPCMReference.witnessed", "Steel.Preorder.history", "Steel.Preorder.pcm_history", "Steel.Preorder.lift_fact" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f) let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) = h_exists (pts_to_body r f v) let pts_to_sl r f v = hp_of (pts_to' r f v) let intro_pure #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h) = A.intro_pure (history_val h v f) let intro_pure_full #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to r f v) = intro_pure #_ #a #p #f r v h; intro_exists h (pts_to_body r f v) let alloc #_ (#a:Type) (p:Preorder.preorder a) (v:a) = let h = Current [v] full_perm in assert (compatible pcm_history h h); let x : ref a p = alloc h in intro_pure_full x v h; x let extract_pure #a #uses #p #f (r:ref a p) (v:a) (h:(history a p)) : SteelGhostT (_:unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> pts_to_body r f v h) = elim_pure (history_val h v f); A.intro_pure (history_val h v f) let elim_pure #a #uses #p #f (r:ref a p) (v:a) (h:(history a p)) : SteelGhostT (_:unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) = let _ = extract_pure r v h in drop (pure (history_val h v f)) let write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a) (r:ref a p) (x:a) : SteelGhost unit opened (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True) = let h_old_e = witness_exists #_ #_ #(pts_to_body r full_perm v) () in let _ = elim_pure r v h_old_e in let h_old = read r in let h: history a p = extend_history' h_old x in write r h_old_e h; intro_pure_full r x h
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a) : Type0
[]
Steel.GhostMonotonicHigherReference.witnessed
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> fact: Steel.GhostMonotonicHigherReference.property a -> Type0
{ "end_col": 33, "end_line": 113, "start_col": 2, "start_line": 113 }
Steel.Effect.Atomic.SteelGhostT
val intro_pts_to (#o: _) (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : SteelGhostT unit o (pts_to' r f v) (fun _ -> pts_to' r f v)
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let intro_pts_to #o (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : SteelGhostT unit o (pts_to' r f v) (fun _ -> pts_to' r f v) = rewrite_slprop _ _ (fun _ -> ())
val intro_pts_to (#o: _) (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : SteelGhostT unit o (pts_to' r f v) (fun _ -> pts_to' r f v) let intro_pts_to #o (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : SteelGhostT unit o (pts_to' r f v) (fun _ -> pts_to' r f v) =
true
null
false
rewrite_slprop _ _ (fun _ -> ())
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.Preorder.preorder", "Steel.GhostMonotonicHigherReference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Atomic.rewrite_slprop", "Steel.GhostMonotonicHigherReference.pts_to'", "Steel.Memory.mem", "Prims.unit", "Steel.Effect.Common.vprop" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f) let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) = h_exists (pts_to_body r f v) let pts_to_sl r f v = hp_of (pts_to' r f v) let intro_pure #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h) = A.intro_pure (history_val h v f) let intro_pure_full #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to r f v) = intro_pure #_ #a #p #f r v h; intro_exists h (pts_to_body r f v) let alloc #_ (#a:Type) (p:Preorder.preorder a) (v:a) = let h = Current [v] full_perm in assert (compatible pcm_history h h); let x : ref a p = alloc h in intro_pure_full x v h; x let extract_pure #a #uses #p #f (r:ref a p) (v:a) (h:(history a p)) : SteelGhostT (_:unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> pts_to_body r f v h) = elim_pure (history_val h v f); A.intro_pure (history_val h v f) let elim_pure #a #uses #p #f (r:ref a p) (v:a) (h:(history a p)) : SteelGhostT (_:unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) = let _ = extract_pure r v h in drop (pure (history_val h v f)) let write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a) (r:ref a p) (x:a) : SteelGhost unit opened (pts_to r full_perm v) (fun v -> pts_to r full_perm x) (requires fun _ -> p v x /\ True) (ensures fun _ _ _ -> True) = let h_old_e = witness_exists #_ #_ #(pts_to_body r full_perm v) () in let _ = elim_pure r v h_old_e in let h_old = read r in let h: history a p = extend_history' h_old x in write r h_old_e h; intro_pure_full r x h let witnessed #a #p r fact = PR.witnessed r (lift_fact fact) let get_squash (#p:prop) (_:unit{p}) : squash p = () let witness_thunk (#inames: _) (#a:Type) (#pcm:FStar.PCM.pcm a) (r:PR.ref a pcm) (fact:M.stable_property pcm) (v:erased a) (sq:squash (fact_valid_compat #_ #pcm fact v)) (_:unit) : SteelAtomicUT (PR.witnessed r fact) inames (PR.pts_to r v) (fun _ -> PR.pts_to r v) = witness r fact v sq let witness (#inames: _) (#a:Type) (#q:perm) (#p:Preorder.preorder a) (r:ref a p) (fact:stable_property p) (v:erased a) (_:squash (fact v)) : SteelAtomicUT (witnessed r fact) inames (pts_to r q v) (fun _ -> pts_to r q v) = let h = witness_exists #_ #_ #(pts_to_body r q v) () in let _ = elim_pure #_ #_ #_ #q r v h in assert (forall h'. compatible pcm_history h h' ==> lift_fact fact h'); lift_fact_is_stable #a #p fact; let w = witness_thunk #_ #_ #(pcm_history #a #p) r (lift_fact fact) h () () in intro_pure_full r v h; rewrite_slprop (pts_to _ q _) (pts_to r q v) (fun _ -> ()); return w let recall (#inames: _) (#a:Type u#1) (#q:perm) (#p:Preorder.preorder a) (fact:property a) (r:ref a p) (v:erased a) (w:witnessed r fact) = let h = witness_exists #_ #_ #(pts_to_body r q v) () in let _ = elim_pure #_ #_ #_ #q r v h in let h1 = recall (lift_fact fact) r h w in intro_pure_full r v h; rewrite_slprop (pts_to _ q _) (pts_to r q v) (fun _ -> ()) let elim_pts_to #o (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : SteelGhostT unit o (pts_to r f v) (fun _ -> pts_to' r f v) = rewrite_slprop _ _ (fun _ -> ()) let intro_pts_to #o (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : SteelGhostT unit o (pts_to' r f v)
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intro_pts_to (#o: _) (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : SteelGhostT unit o (pts_to' r f v) (fun _ -> pts_to' r f v)
[]
Steel.GhostMonotonicHigherReference.intro_pts_to
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Atomic.SteelGhostT Prims.unit
{ "end_col": 38, "end_line": 178, "start_col": 6, "start_line": 178 }
Steel.Effect.Atomic.SteelGhostT
val intro_pure (#opened #a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f}) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h)
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.GhostPCMReference", "short_module": "PR" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.Preorder", "short_module": "Q" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "Preorder" }, { "abbrev": false, "full_module": "Steel.Preorder", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.GhostPCMReference", "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.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "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 } ]
false
let intro_pure #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h) = A.intro_pure (history_val h v f)
val intro_pure (#opened #a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f}) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h) let intro_pure #opened #a #p #f (r: ref a p) (v: a) (h: history a p {history_val h v f}) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h) =
true
null
false
A.intro_pure (history_val h v f)
{ "checked_file": "Steel.GhostMonotonicHigherReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.Memory.fsti.checked", "Steel.GhostPCMReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostMonotonicHigherReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.Preorder.preorder", "Steel.FractionalPermission.perm", "Steel.GhostMonotonicHigherReference.ref", "Steel.Preorder.history", "Steel.Preorder.history_val", "FStar.Ghost.hide", "Steel.Effect.Atomic.intro_pure", "Prims.unit", "Steel.GhostPCMReference.pts_to", "Steel.Preorder.pcm_history", "Steel.GhostMonotonicHigherReference.pts_to_body", "Steel.Effect.Common.vprop" ]
[]
(* 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.GhostMonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.GhostPCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.GhostPCMReference module A = Steel.Effect.Atomic open FStar.Real #set-options "--ide_id_info_off" let ref a p = PR.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:a) (h:history a p) = PR.pts_to r h `star` pure (history_val h v f) let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v: a) = h_exists (pts_to_body r f v) let pts_to_sl r f v = hp_of (pts_to' r f v) let intro_pure #opened #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelGhostT unit opened (PR.pts_to r h)
false
false
Steel.GhostMonotonicHigherReference.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intro_pure (#opened #a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f}) : SteelGhostT unit opened (PR.pts_to r h) (fun _ -> pts_to_body r f v h)
[]
Steel.GhostMonotonicHigherReference.intro_pure
{ "file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostMonotonicHigherReference.ref a p -> v: a -> h: Steel.Preorder.history a p {Steel.Preorder.history_val h (FStar.Ghost.hide v) f} -> Steel.Effect.Atomic.SteelGhostT Prims.unit
{ "end_col": 36, "end_line": 56, "start_col": 4, "start_line": 56 }