file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Test.Vectors.Curve25519.fst
Test.Vectors.Curve25519.result6
val result6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
val result6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
let result6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
{ "file_name": "providers/test/vectors/Test.Vectors.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 182, "start_col": 0, "start_line": 179 }
module Test.Vectors.Curve25519 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let private_0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x77uy; 0x07uy; 0x6duy; 0x0auy; 0x73uy; 0x18uy; 0xa5uy; 0x7duy; 0x3cuy; 0x16uy; 0xc1uy; 0x72uy; 0x51uy; 0xb2uy; 0x66uy; 0x45uy; 0xdfuy; 0x4cuy; 0x2fuy; 0x87uy; 0xebuy; 0xc0uy; 0x99uy; 0x2auy; 0xb1uy; 0x77uy; 0xfbuy; 0xa5uy; 0x1duy; 0xb9uy; 0x2cuy; 0x2auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_0_len: (x:UInt32.t { UInt32.v x = B.length private_0 }) = 32ul let public0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xdeuy; 0x9euy; 0xdbuy; 0x7duy; 0x7buy; 0x7duy; 0xc1uy; 0xb4uy; 0xd3uy; 0x5buy; 0x61uy; 0xc2uy; 0xecuy; 0xe4uy; 0x35uy; 0x37uy; 0x3fuy; 0x83uy; 0x43uy; 0xc8uy; 0x5buy; 0x78uy; 0x67uy; 0x4duy; 0xaduy; 0xfcuy; 0x7euy; 0x14uy; 0x6fuy; 0x88uy; 0x2buy; 0x4fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public0_len: (x:UInt32.t { UInt32.v x = B.length public0 }) = 32ul let result0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result0_len: (x:UInt32.t { UInt32.v x = B.length result0 }) = 32ul inline_for_extraction let valid0 = true let private_1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x5duy; 0xabuy; 0x08uy; 0x7euy; 0x62uy; 0x4auy; 0x8auy; 0x4buy; 0x79uy; 0xe1uy; 0x7fuy; 0x8buy; 0x83uy; 0x80uy; 0x0euy; 0xe6uy; 0x6fuy; 0x3buy; 0xb1uy; 0x29uy; 0x26uy; 0x18uy; 0xb6uy; 0xfduy; 0x1cuy; 0x2fuy; 0x8buy; 0x27uy; 0xffuy; 0x88uy; 0xe0uy; 0xebuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_1_len: (x:UInt32.t { UInt32.v x = B.length private_1 }) = 32ul let public1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x85uy; 0x20uy; 0xf0uy; 0x09uy; 0x89uy; 0x30uy; 0xa7uy; 0x54uy; 0x74uy; 0x8buy; 0x7duy; 0xdcuy; 0xb4uy; 0x3euy; 0xf7uy; 0x5auy; 0x0duy; 0xbfuy; 0x3auy; 0x0duy; 0x26uy; 0x38uy; 0x1auy; 0xf4uy; 0xebuy; 0xa4uy; 0xa9uy; 0x8euy; 0xaauy; 0x9buy; 0x4euy; 0x6auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public1_len: (x:UInt32.t { UInt32.v x = B.length public1 }) = 32ul let result1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result1_len: (x:UInt32.t { UInt32.v x = B.length result1 }) = 32ul inline_for_extraction let valid1 = true let private_2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_2_len: (x:UInt32.t { UInt32.v x = B.length private_2 }) = 32ul let public2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x25uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public2_len: (x:UInt32.t { UInt32.v x = B.length public2 }) = 32ul let result2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x3cuy; 0x77uy; 0x77uy; 0xcauy; 0xf9uy; 0x97uy; 0xb2uy; 0x64uy; 0x41uy; 0x60uy; 0x77uy; 0x66uy; 0x5buy; 0x4euy; 0x22uy; 0x9duy; 0x0buy; 0x95uy; 0x48uy; 0xdcuy; 0x0cuy; 0xd8uy; 0x19uy; 0x98uy; 0xdduy; 0xcduy; 0xc5uy; 0xc8uy; 0x53uy; 0x3cuy; 0x79uy; 0x7fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result2_len: (x:UInt32.t { UInt32.v x = B.length result2 }) = 32ul inline_for_extraction let valid2 = true let private_3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_3_len: (x:UInt32.t { UInt32.v x = B.length private_3 }) = 32ul let public3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public3_len: (x:UInt32.t { UInt32.v x = B.length public3 }) = 32ul let result3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xb3uy; 0x2duy; 0x13uy; 0x62uy; 0xc2uy; 0x48uy; 0xd6uy; 0x2fuy; 0xe6uy; 0x26uy; 0x19uy; 0xcfuy; 0xf0uy; 0x4duy; 0xd4uy; 0x3duy; 0xb7uy; 0x3fuy; 0xfcuy; 0x1buy; 0x63uy; 0x08uy; 0xeduy; 0xe3uy; 0x0buy; 0x78uy; 0xd8uy; 0x73uy; 0x80uy; 0xf1uy; 0xe8uy; 0x34uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result3_len: (x:UInt32.t { UInt32.v x = B.length result3 }) = 32ul inline_for_extraction let valid3 = true let private_4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xa5uy; 0x46uy; 0xe3uy; 0x6buy; 0xf0uy; 0x52uy; 0x7cuy; 0x9duy; 0x3buy; 0x16uy; 0x15uy; 0x4buy; 0x82uy; 0x46uy; 0x5euy; 0xdduy; 0x62uy; 0x14uy; 0x4cuy; 0x0auy; 0xc1uy; 0xfcuy; 0x5auy; 0x18uy; 0x50uy; 0x6auy; 0x22uy; 0x44uy; 0xbauy; 0x44uy; 0x9auy; 0xc4uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_4_len: (x:UInt32.t { UInt32.v x = B.length private_4 }) = 32ul let public4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe6uy; 0xdbuy; 0x68uy; 0x67uy; 0x58uy; 0x30uy; 0x30uy; 0xdbuy; 0x35uy; 0x94uy; 0xc1uy; 0xa4uy; 0x24uy; 0xb1uy; 0x5fuy; 0x7cuy; 0x72uy; 0x66uy; 0x24uy; 0xecuy; 0x26uy; 0xb3uy; 0x35uy; 0x3buy; 0x10uy; 0xa9uy; 0x03uy; 0xa6uy; 0xd0uy; 0xabuy; 0x1cuy; 0x4cuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public4_len: (x:UInt32.t { UInt32.v x = B.length public4 }) = 32ul let result4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xc3uy; 0xdauy; 0x55uy; 0x37uy; 0x9duy; 0xe9uy; 0xc6uy; 0x90uy; 0x8euy; 0x94uy; 0xeauy; 0x4duy; 0xf2uy; 0x8duy; 0x08uy; 0x4fuy; 0x32uy; 0xecuy; 0xcfuy; 0x03uy; 0x49uy; 0x1cuy; 0x71uy; 0xf7uy; 0x54uy; 0xb4uy; 0x07uy; 0x55uy; 0x77uy; 0xa2uy; 0x85uy; 0x52uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result4_len: (x:UInt32.t { UInt32.v x = B.length result4 }) = 32ul inline_for_extraction let valid4 = true let private_5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_5_len: (x:UInt32.t { UInt32.v x = B.length private_5 }) = 32ul let public5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public5_len: (x:UInt32.t { UInt32.v x = B.length public5 }) = 32ul let result5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result5_len: (x:UInt32.t { UInt32.v x = B.length result5 }) = 32ul inline_for_extraction let valid5 = false let private_6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x02uy; 0x04uy; 0x06uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_6_len: (x:UInt32.t { UInt32.v x = B.length private_6 }) = 32ul let public6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe0uy; 0xebuy; 0x7auy; 0x7cuy; 0x3buy; 0x41uy; 0xb8uy; 0xaeuy; 0x16uy; 0x56uy; 0xe3uy; 0xfauy; 0xf1uy; 0x9fuy; 0xc4uy; 0x6auy; 0xdauy; 0x09uy; 0x8duy; 0xebuy; 0x9cuy; 0x32uy; 0xb1uy; 0xfduy; 0x86uy; 0x62uy; 0x05uy; 0x16uy; 0x5fuy; 0x49uy; 0xb8uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public6_len: (x:UInt32.t { UInt32.v x = B.length public6 }) = 32ul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.Buffer.buffer FStar.UInt8.t {LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "FStar.UInt8.t", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let result6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
[@@ inline_let ]let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
false
FStar.Pointer.Derived2.fsti
FStar.Pointer.Derived2.copy_buffer_contents_postcond
val copy_buffer_contents_postcond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h h': HS.mem) : GTot Type0
val copy_buffer_contents_postcond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h h': HS.mem) : GTot Type0
let copy_buffer_contents_postcond (#t: typ) (a: buffer t) (* source *) (idx_a: UInt32.t) (b: buffer t) (* destination *) (idx_b: UInt32.t) (len: UInt32.t) (h: HS.mem) (h' : HS.mem) : GTot Type0 = copy_buffer_contents_precond a idx_a b idx_b len h /\ modifies (loc_buffer (gsub_buffer b idx_b len)) h h' /\ buffer_readable h' (gsub_buffer b idx_b len) /\ buffer_as_seq h' (gsub_buffer b idx_b len) == buffer_as_seq h (gsub_buffer a idx_a len)
{ "file_name": "ulib/legacy/FStar.Pointer.Derived2.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 89, "end_line": 52, "start_col": 0, "start_line": 39 }
(* 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 FStar.Pointer.Derived2 include FStar.Pointer.Base include FStar.Pointer.Derived1 module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST let copy_buffer_contents_precond (#t: typ) (a: buffer t) (* source *) (idx_a: UInt32.t) (b: buffer t) (* destination *) (idx_b: UInt32.t) (len: UInt32.t) (h: HS.mem) : GTot Type0 = UInt32.v idx_a + UInt32.v len <= UInt32.v (buffer_length a) /\ UInt32.v idx_b + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b idx_b len) /\ buffer_readable h (gsub_buffer a idx_a len) /\ loc_disjoint (loc_buffer (gsub_buffer a idx_a len)) (loc_buffer (gsub_buffer b idx_b len))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pointer.Derived1.fsti.checked", "FStar.Pointer.Base.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Derived2.fsti" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer.Derived1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Pointer.Base.buffer t -> idx_a: FStar.UInt32.t -> b: FStar.Pointer.Base.buffer t -> idx_b: FStar.UInt32.t -> len: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.buffer", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Pointer.Derived2.copy_buffer_contents_precond", "FStar.Pointer.Base.modifies", "FStar.Pointer.Base.loc_buffer", "FStar.Pointer.Base.gsub_buffer", "FStar.Pointer.Base.buffer_readable", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.Pointer.Base.type_of_typ", "FStar.Pointer.Base.buffer_as_seq" ]
[]
false
false
false
false
true
let copy_buffer_contents_postcond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h h': HS.mem) : GTot Type0 =
copy_buffer_contents_precond a idx_a b idx_b len h /\ modifies (loc_buffer (gsub_buffer b idx_b len)) h h' /\ buffer_readable h' (gsub_buffer b idx_b len) /\ buffer_as_seq h' (gsub_buffer b idx_b len) == buffer_as_seq h (gsub_buffer a idx_a len)
false
FStar.Pointer.Derived2.fsti
FStar.Pointer.Derived2.copy_buffer_contents_precond
val copy_buffer_contents_precond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h: HS.mem) : GTot Type0
val copy_buffer_contents_precond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h: HS.mem) : GTot Type0
let copy_buffer_contents_precond (#t: typ) (a: buffer t) (* source *) (idx_a: UInt32.t) (b: buffer t) (* destination *) (idx_b: UInt32.t) (len: UInt32.t) (h: HS.mem) : GTot Type0 = UInt32.v idx_a + UInt32.v len <= UInt32.v (buffer_length a) /\ UInt32.v idx_b + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b idx_b len) /\ buffer_readable h (gsub_buffer a idx_a len) /\ loc_disjoint (loc_buffer (gsub_buffer a idx_a len)) (loc_buffer (gsub_buffer b idx_b len))
{ "file_name": "ulib/legacy/FStar.Pointer.Derived2.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 92, "end_line": 37, "start_col": 0, "start_line": 24 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Derived2 include FStar.Pointer.Base include FStar.Pointer.Derived1 module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pointer.Derived1.fsti.checked", "FStar.Pointer.Base.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Derived2.fsti" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer.Derived1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Pointer.Base.buffer t -> idx_a: FStar.UInt32.t -> b: FStar.Pointer.Base.buffer t -> idx_b: FStar.UInt32.t -> len: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.buffer", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Pointer.Base.buffer_length", "FStar.Pointer.Base.buffer_live", "FStar.Pointer.Base.gsub_buffer", "FStar.Pointer.Base.buffer_readable", "FStar.Pointer.Base.loc_disjoint", "FStar.Pointer.Base.loc_buffer" ]
[]
false
false
false
false
true
let copy_buffer_contents_precond (#t: typ) (a: buffer t) (idx_a: UInt32.t) (b: buffer t) (idx_b len: UInt32.t) (h: HS.mem) : GTot Type0 =
UInt32.v idx_a + UInt32.v len <= UInt32.v (buffer_length a) /\ UInt32.v idx_b + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b idx_b len) /\ buffer_readable h (gsub_buffer a idx_a len) /\ loc_disjoint (loc_buffer (gsub_buffer a idx_a len)) (loc_buffer (gsub_buffer b idx_b len))
false
LowParse.Spec.Combinators.fst
LowParse.Spec.Combinators.serialize_nondep_then_upd_left_chain
val serialize_nondep_then_upd_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i' : nat) (s' : bytes) : Lemma (requires ( let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_seq s1' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s i' s' ))
val serialize_nondep_then_upd_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i' : nat) (s' : bytes) : Lemma (requires ( let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_seq s1' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s i' s' ))
let serialize_nondep_then_upd_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i' : nat) (s' : bytes) : Lemma (requires ( let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_seq s1' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s i' s' )) = serialize_nondep_then_upd_left s1 s2 x y; let s = serialize (serialize_nondep_then s1 s2) x in let s1' = serialize s1 (fst x) in let l1 = Seq.length s1' in Seq.lemma_split s l1; Seq.lemma_append_inj (Seq.slice s 0 l1) (Seq.slice s l1 (Seq.length s)) s1' (serialize s2 (snd x)); seq_upd_seq_right_to_left s 0 s1' i' s'; seq_upd_seq_slice_idem s 0 (Seq.length s1')
{ "file_name": "src/lowparse/LowParse.Spec.Combinators.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 45, "end_line": 518, "start_col": 0, "start_line": 487 }
module LowParse.Spec.Combinators include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 module T = FStar.Tactics #reset-options "--using_facts_from '* -FStar.Tactis -FStar.Reflection'" let and_then #k #t p #k' #t' p' = let f : bare_parser t' = and_then_bare p p' in and_then_correct p p' ; f let and_then_eq (#k: parser_kind) (#t:Type) (p:parser k t) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (input: bytes) : Lemma (requires (and_then_cases_injective p')) (ensures (parse (and_then p p') input == and_then_bare p p' input)) = () let tot_and_then_bare (#t:Type) (#t':Type) (p:tot_bare_parser t) (p': (t -> Tot (tot_bare_parser t'))) : Tot (tot_bare_parser t') = fun (b: bytes) -> match p b with | Some (v, l) -> begin let p'v = p' v in let s' : bytes = Seq.slice b l (Seq.length b) in match p'v s' with | Some (v', l') -> let res : consumed_length b = l + l' in Some (v', res) | None -> None end | None -> None let tot_and_then #k #t p #k' #t' p' = let f : tot_bare_parser t' = tot_and_then_bare p p' in and_then_correct #k p #k' p' ; parser_kind_prop_ext (and_then_kind k k') (and_then_bare p p') f; f let parse_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) : Pure (parser k t2) (requires ( synth_injective f2 )) (ensures (fun _ -> True)) = coerce (parser k t2) (and_then p1 (fun v1 -> parse_fret f2 v1)) let parse_synth_eq (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (b: bytes) : Lemma (requires (synth_injective f2)) (ensures (parse (parse_synth p1 f2) b == parse_synth' p1 f2 b)) = () unfold let tot_parse_fret' (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_bare_parser t') = fun (b: bytes) -> Some (f v, (0 <: consumed_length b)) unfold let tot_parse_fret (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_parser parse_ret_kind t') = [@inline_let] let _ = parser_kind_prop_equiv parse_ret_kind (tot_parse_fret' f v) in tot_parse_fret' f v let tot_parse_synth #k #t1 #t2 p1 f2 = coerce (tot_parser k t2) (tot_and_then p1 (fun v1 -> tot_parse_fret f2 v1)) let bare_serialize_synth_correct #k #t1 #t2 p1 f2 s1 g1 = () let serialize_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer (parse_synth p1 f2)) = bare_serialize_synth_correct p1 f2 s1 g1; bare_serialize_synth p1 f2 s1 g1 let serialize_synth_eq (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x: t2) : Lemma (serialize (serialize_synth p1 f2 s1 g1 u) x == serialize s1 (g1 x)) = () let serialize_synth_upd_chain (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x1: t1) (x2: t2) (y1: t1) (y2: t2) (i': nat) (s' : bytes) : Lemma (requires ( let s = serialize s1 x1 in i' + Seq.length s' <= Seq.length s /\ serialize s1 y1 == seq_upd_seq s i' s' /\ x2 == f2 x1 /\ y2 == f2 y1 )) (ensures ( let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in i' + Seq.length s' <= Seq.length s /\ Seq.length s == Seq.length (serialize s1 x1) /\ serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_seq s i' s' )) = (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *) assert (forall w w' . f2 w == f2 w' ==> w == w'); assert (forall w . f2 (g1 w) == w) let serialize_synth_upd_bw_chain (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x1: t1) (x2: t2) (y1: t1) (y2: t2) (i': nat) (s' : bytes) : Lemma (requires ( let s = serialize s1 x1 in i' + Seq.length s' <= Seq.length s /\ serialize s1 y1 == seq_upd_bw_seq s i' s' /\ x2 == f2 x1 /\ y2 == f2 y1 )) (ensures ( let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in i' + Seq.length s' <= Seq.length s /\ Seq.length s == Seq.length (serialize s1 x1) /\ serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_bw_seq s i' s' )) = (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *) assert (forall w w' . f2 w == f2 w' ==> w == w'); assert (forall w . f2 (g1 w) == w) let parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; pt `and_then` parse_tagged_union_payload tag_of_data p let parse_tagged_union_eq (#kt: parser_kind) (#tag_t: Type) (pt: parser kt tag_t) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (input: bytes) : Lemma (parse (parse_tagged_union pt tag_of_data p) input == (match parse pt input with | None -> None | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in begin match parse (p tg) input_tg with | Some (x, consumed_x) -> Some ((x <: data_t), consumed_tg + consumed_x) | None -> None end )) = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; and_then_eq pt (parse_tagged_union_payload tag_of_data p) input; match parse pt input with | None -> () | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in parse_synth_eq #k #(refine_with_tag tag_of_data tg) (p tg) (synth_tagged_union_data tag_of_data tg) input_tg let parse_tagged_union_eq_gen (#kt: parser_kind) (#tag_t: Type) (pt: parser kt tag_t) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (#kt': parser_kind) (pt': parser kt' tag_t) (lem_pt: ( (input: bytes) -> Lemma (parse pt input == parse pt' input) )) (k': (t: tag_t) -> Tot parser_kind) (p': (t: tag_t) -> Tot (parser (k' t) (refine_with_tag tag_of_data t))) (lem_p' : ( (k: tag_t) -> (input: bytes) -> Lemma (parse (p k) input == parse (p' k) input) )) (input: bytes) : Lemma (parse (parse_tagged_union pt tag_of_data p) input == bare_parse_tagged_union pt' tag_of_data k' p' input) = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; and_then_eq pt (parse_tagged_union_payload tag_of_data p) input; lem_pt input; match parse pt input with | None -> () | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in parse_synth_eq #k #(refine_with_tag tag_of_data tg) (p tg) (synth_tagged_union_data tag_of_data tg) input_tg; lem_p' tg input_tg let tot_parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p = parse_tagged_union_payload_and_then_cases_injective tag_of_data #k p; pt `tot_and_then` tot_parse_tagged_union_payload tag_of_data p let serialize_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (st: serializer pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (s: (t: tag_t) -> Tot (serializer (p t))) : Pure (serializer (parse_tagged_union pt tag_of_data p)) (requires (kt.parser_kind_subkind == Some ParserStrong)) (ensures (fun _ -> True)) = bare_serialize_tagged_union_correct st tag_of_data s; bare_serialize_tagged_union st tag_of_data s let serialize_tagged_union_eq (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (st: serializer pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (s: (t: tag_t) -> Tot (serializer (p t))) (input: data_t) : Lemma (requires (kt.parser_kind_subkind == Some ParserStrong)) (ensures (serialize (serialize_tagged_union st tag_of_data s) input == bare_serialize_tagged_union st tag_of_data s input)) [SMTPat (serialize (serialize_tagged_union st tag_of_data s) input)] = () let serialize_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> parser k2 (t2 x)) (s2: (x: t1) -> serializer (p2 x)) : Tot (serializer (parse_dtuple2 p1 p2)) = serialize_tagged_union s1 dfst (fun (x: t1) -> serialize_synth (p2 x) (synth_dtuple2 x) (s2 x) (synth_dtuple2_recip x) ()) let parse_dtuple2_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) (b: bytes) : Lemma (parse (parse_dtuple2 p1 p2) b == (match parse p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match parse (p2 x1) b' with | Some (x2, consumed2) -> Some ((| x1, x2 |), consumed1 + consumed2) | _ -> None end | _ -> None )) by (T.norm [delta_only [`%parse_dtuple2;]]) = () let serialize_dtuple2_eq (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> parser k2 (t2 x)) (s2: (x: t1) -> serializer (p2 x)) (xy: dtuple2 t1 t2) : Lemma (serialize (serialize_dtuple2 s1 s2) xy == serialize s1 (dfst xy) `Seq.append` serialize (s2 (dfst xy)) (dsnd xy)) = () (* Special case for non-dependent parsing *) let nondep_then (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) = parse_tagged_union p1 fst (fun x -> parse_synth p2 (fun y -> (x, y) <: refine_with_tag fst x)) #set-options "--z3rlimit 16" let nondep_then_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (b: bytes) : Lemma (parse (nondep_then p1 p2) b == (match parse p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match parse p2 b' with | Some (x2, consumed2) -> Some ((x1, x2), consumed1 + consumed2) | _ -> None end | _ -> None )) by (T.norm [delta_only [`%nondep_then;]]) = () let tot_nondep_then_bare (#t1: Type) (p1: tot_bare_parser t1) (#t2: Type) (p2: tot_bare_parser t2) : Tot (tot_bare_parser (t1 & t2)) = fun b -> match p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match p2 b' with | Some (x2, consumed2) -> Some ((x1, x2), consumed1 + consumed2) | _ -> None end | _ -> None let tot_nondep_then #k1 #t1 p1 #k2 #t2 p2 = Classical.forall_intro (nondep_then_eq #k1 p1 #k2 p2); parser_kind_prop_ext (and_then_kind k1 k2) (nondep_then #k1 p1 #k2 p2) (tot_nondep_then_bare p1 p2); tot_nondep_then_bare p1 p2 let serialize_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) : Tot (serializer (nondep_then p1 p2)) = serialize_tagged_union s1 fst (fun x -> serialize_synth p2 (fun y -> (x, y) <: refine_with_tag fst x) s2 (fun (xy: refine_with_tag fst x) -> snd xy) ()) let serialize_nondep_then_eq (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (input: t1 * t2) : Lemma (serialize (serialize_nondep_then s1 s2) input == bare_serialize_nondep_then p1 s1 p2 s2 input) = () let length_serialize_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (input1: t1) (input2: t2) : Lemma (Seq.length (serialize (serialize_nondep_then s1 s2) (input1, input2)) == Seq.length (serialize s1 input1) + Seq.length (serialize s2 input2)) = () let serialize_nondep_then_upd_left (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) : Lemma (requires (Seq.length (serialize s1 y) == Seq.length (serialize s1 (fst x)))) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in Seq.length (serialize s1 y) <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s 0 (serialize s1 y) )) = let s = serialize (serialize_nondep_then s1 s2) x in seq_upd_seq_left s (serialize s1 y); let l1 = Seq.length (serialize s1 (fst x)) in Seq.lemma_split s l1; Seq.lemma_append_inj (Seq.slice s 0 l1) (Seq.slice s l1 (Seq.length s)) (serialize s1 (fst x)) (serialize s2 (snd x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.Combinators.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: LowParse.Spec.Base.serializer p1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2: LowParse.Spec.Base.serializer p2 -> x: (t1 * t2) -> y: t1 -> i': Prims.nat -> s': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires (let s1' = LowParse.Spec.Base.serialize s1 (FStar.Pervasives.Native.fst x) in i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length s1' /\ LowParse.Spec.Base.serialize s1 y == LowParse.Spec.Base.seq_upd_seq s1' i' s')) (ensures (let s = LowParse.Spec.Base.serialize (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) x in i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length s /\ LowParse.Spec.Base.serialize (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) (y, FStar.Pervasives.Native.snd x) == LowParse.Spec.Base.seq_upd_seq s i' s'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "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", "FStar.Pervasives.Native.tuple2", "Prims.nat", "LowParse.Bytes.bytes", "LowParse.Spec.Base.seq_upd_seq_slice_idem", "LowParse.Bytes.byte", "FStar.Seq.Base.length", "Prims.unit", "LowParse.Spec.Base.seq_upd_seq_right_to_left", "FStar.Seq.Properties.lemma_append_inj", "FStar.Seq.Base.slice", "LowParse.Spec.Base.serialize", "FStar.Pervasives.Native.snd", "FStar.Seq.Properties.lemma_split", "FStar.Pervasives.Native.fst", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then_upd_left", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Seq.Base.seq", "LowParse.Spec.Base.seq_upd_seq", "Prims.squash", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let serialize_nondep_then_upd_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i': nat) (s': bytes) : Lemma (requires (let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_seq s1' i' s')) (ensures (let s = serialize (serialize_nondep_then s1 s2) x in i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s i' s')) =
serialize_nondep_then_upd_left s1 s2 x y; let s = serialize (serialize_nondep_then s1 s2) x in let s1' = serialize s1 (fst x) in let l1 = Seq.length s1' in Seq.lemma_split s l1; Seq.lemma_append_inj (Seq.slice s 0 l1) (Seq.slice s l1 (Seq.length s)) s1' (serialize s2 (snd x)); seq_upd_seq_right_to_left s 0 s1' i' s'; seq_upd_seq_slice_idem s 0 (Seq.length s1')
false
Test.Vectors.Curve25519.fst
Test.Vectors.Curve25519.result5
val result5:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
val result5:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
let result5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
{ "file_name": "providers/test/vectors/Test.Vectors.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 156, "start_col": 0, "start_line": 153 }
module Test.Vectors.Curve25519 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let private_0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x77uy; 0x07uy; 0x6duy; 0x0auy; 0x73uy; 0x18uy; 0xa5uy; 0x7duy; 0x3cuy; 0x16uy; 0xc1uy; 0x72uy; 0x51uy; 0xb2uy; 0x66uy; 0x45uy; 0xdfuy; 0x4cuy; 0x2fuy; 0x87uy; 0xebuy; 0xc0uy; 0x99uy; 0x2auy; 0xb1uy; 0x77uy; 0xfbuy; 0xa5uy; 0x1duy; 0xb9uy; 0x2cuy; 0x2auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_0_len: (x:UInt32.t { UInt32.v x = B.length private_0 }) = 32ul let public0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xdeuy; 0x9euy; 0xdbuy; 0x7duy; 0x7buy; 0x7duy; 0xc1uy; 0xb4uy; 0xd3uy; 0x5buy; 0x61uy; 0xc2uy; 0xecuy; 0xe4uy; 0x35uy; 0x37uy; 0x3fuy; 0x83uy; 0x43uy; 0xc8uy; 0x5buy; 0x78uy; 0x67uy; 0x4duy; 0xaduy; 0xfcuy; 0x7euy; 0x14uy; 0x6fuy; 0x88uy; 0x2buy; 0x4fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public0_len: (x:UInt32.t { UInt32.v x = B.length public0 }) = 32ul let result0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result0_len: (x:UInt32.t { UInt32.v x = B.length result0 }) = 32ul inline_for_extraction let valid0 = true let private_1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x5duy; 0xabuy; 0x08uy; 0x7euy; 0x62uy; 0x4auy; 0x8auy; 0x4buy; 0x79uy; 0xe1uy; 0x7fuy; 0x8buy; 0x83uy; 0x80uy; 0x0euy; 0xe6uy; 0x6fuy; 0x3buy; 0xb1uy; 0x29uy; 0x26uy; 0x18uy; 0xb6uy; 0xfduy; 0x1cuy; 0x2fuy; 0x8buy; 0x27uy; 0xffuy; 0x88uy; 0xe0uy; 0xebuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_1_len: (x:UInt32.t { UInt32.v x = B.length private_1 }) = 32ul let public1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x85uy; 0x20uy; 0xf0uy; 0x09uy; 0x89uy; 0x30uy; 0xa7uy; 0x54uy; 0x74uy; 0x8buy; 0x7duy; 0xdcuy; 0xb4uy; 0x3euy; 0xf7uy; 0x5auy; 0x0duy; 0xbfuy; 0x3auy; 0x0duy; 0x26uy; 0x38uy; 0x1auy; 0xf4uy; 0xebuy; 0xa4uy; 0xa9uy; 0x8euy; 0xaauy; 0x9buy; 0x4euy; 0x6auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public1_len: (x:UInt32.t { UInt32.v x = B.length public1 }) = 32ul let result1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result1_len: (x:UInt32.t { UInt32.v x = B.length result1 }) = 32ul inline_for_extraction let valid1 = true let private_2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_2_len: (x:UInt32.t { UInt32.v x = B.length private_2 }) = 32ul let public2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x25uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public2_len: (x:UInt32.t { UInt32.v x = B.length public2 }) = 32ul let result2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x3cuy; 0x77uy; 0x77uy; 0xcauy; 0xf9uy; 0x97uy; 0xb2uy; 0x64uy; 0x41uy; 0x60uy; 0x77uy; 0x66uy; 0x5buy; 0x4euy; 0x22uy; 0x9duy; 0x0buy; 0x95uy; 0x48uy; 0xdcuy; 0x0cuy; 0xd8uy; 0x19uy; 0x98uy; 0xdduy; 0xcduy; 0xc5uy; 0xc8uy; 0x53uy; 0x3cuy; 0x79uy; 0x7fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result2_len: (x:UInt32.t { UInt32.v x = B.length result2 }) = 32ul inline_for_extraction let valid2 = true let private_3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_3_len: (x:UInt32.t { UInt32.v x = B.length private_3 }) = 32ul let public3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public3_len: (x:UInt32.t { UInt32.v x = B.length public3 }) = 32ul let result3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xb3uy; 0x2duy; 0x13uy; 0x62uy; 0xc2uy; 0x48uy; 0xd6uy; 0x2fuy; 0xe6uy; 0x26uy; 0x19uy; 0xcfuy; 0xf0uy; 0x4duy; 0xd4uy; 0x3duy; 0xb7uy; 0x3fuy; 0xfcuy; 0x1buy; 0x63uy; 0x08uy; 0xeduy; 0xe3uy; 0x0buy; 0x78uy; 0xd8uy; 0x73uy; 0x80uy; 0xf1uy; 0xe8uy; 0x34uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result3_len: (x:UInt32.t { UInt32.v x = B.length result3 }) = 32ul inline_for_extraction let valid3 = true let private_4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xa5uy; 0x46uy; 0xe3uy; 0x6buy; 0xf0uy; 0x52uy; 0x7cuy; 0x9duy; 0x3buy; 0x16uy; 0x15uy; 0x4buy; 0x82uy; 0x46uy; 0x5euy; 0xdduy; 0x62uy; 0x14uy; 0x4cuy; 0x0auy; 0xc1uy; 0xfcuy; 0x5auy; 0x18uy; 0x50uy; 0x6auy; 0x22uy; 0x44uy; 0xbauy; 0x44uy; 0x9auy; 0xc4uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_4_len: (x:UInt32.t { UInt32.v x = B.length private_4 }) = 32ul let public4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe6uy; 0xdbuy; 0x68uy; 0x67uy; 0x58uy; 0x30uy; 0x30uy; 0xdbuy; 0x35uy; 0x94uy; 0xc1uy; 0xa4uy; 0x24uy; 0xb1uy; 0x5fuy; 0x7cuy; 0x72uy; 0x66uy; 0x24uy; 0xecuy; 0x26uy; 0xb3uy; 0x35uy; 0x3buy; 0x10uy; 0xa9uy; 0x03uy; 0xa6uy; 0xd0uy; 0xabuy; 0x1cuy; 0x4cuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public4_len: (x:UInt32.t { UInt32.v x = B.length public4 }) = 32ul let result4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xc3uy; 0xdauy; 0x55uy; 0x37uy; 0x9duy; 0xe9uy; 0xc6uy; 0x90uy; 0x8euy; 0x94uy; 0xeauy; 0x4duy; 0xf2uy; 0x8duy; 0x08uy; 0x4fuy; 0x32uy; 0xecuy; 0xcfuy; 0x03uy; 0x49uy; 0x1cuy; 0x71uy; 0xf7uy; 0x54uy; 0xb4uy; 0x07uy; 0x55uy; 0x77uy; 0xa2uy; 0x85uy; 0x52uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result4_len: (x:UInt32.t { UInt32.v x = B.length result4 }) = 32ul inline_for_extraction let valid4 = true let private_5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_5_len: (x:UInt32.t { UInt32.v x = B.length private_5 }) = 32ul let public5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public5_len: (x:UInt32.t { UInt32.v x = B.length public5 }) = 32ul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.Buffer.buffer FStar.UInt8.t {LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "FStar.UInt8.t", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let result5:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
[@@ inline_let ]let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
false
LowParse.Spec.Combinators.fst
LowParse.Spec.Combinators.serialize_nondep_then_upd_right_chain
val serialize_nondep_then_upd_right_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t2) (i' : nat) (s' : bytes) : Lemma (requires ( let s2' = serialize s2 (snd x) in i' + Seq.length s' <= Seq.length s2' /\ serialize s2 y == seq_upd_seq s2' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in let l1 = Seq.length (serialize s1 (fst x)) in Seq.length s == l1 + Seq.length (serialize s2 (snd x)) /\ l1 + i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (fst x, y) == seq_upd_seq s (l1 + i') s' ))
val serialize_nondep_then_upd_right_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t2) (i' : nat) (s' : bytes) : Lemma (requires ( let s2' = serialize s2 (snd x) in i' + Seq.length s' <= Seq.length s2' /\ serialize s2 y == seq_upd_seq s2' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in let l1 = Seq.length (serialize s1 (fst x)) in Seq.length s == l1 + Seq.length (serialize s2 (snd x)) /\ l1 + i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (fst x, y) == seq_upd_seq s (l1 + i') s' ))
let serialize_nondep_then_upd_right_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t2) (i' : nat) (s' : bytes) : Lemma (requires ( let s2' = serialize s2 (snd x) in i' + Seq.length s' <= Seq.length s2' /\ serialize s2 y == seq_upd_seq s2' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in let l1 = Seq.length (serialize s1 (fst x)) in Seq.length s == l1 + Seq.length (serialize s2 (snd x)) /\ l1 + i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (fst x, y) == seq_upd_seq s (l1 + i') s' )) = serialize_nondep_then_upd_right s1 s2 x y; let s = serialize (serialize_nondep_then s1 s2) x in let s2' = serialize s2 (snd x) in let l2 = Seq.length s - Seq.length s2' in Seq.lemma_split s l2; Seq.lemma_append_inj (Seq.slice s 0 l2) (Seq.slice s l2 (Seq.length s)) (serialize s1 (fst x)) s2'; seq_upd_seq_right_to_left s l2 s2' i' s'; seq_upd_seq_slice_idem s l2 (Seq.length s)
{ "file_name": "src/lowparse/LowParse.Spec.Combinators.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 44, "end_line": 629, "start_col": 0, "start_line": 596 }
module LowParse.Spec.Combinators include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 module T = FStar.Tactics #reset-options "--using_facts_from '* -FStar.Tactis -FStar.Reflection'" let and_then #k #t p #k' #t' p' = let f : bare_parser t' = and_then_bare p p' in and_then_correct p p' ; f let and_then_eq (#k: parser_kind) (#t:Type) (p:parser k t) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (input: bytes) : Lemma (requires (and_then_cases_injective p')) (ensures (parse (and_then p p') input == and_then_bare p p' input)) = () let tot_and_then_bare (#t:Type) (#t':Type) (p:tot_bare_parser t) (p': (t -> Tot (tot_bare_parser t'))) : Tot (tot_bare_parser t') = fun (b: bytes) -> match p b with | Some (v, l) -> begin let p'v = p' v in let s' : bytes = Seq.slice b l (Seq.length b) in match p'v s' with | Some (v', l') -> let res : consumed_length b = l + l' in Some (v', res) | None -> None end | None -> None let tot_and_then #k #t p #k' #t' p' = let f : tot_bare_parser t' = tot_and_then_bare p p' in and_then_correct #k p #k' p' ; parser_kind_prop_ext (and_then_kind k k') (and_then_bare p p') f; f let parse_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) : Pure (parser k t2) (requires ( synth_injective f2 )) (ensures (fun _ -> True)) = coerce (parser k t2) (and_then p1 (fun v1 -> parse_fret f2 v1)) let parse_synth_eq (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (b: bytes) : Lemma (requires (synth_injective f2)) (ensures (parse (parse_synth p1 f2) b == parse_synth' p1 f2 b)) = () unfold let tot_parse_fret' (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_bare_parser t') = fun (b: bytes) -> Some (f v, (0 <: consumed_length b)) unfold let tot_parse_fret (#t #t':Type) (f: t -> Tot t') (v:t) : Tot (tot_parser parse_ret_kind t') = [@inline_let] let _ = parser_kind_prop_equiv parse_ret_kind (tot_parse_fret' f v) in tot_parse_fret' f v let tot_parse_synth #k #t1 #t2 p1 f2 = coerce (tot_parser k t2) (tot_and_then p1 (fun v1 -> tot_parse_fret f2 v1)) let bare_serialize_synth_correct #k #t1 #t2 p1 f2 s1 g1 = () let serialize_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer (parse_synth p1 f2)) = bare_serialize_synth_correct p1 f2 s1 g1; bare_serialize_synth p1 f2 s1 g1 let serialize_synth_eq (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x: t2) : Lemma (serialize (serialize_synth p1 f2 s1 g1 u) x == serialize s1 (g1 x)) = () let serialize_synth_upd_chain (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x1: t1) (x2: t2) (y1: t1) (y2: t2) (i': nat) (s' : bytes) : Lemma (requires ( let s = serialize s1 x1 in i' + Seq.length s' <= Seq.length s /\ serialize s1 y1 == seq_upd_seq s i' s' /\ x2 == f2 x1 /\ y2 == f2 y1 )) (ensures ( let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in i' + Seq.length s' <= Seq.length s /\ Seq.length s == Seq.length (serialize s1 x1) /\ serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_seq s i' s' )) = (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *) assert (forall w w' . f2 w == f2 w' ==> w == w'); assert (forall w . f2 (g1 w) == w) let serialize_synth_upd_bw_chain (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (g1: t2 -> GTot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) (x1: t1) (x2: t2) (y1: t1) (y2: t2) (i': nat) (s' : bytes) : Lemma (requires ( let s = serialize s1 x1 in i' + Seq.length s' <= Seq.length s /\ serialize s1 y1 == seq_upd_bw_seq s i' s' /\ x2 == f2 x1 /\ y2 == f2 y1 )) (ensures ( let s = serialize (serialize_synth p1 f2 s1 g1 u) x2 in i' + Seq.length s' <= Seq.length s /\ Seq.length s == Seq.length (serialize s1 x1) /\ serialize (serialize_synth p1 f2 s1 g1 u) y2 == seq_upd_bw_seq s i' s' )) = (* I don't know which are THE terms to exhibit among x1, x2, y1, y2 to make the patterns trigger *) assert (forall w w' . f2 w == f2 w' ==> w == w'); assert (forall w . f2 (g1 w) == w) let parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; pt `and_then` parse_tagged_union_payload tag_of_data p let parse_tagged_union_eq (#kt: parser_kind) (#tag_t: Type) (pt: parser kt tag_t) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (input: bytes) : Lemma (parse (parse_tagged_union pt tag_of_data p) input == (match parse pt input with | None -> None | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in begin match parse (p tg) input_tg with | Some (x, consumed_x) -> Some ((x <: data_t), consumed_tg + consumed_x) | None -> None end )) = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; and_then_eq pt (parse_tagged_union_payload tag_of_data p) input; match parse pt input with | None -> () | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in parse_synth_eq #k #(refine_with_tag tag_of_data tg) (p tg) (synth_tagged_union_data tag_of_data tg) input_tg let parse_tagged_union_eq_gen (#kt: parser_kind) (#tag_t: Type) (pt: parser kt tag_t) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (#kt': parser_kind) (pt': parser kt' tag_t) (lem_pt: ( (input: bytes) -> Lemma (parse pt input == parse pt' input) )) (k': (t: tag_t) -> Tot parser_kind) (p': (t: tag_t) -> Tot (parser (k' t) (refine_with_tag tag_of_data t))) (lem_p' : ( (k: tag_t) -> (input: bytes) -> Lemma (parse (p k) input == parse (p' k) input) )) (input: bytes) : Lemma (parse (parse_tagged_union pt tag_of_data p) input == bare_parse_tagged_union pt' tag_of_data k' p' input) = parse_tagged_union_payload_and_then_cases_injective tag_of_data p; and_then_eq pt (parse_tagged_union_payload tag_of_data p) input; lem_pt input; match parse pt input with | None -> () | Some (tg, consumed_tg) -> let input_tg = Seq.slice input consumed_tg (Seq.length input) in parse_synth_eq #k #(refine_with_tag tag_of_data tg) (p tg) (synth_tagged_union_data tag_of_data tg) input_tg; lem_p' tg input_tg let tot_parse_tagged_union #kt #tag_t pt #data_t tag_of_data #k p = parse_tagged_union_payload_and_then_cases_injective tag_of_data #k p; pt `tot_and_then` tot_parse_tagged_union_payload tag_of_data p let serialize_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (st: serializer pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (s: (t: tag_t) -> Tot (serializer (p t))) : Pure (serializer (parse_tagged_union pt tag_of_data p)) (requires (kt.parser_kind_subkind == Some ParserStrong)) (ensures (fun _ -> True)) = bare_serialize_tagged_union_correct st tag_of_data s; bare_serialize_tagged_union st tag_of_data s let serialize_tagged_union_eq (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (st: serializer pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (s: (t: tag_t) -> Tot (serializer (p t))) (input: data_t) : Lemma (requires (kt.parser_kind_subkind == Some ParserStrong)) (ensures (serialize (serialize_tagged_union st tag_of_data s) input == bare_serialize_tagged_union st tag_of_data s input)) [SMTPat (serialize (serialize_tagged_union st tag_of_data s) input)] = () let serialize_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> parser k2 (t2 x)) (s2: (x: t1) -> serializer (p2 x)) : Tot (serializer (parse_dtuple2 p1 p2)) = serialize_tagged_union s1 dfst (fun (x: t1) -> serialize_synth (p2 x) (synth_dtuple2 x) (s2 x) (synth_dtuple2_recip x) ()) let parse_dtuple2_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) (b: bytes) : Lemma (parse (parse_dtuple2 p1 p2) b == (match parse p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match parse (p2 x1) b' with | Some (x2, consumed2) -> Some ((| x1, x2 |), consumed1 + consumed2) | _ -> None end | _ -> None )) by (T.norm [delta_only [`%parse_dtuple2;]]) = () let serialize_dtuple2_eq (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> parser k2 (t2 x)) (s2: (x: t1) -> serializer (p2 x)) (xy: dtuple2 t1 t2) : Lemma (serialize (serialize_dtuple2 s1 s2) xy == serialize s1 (dfst xy) `Seq.append` serialize (s2 (dfst xy)) (dsnd xy)) = () (* Special case for non-dependent parsing *) let nondep_then (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) = parse_tagged_union p1 fst (fun x -> parse_synth p2 (fun y -> (x, y) <: refine_with_tag fst x)) #set-options "--z3rlimit 16" let nondep_then_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (b: bytes) : Lemma (parse (nondep_then p1 p2) b == (match parse p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match parse p2 b' with | Some (x2, consumed2) -> Some ((x1, x2), consumed1 + consumed2) | _ -> None end | _ -> None )) by (T.norm [delta_only [`%nondep_then;]]) = () let tot_nondep_then_bare (#t1: Type) (p1: tot_bare_parser t1) (#t2: Type) (p2: tot_bare_parser t2) : Tot (tot_bare_parser (t1 & t2)) = fun b -> match p1 b with | Some (x1, consumed1) -> let b' = Seq.slice b consumed1 (Seq.length b) in begin match p2 b' with | Some (x2, consumed2) -> Some ((x1, x2), consumed1 + consumed2) | _ -> None end | _ -> None let tot_nondep_then #k1 #t1 p1 #k2 #t2 p2 = Classical.forall_intro (nondep_then_eq #k1 p1 #k2 p2); parser_kind_prop_ext (and_then_kind k1 k2) (nondep_then #k1 p1 #k2 p2) (tot_nondep_then_bare p1 p2); tot_nondep_then_bare p1 p2 let serialize_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) : Tot (serializer (nondep_then p1 p2)) = serialize_tagged_union s1 fst (fun x -> serialize_synth p2 (fun y -> (x, y) <: refine_with_tag fst x) s2 (fun (xy: refine_with_tag fst x) -> snd xy) ()) let serialize_nondep_then_eq (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (input: t1 * t2) : Lemma (serialize (serialize_nondep_then s1 s2) input == bare_serialize_nondep_then p1 s1 p2 s2 input) = () let length_serialize_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (input1: t1) (input2: t2) : Lemma (Seq.length (serialize (serialize_nondep_then s1 s2) (input1, input2)) == Seq.length (serialize s1 input1) + Seq.length (serialize s2 input2)) = () let serialize_nondep_then_upd_left (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) : Lemma (requires (Seq.length (serialize s1 y) == Seq.length (serialize s1 (fst x)))) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in Seq.length (serialize s1 y) <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s 0 (serialize s1 y) )) = let s = serialize (serialize_nondep_then s1 s2) x in seq_upd_seq_left s (serialize s1 y); let l1 = Seq.length (serialize s1 (fst x)) in Seq.lemma_split s l1; Seq.lemma_append_inj (Seq.slice s 0 l1) (Seq.slice s l1 (Seq.length s)) (serialize s1 (fst x)) (serialize s2 (snd x)) let serialize_nondep_then_upd_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i' : nat) (s' : bytes) : Lemma (requires ( let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_seq s1' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_seq s i' s' )) = serialize_nondep_then_upd_left s1 s2 x y; let s = serialize (serialize_nondep_then s1 s2) x in let s1' = serialize s1 (fst x) in let l1 = Seq.length s1' in Seq.lemma_split s l1; Seq.lemma_append_inj (Seq.slice s 0 l1) (Seq.slice s l1 (Seq.length s)) s1' (serialize s2 (snd x)); seq_upd_seq_right_to_left s 0 s1' i' s'; seq_upd_seq_slice_idem s 0 (Seq.length s1') let serialize_nondep_then_upd_bw_left (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) : Lemma (requires (Seq.length (serialize s1 y) == Seq.length (serialize s1 (fst x)))) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in let len2 = Seq.length (serialize s2 (snd x)) in len2 + Seq.length (serialize s1 y) <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_bw_seq s len2 (serialize s1 y) )) = serialize_nondep_then_upd_left s1 s2 x y #reset-options "--z3refresh --z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Tactis -FStar.Reflection'" let serialize_nondep_then_upd_bw_left_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t1) (i' : nat) (s' : bytes) : Lemma (requires ( let s1' = serialize s1 (fst x) in i' + Seq.length s' <= Seq.length s1' /\ serialize s1 y == seq_upd_bw_seq s1' i' s' )) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in let len2 = Seq.length (serialize s2 (snd x)) in len2 + i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (y, snd x) == seq_upd_bw_seq s (len2 + i') s' )) = let j' = Seq.length (serialize s1 (fst x)) - i' - Seq.length s' in serialize_nondep_then_upd_left_chain s1 s2 x y j' s'; assert (j' == Seq.length (serialize (serialize_nondep_then s1 s2) x) - (Seq.length (serialize s2 (snd x)) + i') - Seq.length s') let serialize_nondep_then_upd_right (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t2) : Lemma (requires (Seq.length (serialize s2 y) == Seq.length (serialize s2 (snd x)))) (ensures ( let s = serialize (serialize_nondep_then s1 s2) x in Seq.length (serialize s2 y) <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (fst x, y) == seq_upd_seq s (Seq.length s - Seq.length (serialize s2 y)) (serialize s2 y) )) = let s = serialize (serialize_nondep_then s1 s2) x in seq_upd_seq_right s (serialize s2 y); let l2 = Seq.length s - Seq.length (serialize s2 (snd x)) in Seq.lemma_split s l2; Seq.lemma_append_inj (Seq.slice s 0 l2) (Seq.slice s l2 (Seq.length s)) (serialize s1 (fst x)) (serialize s2 (snd x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.Combinators.fst" }
[ { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": true, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: LowParse.Spec.Base.serializer p1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2: LowParse.Spec.Base.serializer p2 -> x: (t1 * t2) -> y: t2 -> i': Prims.nat -> s': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires (let s2' = LowParse.Spec.Base.serialize s2 (FStar.Pervasives.Native.snd x) in i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length s2' /\ LowParse.Spec.Base.serialize s2 y == LowParse.Spec.Base.seq_upd_seq s2' i' s')) (ensures (let s = LowParse.Spec.Base.serialize (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) x in let l1 = FStar.Seq.Base.length (LowParse.Spec.Base.serialize s1 (FStar.Pervasives.Native.fst x)) in FStar.Seq.Base.length s == l1 + FStar.Seq.Base.length (LowParse.Spec.Base.serialize s2 (FStar.Pervasives.Native.snd x)) /\ l1 + i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length s /\ LowParse.Spec.Base.serialize (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) (FStar.Pervasives.Native.fst x, y) == LowParse.Spec.Base.seq_upd_seq s (l1 + i') s'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "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", "FStar.Pervasives.Native.tuple2", "Prims.nat", "LowParse.Bytes.bytes", "LowParse.Spec.Base.seq_upd_seq_slice_idem", "LowParse.Bytes.byte", "FStar.Seq.Base.length", "Prims.unit", "LowParse.Spec.Base.seq_upd_seq_right_to_left", "FStar.Seq.Properties.lemma_append_inj", "FStar.Seq.Base.slice", "LowParse.Spec.Base.serialize", "FStar.Pervasives.Native.fst", "FStar.Seq.Properties.lemma_split", "Prims.int", "Prims.op_Subtraction", "FStar.Pervasives.Native.snd", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then_upd_right", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Seq.Base.seq", "LowParse.Spec.Base.seq_upd_seq", "Prims.squash", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let serialize_nondep_then_upd_right_chain (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2) (x: t1 * t2) (y: t2) (i': nat) (s': bytes) : Lemma (requires (let s2' = serialize s2 (snd x) in i' + Seq.length s' <= Seq.length s2' /\ serialize s2 y == seq_upd_seq s2' i' s')) (ensures (let s = serialize (serialize_nondep_then s1 s2) x in let l1 = Seq.length (serialize s1 (fst x)) in Seq.length s == l1 + Seq.length (serialize s2 (snd x)) /\ l1 + i' + Seq.length s' <= Seq.length s /\ serialize (serialize_nondep_then s1 s2) (fst x, y) == seq_upd_seq s (l1 + i') s')) =
serialize_nondep_then_upd_right s1 s2 x y; let s = serialize (serialize_nondep_then s1 s2) x in let s2' = serialize s2 (snd x) in let l2 = Seq.length s - Seq.length s2' in Seq.lemma_split s l2; Seq.lemma_append_inj (Seq.slice s 0 l2) (Seq.slice s l2 (Seq.length s)) (serialize s1 (fst x)) s2'; seq_upd_seq_right_to_left s l2 s2' i' s'; seq_upd_seq_slice_idem s l2 (Seq.length s)
false
Steel.ST.CancellableSpinLock.fst
Steel.ST.CancellableSpinLock.lock_inv_pred
val lock_inv_pred: r: ref bool -> v: vprop -> bool -> vprop
val lock_inv_pred: r: ref bool -> v: vprop -> bool -> vprop
let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop = fun b -> pts_to r full_perm b `star` (if b then v else emp)
{ "file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 31, "start_col": 0, "start_line": 30 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module Steel.ST.CancellableSpinLock open Steel.ST.Effect open Steel.ST.Util open Steel.FractionalPermission open Steel.ST.Reference open Steel.ST.SpinLock module G = FStar.Ghost
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.CancellableSpinLock.fst" }
[ { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.ST.Reference.ref Prims.bool -> v: Steel.Effect.Common.vprop -> _: Prims.bool -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.Reference.ref", "Prims.bool", "Steel.Effect.Common.vprop", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.emp" ]
[]
false
false
false
true
false
let lock_inv_pred (r: ref bool) (v: vprop) : bool -> vprop =
fun b -> (pts_to r full_perm b) `star` (if b then v else emp)
false
Test.Vectors.Curve25519.fst
Test.Vectors.Curve25519.vectors
val vectors:(b: B.buffer vector {B.length b = 7 /\ B.recallable b})
val vectors:(b: B.buffer vector {B.length b = 7 /\ B.recallable b})
let vectors: (b: B.buffer vector { B.length b = 7 /\ B.recallable b }) = [@inline_let] let l = [ Vector result0 result0_len public0 public0_len private_0 private_0_len valid0; Vector result1 result1_len public1 public1_len private_1 private_1_len valid1; Vector result2 result2_len public2 public2_len private_2 private_2_len valid2; Vector result3 result3_len public3 public3_len private_3 private_3_len valid3; Vector result4 result4_len public4 public4_len private_4 private_4_len valid4; Vector result5 result5_len public5 public5_len private_5 private_5_len valid5; Vector result6 result6_len public6 public6_len private_6 private_6_len valid6; ] in assert_norm (List.Tot.length l = 7); B.gcmalloc_of_list HyperStack.root l
{ "file_name": "providers/test/vectors/Test.Vectors.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 211, "start_col": 0, "start_line": 200 }
module Test.Vectors.Curve25519 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let private_0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x77uy; 0x07uy; 0x6duy; 0x0auy; 0x73uy; 0x18uy; 0xa5uy; 0x7duy; 0x3cuy; 0x16uy; 0xc1uy; 0x72uy; 0x51uy; 0xb2uy; 0x66uy; 0x45uy; 0xdfuy; 0x4cuy; 0x2fuy; 0x87uy; 0xebuy; 0xc0uy; 0x99uy; 0x2auy; 0xb1uy; 0x77uy; 0xfbuy; 0xa5uy; 0x1duy; 0xb9uy; 0x2cuy; 0x2auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_0_len: (x:UInt32.t { UInt32.v x = B.length private_0 }) = 32ul let public0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xdeuy; 0x9euy; 0xdbuy; 0x7duy; 0x7buy; 0x7duy; 0xc1uy; 0xb4uy; 0xd3uy; 0x5buy; 0x61uy; 0xc2uy; 0xecuy; 0xe4uy; 0x35uy; 0x37uy; 0x3fuy; 0x83uy; 0x43uy; 0xc8uy; 0x5buy; 0x78uy; 0x67uy; 0x4duy; 0xaduy; 0xfcuy; 0x7euy; 0x14uy; 0x6fuy; 0x88uy; 0x2buy; 0x4fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public0_len: (x:UInt32.t { UInt32.v x = B.length public0 }) = 32ul let result0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result0_len: (x:UInt32.t { UInt32.v x = B.length result0 }) = 32ul inline_for_extraction let valid0 = true let private_1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x5duy; 0xabuy; 0x08uy; 0x7euy; 0x62uy; 0x4auy; 0x8auy; 0x4buy; 0x79uy; 0xe1uy; 0x7fuy; 0x8buy; 0x83uy; 0x80uy; 0x0euy; 0xe6uy; 0x6fuy; 0x3buy; 0xb1uy; 0x29uy; 0x26uy; 0x18uy; 0xb6uy; 0xfduy; 0x1cuy; 0x2fuy; 0x8buy; 0x27uy; 0xffuy; 0x88uy; 0xe0uy; 0xebuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_1_len: (x:UInt32.t { UInt32.v x = B.length private_1 }) = 32ul let public1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x85uy; 0x20uy; 0xf0uy; 0x09uy; 0x89uy; 0x30uy; 0xa7uy; 0x54uy; 0x74uy; 0x8buy; 0x7duy; 0xdcuy; 0xb4uy; 0x3euy; 0xf7uy; 0x5auy; 0x0duy; 0xbfuy; 0x3auy; 0x0duy; 0x26uy; 0x38uy; 0x1auy; 0xf4uy; 0xebuy; 0xa4uy; 0xa9uy; 0x8euy; 0xaauy; 0x9buy; 0x4euy; 0x6auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public1_len: (x:UInt32.t { UInt32.v x = B.length public1 }) = 32ul let result1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result1_len: (x:UInt32.t { UInt32.v x = B.length result1 }) = 32ul inline_for_extraction let valid1 = true let private_2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_2_len: (x:UInt32.t { UInt32.v x = B.length private_2 }) = 32ul let public2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x25uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public2_len: (x:UInt32.t { UInt32.v x = B.length public2 }) = 32ul let result2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x3cuy; 0x77uy; 0x77uy; 0xcauy; 0xf9uy; 0x97uy; 0xb2uy; 0x64uy; 0x41uy; 0x60uy; 0x77uy; 0x66uy; 0x5buy; 0x4euy; 0x22uy; 0x9duy; 0x0buy; 0x95uy; 0x48uy; 0xdcuy; 0x0cuy; 0xd8uy; 0x19uy; 0x98uy; 0xdduy; 0xcduy; 0xc5uy; 0xc8uy; 0x53uy; 0x3cuy; 0x79uy; 0x7fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result2_len: (x:UInt32.t { UInt32.v x = B.length result2 }) = 32ul inline_for_extraction let valid2 = true let private_3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_3_len: (x:UInt32.t { UInt32.v x = B.length private_3 }) = 32ul let public3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public3_len: (x:UInt32.t { UInt32.v x = B.length public3 }) = 32ul let result3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xb3uy; 0x2duy; 0x13uy; 0x62uy; 0xc2uy; 0x48uy; 0xd6uy; 0x2fuy; 0xe6uy; 0x26uy; 0x19uy; 0xcfuy; 0xf0uy; 0x4duy; 0xd4uy; 0x3duy; 0xb7uy; 0x3fuy; 0xfcuy; 0x1buy; 0x63uy; 0x08uy; 0xeduy; 0xe3uy; 0x0buy; 0x78uy; 0xd8uy; 0x73uy; 0x80uy; 0xf1uy; 0xe8uy; 0x34uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result3_len: (x:UInt32.t { UInt32.v x = B.length result3 }) = 32ul inline_for_extraction let valid3 = true let private_4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xa5uy; 0x46uy; 0xe3uy; 0x6buy; 0xf0uy; 0x52uy; 0x7cuy; 0x9duy; 0x3buy; 0x16uy; 0x15uy; 0x4buy; 0x82uy; 0x46uy; 0x5euy; 0xdduy; 0x62uy; 0x14uy; 0x4cuy; 0x0auy; 0xc1uy; 0xfcuy; 0x5auy; 0x18uy; 0x50uy; 0x6auy; 0x22uy; 0x44uy; 0xbauy; 0x44uy; 0x9auy; 0xc4uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_4_len: (x:UInt32.t { UInt32.v x = B.length private_4 }) = 32ul let public4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe6uy; 0xdbuy; 0x68uy; 0x67uy; 0x58uy; 0x30uy; 0x30uy; 0xdbuy; 0x35uy; 0x94uy; 0xc1uy; 0xa4uy; 0x24uy; 0xb1uy; 0x5fuy; 0x7cuy; 0x72uy; 0x66uy; 0x24uy; 0xecuy; 0x26uy; 0xb3uy; 0x35uy; 0x3buy; 0x10uy; 0xa9uy; 0x03uy; 0xa6uy; 0xd0uy; 0xabuy; 0x1cuy; 0x4cuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public4_len: (x:UInt32.t { UInt32.v x = B.length public4 }) = 32ul let result4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xc3uy; 0xdauy; 0x55uy; 0x37uy; 0x9duy; 0xe9uy; 0xc6uy; 0x90uy; 0x8euy; 0x94uy; 0xeauy; 0x4duy; 0xf2uy; 0x8duy; 0x08uy; 0x4fuy; 0x32uy; 0xecuy; 0xcfuy; 0x03uy; 0x49uy; 0x1cuy; 0x71uy; 0xf7uy; 0x54uy; 0xb4uy; 0x07uy; 0x55uy; 0x77uy; 0xa2uy; 0x85uy; 0x52uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result4_len: (x:UInt32.t { UInt32.v x = B.length result4 }) = 32ul inline_for_extraction let valid4 = true let private_5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_5_len: (x:UInt32.t { UInt32.v x = B.length private_5 }) = 32ul let public5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public5_len: (x:UInt32.t { UInt32.v x = B.length public5 }) = 32ul let result5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result5_len: (x:UInt32.t { UInt32.v x = B.length result5 }) = 32ul inline_for_extraction let valid5 = false let private_6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x02uy; 0x04uy; 0x06uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_6_len: (x:UInt32.t { UInt32.v x = B.length private_6 }) = 32ul let public6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe0uy; 0xebuy; 0x7auy; 0x7cuy; 0x3buy; 0x41uy; 0xb8uy; 0xaeuy; 0x16uy; 0x56uy; 0xe3uy; 0xfauy; 0xf1uy; 0x9fuy; 0xc4uy; 0x6auy; 0xdauy; 0x09uy; 0x8duy; 0xebuy; 0x9cuy; 0x32uy; 0xb1uy; 0xfduy; 0x86uy; 0x62uy; 0x05uy; 0x16uy; 0x5fuy; 0x49uy; 0xb8uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public6_len: (x:UInt32.t { UInt32.v x = B.length public6 }) = 32ul let result6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result6_len: (x:UInt32.t { UInt32.v x = B.length result6 }) = 32ul inline_for_extraction let valid6 = false noeq type vector = | Vector: result: B.buffer UInt8.t { B.recallable result } -> result_len: UInt32.t { B.length result = UInt32.v result_len } -> public: B.buffer UInt8.t { B.recallable public } -> public_len: UInt32.t { B.length public = UInt32.v public_len } -> private_: B.buffer UInt8.t { B.recallable private_ } -> private__len: UInt32.t { B.length private_ = UInt32.v private__len } -> valid: bool -> vector
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.Buffer.buffer Test.Vectors.Curve25519.vector {LowStar.Monotonic.Buffer.length b = 7 /\ LowStar.Monotonic.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "Test.Vectors.Curve25519.vector", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "Test.Vectors.Curve25519.Vector", "Test.Vectors.Curve25519.result0", "Test.Vectors.Curve25519.result0_len", "Test.Vectors.Curve25519.public0", "Test.Vectors.Curve25519.public0_len", "Test.Vectors.Curve25519.private_0", "Test.Vectors.Curve25519.private_0_len", "Test.Vectors.Curve25519.valid0", "Test.Vectors.Curve25519.result1", "Test.Vectors.Curve25519.result1_len", "Test.Vectors.Curve25519.public1", "Test.Vectors.Curve25519.public1_len", "Test.Vectors.Curve25519.private_1", "Test.Vectors.Curve25519.private_1_len", "Test.Vectors.Curve25519.valid1", "Test.Vectors.Curve25519.result2", "Test.Vectors.Curve25519.result2_len", "Test.Vectors.Curve25519.public2", "Test.Vectors.Curve25519.public2_len", "Test.Vectors.Curve25519.private_2", "Test.Vectors.Curve25519.private_2_len", "Test.Vectors.Curve25519.valid2", "Test.Vectors.Curve25519.result3", "Test.Vectors.Curve25519.result3_len", "Test.Vectors.Curve25519.public3", "Test.Vectors.Curve25519.public3_len", "Test.Vectors.Curve25519.private_3", "Test.Vectors.Curve25519.private_3_len", "Test.Vectors.Curve25519.valid3", "Test.Vectors.Curve25519.result4", "Test.Vectors.Curve25519.result4_len", "Test.Vectors.Curve25519.public4", "Test.Vectors.Curve25519.public4_len", "Test.Vectors.Curve25519.private_4", "Test.Vectors.Curve25519.private_4_len", "Test.Vectors.Curve25519.valid4", "Test.Vectors.Curve25519.result5", "Test.Vectors.Curve25519.result5_len", "Test.Vectors.Curve25519.public5", "Test.Vectors.Curve25519.public5_len", "Test.Vectors.Curve25519.private_5", "Test.Vectors.Curve25519.private_5_len", "Test.Vectors.Curve25519.valid5", "Test.Vectors.Curve25519.result6", "Test.Vectors.Curve25519.result6_len", "Test.Vectors.Curve25519.public6", "Test.Vectors.Curve25519.public6_len", "Test.Vectors.Curve25519.private_6", "Test.Vectors.Curve25519.private_6_len", "Test.Vectors.Curve25519.valid6", "Prims.Nil" ]
[]
false
false
false
false
false
let vectors:(b: B.buffer vector {B.length b = 7 /\ B.recallable b}) =
[@@ inline_let ]let l = [ Vector result0 result0_len public0 public0_len private_0 private_0_len valid0; Vector result1 result1_len public1 public1_len private_1 private_1_len valid1; Vector result2 result2_len public2 public2_len private_2 private_2_len valid2; Vector result3 result3_len public3 public3_len private_3 private_3_len valid3; Vector result4 result4_len public4 public4_len private_4 private_4_len valid4; Vector result5 result5_len public5 public5_len private_5 private_5_len valid5; Vector result6 result6_len public6 public6_len private_6 private_6_len valid6 ] in assert_norm (List.Tot.length l = 7); B.gcmalloc_of_list HyperStack.root l
false
Steel.ST.CancellableSpinLock.fst
Steel.ST.CancellableSpinLock.can_release
val can_release (#v:vprop) (c:cancellable_lock v) : vprop
val can_release (#v:vprop) (c:cancellable_lock v) : vprop
let can_release #v c = pts_to c.lref full_perm true
{ "file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 49, "start_col": 0, "start_line": 49 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module Steel.ST.CancellableSpinLock open Steel.ST.Effect open Steel.ST.Util open Steel.FractionalPermission open Steel.ST.Reference open Steel.ST.SpinLock module G = FStar.Ghost [@@__reduce__] let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop = fun b -> pts_to r full_perm b `star` (if b then v else emp) [@@__reduce__] let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v) noeq type cancellable_lock (v:vprop) = { lref : ref bool; llock : lock (lock_inv lref v) } let new_cancellable_lock v = let r = alloc true in intro_exists true (lock_inv_pred r v); let l = new_lock (lock_inv r v) in return ({lref = r; llock = l})
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.CancellableSpinLock.fst" }
[ { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Steel.ST.CancellableSpinLock.cancellable_lock v -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.ST.CancellableSpinLock.cancellable_lock", "Steel.ST.Reference.pts_to", "Prims.bool", "Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__lref", "Steel.FractionalPermission.full_perm" ]
[]
false
false
false
false
false
let can_release #v c =
pts_to c.lref full_perm true
false
Test.Vectors.Curve25519.fst
Test.Vectors.Curve25519.private_6
val private_6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
val private_6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
let private_6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x02uy; 0x04uy; 0x06uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
{ "file_name": "providers/test/vectors/Test.Vectors.Curve25519.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 166, "start_col": 0, "start_line": 163 }
module Test.Vectors.Curve25519 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let private_0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x77uy; 0x07uy; 0x6duy; 0x0auy; 0x73uy; 0x18uy; 0xa5uy; 0x7duy; 0x3cuy; 0x16uy; 0xc1uy; 0x72uy; 0x51uy; 0xb2uy; 0x66uy; 0x45uy; 0xdfuy; 0x4cuy; 0x2fuy; 0x87uy; 0xebuy; 0xc0uy; 0x99uy; 0x2auy; 0xb1uy; 0x77uy; 0xfbuy; 0xa5uy; 0x1duy; 0xb9uy; 0x2cuy; 0x2auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_0_len: (x:UInt32.t { UInt32.v x = B.length private_0 }) = 32ul let public0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xdeuy; 0x9euy; 0xdbuy; 0x7duy; 0x7buy; 0x7duy; 0xc1uy; 0xb4uy; 0xd3uy; 0x5buy; 0x61uy; 0xc2uy; 0xecuy; 0xe4uy; 0x35uy; 0x37uy; 0x3fuy; 0x83uy; 0x43uy; 0xc8uy; 0x5buy; 0x78uy; 0x67uy; 0x4duy; 0xaduy; 0xfcuy; 0x7euy; 0x14uy; 0x6fuy; 0x88uy; 0x2buy; 0x4fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public0_len: (x:UInt32.t { UInt32.v x = B.length public0 }) = 32ul let result0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result0_len: (x:UInt32.t { UInt32.v x = B.length result0 }) = 32ul inline_for_extraction let valid0 = true let private_1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x5duy; 0xabuy; 0x08uy; 0x7euy; 0x62uy; 0x4auy; 0x8auy; 0x4buy; 0x79uy; 0xe1uy; 0x7fuy; 0x8buy; 0x83uy; 0x80uy; 0x0euy; 0xe6uy; 0x6fuy; 0x3buy; 0xb1uy; 0x29uy; 0x26uy; 0x18uy; 0xb6uy; 0xfduy; 0x1cuy; 0x2fuy; 0x8buy; 0x27uy; 0xffuy; 0x88uy; 0xe0uy; 0xebuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_1_len: (x:UInt32.t { UInt32.v x = B.length private_1 }) = 32ul let public1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x85uy; 0x20uy; 0xf0uy; 0x09uy; 0x89uy; 0x30uy; 0xa7uy; 0x54uy; 0x74uy; 0x8buy; 0x7duy; 0xdcuy; 0xb4uy; 0x3euy; 0xf7uy; 0x5auy; 0x0duy; 0xbfuy; 0x3auy; 0x0duy; 0x26uy; 0x38uy; 0x1auy; 0xf4uy; 0xebuy; 0xa4uy; 0xa9uy; 0x8euy; 0xaauy; 0x9buy; 0x4euy; 0x6auy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public1_len: (x:UInt32.t { UInt32.v x = B.length public1 }) = 32ul let result1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4auy; 0x5duy; 0x9duy; 0x5buy; 0xa4uy; 0xceuy; 0x2duy; 0xe1uy; 0x72uy; 0x8euy; 0x3buy; 0xf4uy; 0x80uy; 0x35uy; 0x0fuy; 0x25uy; 0xe0uy; 0x7euy; 0x21uy; 0xc9uy; 0x47uy; 0xd1uy; 0x9euy; 0x33uy; 0x76uy; 0xf0uy; 0x9buy; 0x3cuy; 0x1euy; 0x16uy; 0x17uy; 0x42uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result1_len: (x:UInt32.t { UInt32.v x = B.length result1 }) = 32ul inline_for_extraction let valid1 = true let private_2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_2_len: (x:UInt32.t { UInt32.v x = B.length private_2 }) = 32ul let public2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x25uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public2_len: (x:UInt32.t { UInt32.v x = B.length public2 }) = 32ul let result2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x3cuy; 0x77uy; 0x77uy; 0xcauy; 0xf9uy; 0x97uy; 0xb2uy; 0x64uy; 0x41uy; 0x60uy; 0x77uy; 0x66uy; 0x5buy; 0x4euy; 0x22uy; 0x9duy; 0x0buy; 0x95uy; 0x48uy; 0xdcuy; 0x0cuy; 0xd8uy; 0x19uy; 0x98uy; 0xdduy; 0xcduy; 0xc5uy; 0xc8uy; 0x53uy; 0x3cuy; 0x79uy; 0x7fuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result2_len: (x:UInt32.t { UInt32.v x = B.length result2 }) = 32ul inline_for_extraction let valid2 = true let private_3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_3_len: (x:UInt32.t { UInt32.v x = B.length private_3 }) = 32ul let public3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public3_len: (x:UInt32.t { UInt32.v x = B.length public3 }) = 32ul let result3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xb3uy; 0x2duy; 0x13uy; 0x62uy; 0xc2uy; 0x48uy; 0xd6uy; 0x2fuy; 0xe6uy; 0x26uy; 0x19uy; 0xcfuy; 0xf0uy; 0x4duy; 0xd4uy; 0x3duy; 0xb7uy; 0x3fuy; 0xfcuy; 0x1buy; 0x63uy; 0x08uy; 0xeduy; 0xe3uy; 0x0buy; 0x78uy; 0xd8uy; 0x73uy; 0x80uy; 0xf1uy; 0xe8uy; 0x34uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result3_len: (x:UInt32.t { UInt32.v x = B.length result3 }) = 32ul inline_for_extraction let valid3 = true let private_4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xa5uy; 0x46uy; 0xe3uy; 0x6buy; 0xf0uy; 0x52uy; 0x7cuy; 0x9duy; 0x3buy; 0x16uy; 0x15uy; 0x4buy; 0x82uy; 0x46uy; 0x5euy; 0xdduy; 0x62uy; 0x14uy; 0x4cuy; 0x0auy; 0xc1uy; 0xfcuy; 0x5auy; 0x18uy; 0x50uy; 0x6auy; 0x22uy; 0x44uy; 0xbauy; 0x44uy; 0x9auy; 0xc4uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_4_len: (x:UInt32.t { UInt32.v x = B.length private_4 }) = 32ul let public4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xe6uy; 0xdbuy; 0x68uy; 0x67uy; 0x58uy; 0x30uy; 0x30uy; 0xdbuy; 0x35uy; 0x94uy; 0xc1uy; 0xa4uy; 0x24uy; 0xb1uy; 0x5fuy; 0x7cuy; 0x72uy; 0x66uy; 0x24uy; 0xecuy; 0x26uy; 0xb3uy; 0x35uy; 0x3buy; 0x10uy; 0xa9uy; 0x03uy; 0xa6uy; 0xd0uy; 0xabuy; 0x1cuy; 0x4cuy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public4_len: (x:UInt32.t { UInt32.v x = B.length public4 }) = 32ul let result4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0xc3uy; 0xdauy; 0x55uy; 0x37uy; 0x9duy; 0xe9uy; 0xc6uy; 0x90uy; 0x8euy; 0x94uy; 0xeauy; 0x4duy; 0xf2uy; 0x8duy; 0x08uy; 0x4fuy; 0x32uy; 0xecuy; 0xcfuy; 0x03uy; 0x49uy; 0x1cuy; 0x71uy; 0xf7uy; 0x54uy; 0xb4uy; 0x07uy; 0x55uy; 0x77uy; 0xa2uy; 0x85uy; 0x52uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result4_len: (x:UInt32.t { UInt32.v x = B.length result4 }) = 32ul inline_for_extraction let valid4 = true let private_5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let private_5_len: (x:UInt32.t { UInt32.v x = B.length private_5 }) = 32ul let public5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let public5_len: (x:UInt32.t { UInt32.v x = B.length public5 }) = 32ul let result5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let result5_len: (x:UInt32.t { UInt32.v x = B.length result5 }) = 32ul inline_for_extraction let valid5 = false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Curve25519.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.Buffer.buffer FStar.UInt8.t {LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.gcmalloc_of_list", "FStar.UInt8.t", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let private_6:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
[@@ inline_let ]let l = [ 0x02uy; 0x04uy; 0x06uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
false
Steel.ST.Array.fst
Steel.ST.Array.pts_to_range_upd
val pts_to_range_upd (#elt: Type0) (#s: Ghost.erased (Seq.seq elt)) (a: array elt) (i: Ghost.erased nat) (m: US.t) (j: Ghost.erased nat) (x: elt) : ST (Ghost.erased (Seq.seq elt)) (pts_to_range a i j full_perm s) (fun s' -> pts_to_range a i j full_perm s') (i <= US.v m /\ US.v m < j) (fun s' -> i <= US.v m /\ US.v m < j /\ Seq.length s == j - i /\ Ghost.reveal s' == Seq.upd s (US.v m - i) x )
val pts_to_range_upd (#elt: Type0) (#s: Ghost.erased (Seq.seq elt)) (a: array elt) (i: Ghost.erased nat) (m: US.t) (j: Ghost.erased nat) (x: elt) : ST (Ghost.erased (Seq.seq elt)) (pts_to_range a i j full_perm s) (fun s' -> pts_to_range a i j full_perm s') (i <= US.v m /\ US.v m < j) (fun s' -> i <= US.v m /\ US.v m < j /\ Seq.length s == j - i /\ Ghost.reveal s' == Seq.upd s (US.v m - i) x )
let pts_to_range_upd #elt #s a i m j x = length_fits a; pts_to_range_prop a i j full_perm s; pts_to_range_split a i (US.v m) j; let s1 = elim_exists () in let s2 = elim_exists () in elim_pure _; let ga' = pts_to_range_elim' a (US.v m) j full_perm s2 in let a' = array_slice_impl a m j () in vpattern_rewrite #_ #(array elt) #ga' (fun ga' -> pts_to ga' _ _) a'; pts_to_length a' s2; let s2' = upd' a' 0sz x in pts_to_range_intro' a (US.v m) j full_perm a' s2'; pts_to_range_join a i (US.v m) j; let s' = vpattern_replace_erased (pts_to_range a i j full_perm) in assert (Ghost.reveal s' `Seq.equal` Seq.upd s (US.v m - i) x); noop (); return s'
{ "file_name": "lib/steel/Steel.ST.Array.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 723, "start_col": 0, "start_line": 705 }
(* Copyright 2020, 2021, 2022 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.ST.Array module US = FStar.SizeT /// Lifting a value of universe 0 to universe 1. We use /// FStar.Universe, since FStar.Extraction.Krml is set to extract /// those functions to identity. inline_for_extraction [@@ noextract_to "krml"] let raise_t (t: Type0) : Type u#1 = FStar.Universe.raise_t t inline_for_extraction [@@noextract_to "krml"] let raise (#t: Type) (x: t) : Tot (raise_t t) = FStar.Universe.raise_val x inline_for_extraction [@@noextract_to "krml"] let lower (#t: Type) (x: raise_t t) : Tot t = FStar.Universe.downgrade_val x /// A map operation on sequences. Here we only need Ghost versions, /// because such sequences are only used in vprops or with their /// selectors. let rec seq_map (#t: Type u#a) (#t' : Type u#b) (f: (t -> GTot t')) (s: Seq.seq t) : Ghost (Seq.seq t') (requires True) (ensures (fun s' -> Seq.length s' == Seq.length s /\ (forall i . {:pattern (Seq.index s' i)} Seq.index s' i == f (Seq.index s i)) )) (decreases (Seq.length s)) = if Seq.length s = 0 then Seq.empty else Seq.cons (f (Seq.index s 0)) (seq_map f (Seq.slice s 1 (Seq.length s))) let seq_map_append (#t: Type u#a) (#t': Type u#b) (f: (t -> GTot t')) (s1 s2: Seq.seq t) : Lemma (seq_map f (s1 `Seq.append` s2) `Seq.equal` (seq_map f s1 `Seq.append` seq_map f s2)) = () let seq_map_raise_inj (#elt: Type0) (s1 s2: Seq.seq elt) : Lemma (requires (seq_map raise s1 == seq_map raise s2)) (ensures (s1 == s2)) [SMTPat (seq_map raise s1); SMTPat (seq_map raise s2)] = assert (seq_map lower (seq_map raise s1) `Seq.equal` s1); assert (seq_map lower (seq_map raise s2) `Seq.equal` s2) /// Implementation of the interface /// base, ptr, array, pts_to module H = Steel.ST.HigherArray let base_t elt = H.base_t (raise_t elt) let base_len b = H.base_len b let ptr elt = H.ptr (raise_t elt) let null_ptr elt = H.null_ptr (raise_t elt) let is_null_ptr p = H.is_null_ptr p let base p = H.base p let offset p = H.offset p let ptr_base_offset_inj p1 p2 = H.ptr_base_offset_inj p1 p2 let base_len_null_ptr elt = H.base_len_null_ptr (raise_t elt) let length_fits a = H.length_fits a let pts_to a p s = H.pts_to a p (seq_map raise s) let pts_to_length a s = H.pts_to_length a _ let h_array_eq' (#t: Type u#1) (a1 a2: H.array t) : Lemma (requires ( dfst a1 == dfst a2 /\ (Ghost.reveal (dsnd a1) <: nat) == Ghost.reveal (dsnd a2) )) (ensures ( a1 == a2 )) = () let pts_to_not_null #_ #t #p a s = let _ = H.pts_to_not_null #_ #_ #p a (seq_map raise s) in assert (a =!= H.null #(raise_t t)); Classical.move_requires (h_array_eq' a) (H.null #(raise_t t)); noop () let pts_to_inj a p1 s1 p2 s2 = H.pts_to_inj a p1 (seq_map raise s1) p2 (seq_map raise s2) /// Non-selector operations. let malloc x n = let res = H.malloc (raise x) n in assert (seq_map raise (Seq.create (US.v n) x) `Seq.equal` Seq.create (US.v n) (raise x)); rewrite (H.pts_to res _ _) (pts_to res _ _); return res let free #_ x = let s = elim_exists () in rewrite (pts_to x _ _) (H.pts_to x P.full_perm (seq_map raise s)); H.free x let share #_ #_ #x a p p1 p2 = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); H.share a p p1 p2; rewrite (H.pts_to a p1 _) (pts_to a p1 x); rewrite (H.pts_to a p2 _) (pts_to a p2 x) let gather #_ #_ a #x1 p1 #x2 p2 = rewrite (pts_to a p1 _) (H.pts_to a p1 (seq_map raise x1)); rewrite (pts_to a p2 _) (H.pts_to a p2 (seq_map raise x2)); H.gather a p1 p2; rewrite (H.pts_to a _ _) (pts_to _ _ _) let index #_ #p a #s i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise s)); let res = H.index a i in rewrite (H.pts_to _ _ _) (pts_to _ _ _); return (lower res) let upd #_ a #s i v = rewrite (pts_to a _ _) (H.pts_to a P.full_perm (seq_map raise s)); H.upd a i (raise v); assert (seq_map raise (Seq.upd s (US.v i) v) `Seq.equal` Seq.upd (seq_map raise s) (US.v i) (raise v)); rewrite (H.pts_to _ _ _) (pts_to _ _ _) let ghost_join #_ #_ #x1 #x2 #p a1 a2 h = rewrite (pts_to a1 _ _) (H.pts_to a1 p (seq_map raise x1)); rewrite (pts_to a2 _ _) (H.pts_to a2 p (seq_map raise x2)); H.ghost_join a1 a2 h; assert (seq_map raise (x1 `Seq.append` x2) `Seq.equal` (seq_map raise x1 `Seq.append` seq_map raise x2)); rewrite (H.pts_to _ _ _) (H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2))); rewrite (H.pts_to _ _ _) (pts_to (merge a1 a2) _ _) let ptr_shift p off = H.ptr_shift p off let ghost_split #_ #_ #x #p a i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); let _ = H.ghost_split a i in //H.ghost_split a i; assert (seq_map raise (Seq.slice x 0 (US.v i)) `Seq.equal` Seq.slice (seq_map raise x) 0 (US.v i)); rewrite (H.pts_to (H.split_l a i) _ _) (H.pts_to (split_l a i) p (seq_map raise (Seq.slice x 0 (US.v i)))); rewrite (H.pts_to (split_l a i) _ _) (pts_to (split_l a i) _ _); assert (seq_map raise (Seq.slice x (US.v i) (Seq.length x)) `Seq.equal` Seq.slice (seq_map raise x) (US.v i) (Seq.length (seq_map raise x))); Seq.lemma_split x (US.v i); rewrite (H.pts_to (H.split_r a i) _ _) (H.pts_to (split_r a i) p (seq_map raise (Seq.slice x (US.v i) (Seq.length x)))); rewrite (H.pts_to (split_r a i) _ _) (pts_to (split_r a i) _ _) let memcpy a0 a1 l = H.memcpy a0 a1 l //////////////////////////////////////////////////////////////////////////////// // compare //////////////////////////////////////////////////////////////////////////////// module R = Steel.ST.Reference #push-options "--fuel 0 --ifuel 1 --z3rlimit_factor 2" let equal_up_to #t (s0: Seq.seq t) (s1: Seq.seq t) (v : option US.t) : prop = Seq.length s0 = Seq.length s1 /\ (match v with | None -> Ghost.reveal s0 =!= Ghost.reveal s1 | Some v -> US.v v <= Seq.length s0 /\ Seq.slice s0 0 (US.v v) `Seq.equal` Seq.slice s1 0 (US.v v)) let within_bounds (x:option US.t) (l:US.t) (b:Ghost.erased bool) : prop = if b then Some? x /\ US.(Some?.v x <^ l) else None? x \/ US.(Some?.v x >=^ l) let compare_inv (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (s0: Seq.seq t) (s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) = pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) let elim_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (b: bool) : STGhostT (Ghost.erased (option US.t)) o (compare_inv a0 a1 s0 s1 l ctr b) (fun x -> let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l b)) = let open US in assert_spinoff ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b)))); rewrite (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr b) (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l b))); let _v = elim_exists () in _v let intro_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) (b:bool { within_bounds x l b }) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> compare_inv a0 a1 s0 s1 l ctr (Ghost.hide b)) = let open US in intro_pure (within_bounds x l (Ghost.hide b)); intro_exists_erased x (fun (x:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x) `star` pure (within_bounds x l (Ghost.hide b))); assert_norm ((compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) == (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b))))); rewrite (pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` exists_ (fun (v:option US.t) -> R.pts_to ctr Steel.FractionalPermission.full_perm v `star` pure (equal_up_to s0 s1 v) `star` pure (within_bounds v l (Ghost.hide b)))) (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) let intro_exists_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) (x: Ghost.erased (option US.t)) : STGhostT unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm x `star` pure (equal_up_to s0 s1 x)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) = let b : bool = match Ghost.reveal x with | None -> false | Some x -> US.(x <^ l) in assert (within_bounds x l b); intro_compare_inv #_ #_ #p0 #p1 a0 a1 #s0 #s1 l ctr x b; intro_exists _ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr) let extend_equal_up_to_lemma (#t:Type0) (s0:Seq.seq t) (s1:Seq.seq t) (i:nat{ i < Seq.length s0 /\ Seq.length s0 == Seq.length s1 }) : Lemma (requires Seq.equal (Seq.slice s0 0 i) (Seq.slice s1 0 i) /\ Seq.index s0 i == Seq.index s1 i) (ensures Seq.equal (Seq.slice s0 0 (i + 1)) (Seq.slice s1 0 (i + 1))) = assert (forall k. k < i ==> Seq.index s0 k == Seq.index (Seq.slice s0 0 i) k /\ Seq.index s1 k == Seq.index (Seq.slice s1 0 i) k) let extend_equal_up_to (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 (Some US.(i +^ 1sz)))) (requires Seq.index s0 (US.v i) == Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; extend_equal_up_to_lemma s0 s1 (US.v i); intro_pure (equal_up_to s0 s1 (Some US.(i +^ 1sz))) let extend_equal_up_to_neg (#o:_) (#t:Type0) (#s0:Seq.seq t) (#s1:Seq.seq t) (len:US.t) (i:US.t{ Seq.length s0 == Seq.length s1 /\ US.(i <^ len) /\ US.v len == Seq.length s0 } ) : STGhost unit o (pure (equal_up_to s0 s1 (Some i))) (fun _ -> pure (equal_up_to s0 s1 None)) (requires Seq.index s0 (US.v i) =!= Seq.index s1 (US.v i)) (ensures fun _ -> True) = elim_pure _; intro_pure _ let init_compare_inv #o (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Seq.seq t) (#s1: Seq.seq t) (l:US.t) (ctr : R.ref (option US.t)) : STGhost unit o (let open US in pts_to a0 p0 s0 `star` pts_to a1 p1 s1 `star` R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (requires ( length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0 )) (ensures (fun _ -> True)) = pts_to_length a0 _; pts_to_length a1 _; intro_pure (equal_up_to s0 s1 (Ghost.hide (Some 0sz))); rewrite (R.pts_to ctr Steel.FractionalPermission.full_perm (Some 0sz)) (R.pts_to ctr Steel.FractionalPermission.full_perm (Ghost.hide (Some 0sz))); intro_exists_compare_inv a0 a1 l ctr (Ghost.hide (Some 0sz)) let compare_pts (#t:eqtype) (#p0 #p1:perm) (a0 a1:array t) (#s0: Ghost.erased (Seq.seq t)) (#s1: Ghost.erased (Seq.seq t)) (l:US.t) : ST bool (pts_to a0 p0 s0 `star` pts_to a1 p1 s1) (fun _ -> pts_to a0 p0 s0 `star` pts_to a1 p1 s1) (requires length a0 > 0 /\ length a0 == length a1 /\ US.v l == length a0 ) (ensures fun b -> b = (Ghost.reveal s0 = Ghost.reveal s1)) = pts_to_length a0 _; pts_to_length a1 _; let ctr = R.alloc (Some 0sz) in let cond () : STT bool (exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) (fun b -> compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide b)) = let _b = elim_exists () in let _ = elim_compare_inv _ _ _ _ _ in let x = R.read ctr in elim_pure (within_bounds _ _ _); match x with | None -> intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ false; return false | Some x -> let res = US.(x <^ l) in intro_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr _ res; return res in let body () : STT unit (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr (Ghost.hide true)) (fun _ -> exists_ (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr)) = let _i = elim_compare_inv _ _ _ _ _ in elim_pure (within_bounds _ _ _); let Some i = R.read ctr in assert_spinoff ((pure (equal_up_to s0 s1 _i)) == (pure (equal_up_to s0 s1 (Some i)))); rewrite (pure (equal_up_to s0 s1 _i)) (pure (equal_up_to s0 s1 (Some i))); let v0 = index a0 i in let v1 = index a1 i in if v0 = v1 then ( R.write ctr (Some US.(i +^ 1sz)); extend_equal_up_to l i; intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide (Some (US.(i +^ 1sz)))) ) else ( R.write ctr None; extend_equal_up_to_neg l i; intro_exists_compare_inv #_ #_ #p0 #p1 a0 a1 l ctr (Ghost.hide None) ) in init_compare_inv a0 a1 l ctr; Steel.ST.Loops.while_loop (compare_inv #_ #p0 #p1 a0 a1 s0 s1 l ctr) cond body; let _ = elim_compare_inv _ _ _ _ _ in elim_pure (equal_up_to _ _ _); let v = R.read ctr in R.free ctr; elim_pure (within_bounds _ _ _); match v with | None -> return false | Some _ -> return true let compare #t #p0 #p1 a0 a1 #s0 #s1 l = pts_to_length a0 _; pts_to_length a1 _; if l = 0sz then ( assert (Seq.equal s0 s1); return true ) else ( compare_pts a0 a1 l ) #pop-options let intro_fits_u32 () = H.intro_fits_u32 () let intro_fits_u64 () = H.intro_fits_u64 () let intro_fits_ptrdiff32 () = H.intro_fits_ptrdiff32 () let intro_fits_ptrdiff64 () = H.intro_fits_ptrdiff64 () let ptrdiff #_ #p0 #p1 #s0 #s1 a0 a1 = rewrite (pts_to a0 _ _) (H.pts_to a0 p0 (seq_map raise s0)); rewrite (pts_to a1 _ _) (H.pts_to a1 p1 (seq_map raise s1)); let res = H.ptrdiff a0 a1 in rewrite (H.pts_to a1 _ _) (pts_to a1 _ _); rewrite (H.pts_to a0 _ _) (pts_to a0 _ _); return res let array_slice (#elt: Type0) (a: array elt) (i j: nat) (sq: squash (i <= j /\ j <= length a)) : Ghost (array elt) (requires True) (ensures (fun a' -> length a' == j - i)) = length_fits a; split_l (split_r a (US.uint_to_t i)) (US.uint_to_t (j - i)) [@@__reduce__] let pts_to_range_body (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (s: Seq.seq elt) (sq: squash (i <= j /\ j <= length a)) : Tot vprop = pts_to (array_slice a i j sq) p s let pts_to_range (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop = exists_ (pts_to_range_body a i j p s) let pts_to_range_intro' (#opened: _) (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (a': array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a' p s) (fun _ -> pts_to_range a i j p s) (i <= j /\ j <= length a /\ a' == array_slice a i j () ) (fun _ -> True) = let sq : squash (i <= j /\ j <= length a) = () in rewrite (pts_to a' p s) (pts_to (array_slice a i j sq) p s); rewrite (exists_ (pts_to_range_body a i j p s)) (pts_to_range a i j p s) let pts_to_range_elim' (#opened: _) (#elt: Type0) (a: array elt) (i j: nat) (p: P.perm) (s: Seq.seq elt) : STGhost (Ghost.erased (array elt)) opened (pts_to_range a i j p s) (fun a' -> pts_to a' p s) True (fun a' -> i <= j /\ j <= length a /\ Ghost.reveal a' == array_slice a i j () ) = rewrite (pts_to_range a i j p s) (exists_ (pts_to_range_body a i j p s)); let _ = elim_exists () in vpattern_replace_erased (fun a' -> pts_to a' p s) let pts_to_range_prop a i j p s = let a' = pts_to_range_elim' a i j p s in pts_to_length a' s; pts_to_range_intro' a i j p a' s let pts_to_range_intro a p s = ptr_shift_zero (ptr_of a); pts_to_range_intro' a 0 (length a) p a s let pts_to_range_elim a p s = ptr_shift_zero (ptr_of a); let a' = pts_to_range_elim' a 0 (length a) p s in vpattern_rewrite (fun a' -> pts_to a' _ _) a let pts_to_range_split #_ #_ #p #s a i m j = length_fits a; pts_to_range_prop a i j p s; let a' = pts_to_range_elim' a i j p s in let mi = US.uint_to_t (m - i) in ptr_shift_add (ptr_of a) (US.uint_to_t i) mi; let _ = ghost_split a' mi in pts_to_range_intro' a m j p (split_r a' mi) _; pts_to_range_intro' a i m p (split_l a' mi) _; noop () let pts_to_range_join #_ #_ #p #s1 #s2 a i m j = length_fits a; pts_to_range_prop a i m p s1; pts_to_range_prop a m j p s2; let a1 = pts_to_range_elim' a i m p s1 in let a2 = pts_to_range_elim' a m j p s2 in ghost_join a1 a2 (); pts_to_range_intro' a i j p _ _ inline_for_extraction [@@noextract_to "krml"] let array_slice_impl (#elt: Type0) (a: array elt) (i: US.t) (j: Ghost.erased nat) (sq: squash (US.v i <= j /\ j <= length a)) : Pure (array elt) (requires True) (ensures (fun a' -> a' == array_slice a (US.v i) j sq)) = length_fits a; split_l (split_r a i) (US.uint_to_t (j - US.v i)) let pts_to_range_index #elt #p #s a i m j = pts_to_range_split a i (US.v m) j; let s1 = elim_exists () in let s2 = elim_exists () in elim_pure _; let ga' = pts_to_range_elim' a (US.v m) j p s2 in let a' = array_slice_impl a m j () in vpattern_rewrite #_ #(array elt) #ga' (fun ga' -> pts_to ga' _ _) a'; let res = index a' 0sz in pts_to_range_intro' a (US.v m) j p a' s2; pts_to_range_join a i (US.v m) j; vpattern_rewrite (pts_to_range a i j p) (Ghost.reveal s); return res inline_for_extraction [@@noextract_to "krml"] let upd' (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) (v: t) : ST (Ghost.erased (Seq.seq t)) (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm res) (US.v i < Seq.length s) (fun res -> US.v i < Seq.length s /\ Ghost.reveal res == Seq.upd s (US.v i) v ) = upd a i v; vpattern_replace_erased (pts_to a P.full_perm)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.HigherArray.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.HigherArray", "short_module": "H" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Steel.ST.Array.array elt -> i: FStar.Ghost.erased Prims.nat -> m: FStar.SizeT.t -> j: FStar.Ghost.erased Prims.nat -> x: elt -> Steel.ST.Effect.ST (FStar.Ghost.erased (FStar.Seq.Base.seq elt))
Steel.ST.Effect.ST
[]
[]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Steel.ST.Array.array", "Prims.nat", "FStar.SizeT.t", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Array.pts_to_range", "FStar.Ghost.reveal", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.ST.Util.noop", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.upd", "Prims.op_Subtraction", "FStar.SizeT.v", "Steel.ST.Util.vpattern_replace_erased", "FStar.Seq.Base.append", "Steel.ST.Array.pts_to_range_join", "Steel.ST.Array.pts_to_range_intro'", "Steel.ST.Array.upd'", "FStar.SizeT.__uint_to_t", "Steel.ST.Array.pts_to_length", "Steel.ST.Util.vpattern_rewrite", "Steel.ST.Array.pts_to", "Steel.ST.Array.array_slice_impl", "Steel.ST.Array.pts_to_range_elim'", "Steel.ST.Util.elim_pure", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Steel.ST.Array.length", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Steel.ST.Util.elim_exists", "Steel.Effect.Common.VStar", "Steel.ST.Util.pure", "Steel.ST.Util.exists_", "Steel.ST.Array.pts_to_range_split", "Steel.ST.Array.pts_to_range_prop", "Steel.ST.Array.length_fits" ]
[]
false
true
false
false
false
let pts_to_range_upd #elt #s a i m j x =
length_fits a; pts_to_range_prop a i j full_perm s; pts_to_range_split a i (US.v m) j; let s1 = elim_exists () in let s2 = elim_exists () in elim_pure _; let ga' = pts_to_range_elim' a (US.v m) j full_perm s2 in let a' = array_slice_impl a m j () in vpattern_rewrite #_ #(array elt) #ga' (fun ga' -> pts_to ga' _ _) a'; pts_to_length a' s2; let s2' = upd' a' 0sz x in pts_to_range_intro' a (US.v m) j full_perm a' s2'; pts_to_range_join a i (US.v m) j; let s' = vpattern_replace_erased (pts_to_range a i j full_perm) in assert ((Ghost.reveal s') `Seq.equal` (Seq.upd s (US.v m - i) x)); noop (); return s'
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_strong_pred
val parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0
val parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0
let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 = Seq.length (serialize s x) == sz
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 112, "start_col": 0, "start_line": 104 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> x: t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "Prims.eq2", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize" ]
[]
false
false
false
false
true
let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 =
Seq.length (serialize s x) == sz
false
Steel.ST.CancellableSpinLock.fst
Steel.ST.CancellableSpinLock.lock_inv
val lock_inv (r: ref bool) (v: vprop) : vprop
val lock_inv (r: ref bool) (v: vprop) : vprop
let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v)
{ "file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 73, "end_line": 34, "start_col": 0, "start_line": 34 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module Steel.ST.CancellableSpinLock open Steel.ST.Effect open Steel.ST.Util open Steel.FractionalPermission open Steel.ST.Reference open Steel.ST.SpinLock module G = FStar.Ghost [@@__reduce__] let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop = fun b -> pts_to r full_perm b `star` (if b then v else emp)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.CancellableSpinLock.fst" }
[ { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.ST.Reference.ref Prims.bool -> v: Steel.Effect.Common.vprop -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.Reference.ref", "Prims.bool", "Steel.Effect.Common.vprop", "Steel.ST.Util.exists_", "Steel.ST.CancellableSpinLock.lock_inv_pred" ]
[]
false
false
false
true
false
let lock_inv (r: ref bool) (v: vprop) : vprop =
exists_ (lock_inv_pred r v)
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.serialize_fldata_strong'
val serialize_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (bare_serializer (parse_fldata_strong_t s sz))
val serialize_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (bare_serializer (parse_fldata_strong_t s sz))
let serialize_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (bare_serializer (parse_fldata_strong_t s sz)) = (fun (x: parse_fldata_strong_t s sz) -> s x)
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 159, "start_col": 0, "start_line": 151 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 = Seq.length (serialize s x) == sz let parse_fldata_strong_t (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot Type = (x: t { parse_fldata_strong_pred s sz x } ) let parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x)) = serializer_correct_implies_complete p s inline_for_extraction let parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz)) = coerce_parser (parse_fldata_strong_t s sz) (parse_strengthen (parse_fldata p sz) (parse_fldata_strong_pred s sz) (parse_fldata_strong_correct s sz)) #set-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> LowParse.Spec.Base.bare_serializer (LowParse.Spec.FLData.parse_fldata_strong_t s sz)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Bytes.bytes", "LowParse.Spec.Base.bare_serializer" ]
[]
false
false
false
false
false
let serialize_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (bare_serializer (parse_fldata_strong_t s sz)) =
(fun (x: parse_fldata_strong_t s sz) -> s x)
false
Spec.P256.Test.fst
Spec.P256.Test.print_result
val print_result (b: bool) : FStar.All.ML unit
val print_result (b: bool) : FStar.All.ML unit
let print_result (b:bool) : FStar.All.ML unit = if b then IO.print_string "\nSuccess!\n" else IO.print_string "\nFailure!\n"
{ "file_name": "specs/tests/Spec.P256.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 78, "end_line": 108, "start_col": 0, "start_line": 107 }
module Spec.P256.Test open Lib.IntTypes open Lib.Sequence open Lib.Meta open Spec.P256 open Spec.ECDSA.Test.Vectors open Spec.Hash.Definitions module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" let test_pk_compressed (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false let test_sigver (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk = concat #_ #32 #32 pk_x pk_y in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg) pk (from_hex r) (from_hex s) in is_sig_valid = is_valid let test_siggen (a:hash_alg_ecdsa) (inp:vec_SigGen) : FStar.All.ML bool = let { msg'; d; qx'; qy'; k; r'; s' } = inp in let msg_len = String.strlen msg' / 2 in let sk_len = String.strlen d / 2 in let nonce_len = String.strlen k / 2 in let pk_x_len = String.strlen qx' / 2 in let pk_y_len = String.strlen qy' / 2 in let sig_r_len = String.strlen r' / 2 in let sig_s_len = String.strlen s' / 2 in if not (msg_len <= max_size_t && min_input_length a <= msg_len && sk_len = 32 && nonce_len = 32 && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx' in let pk_y = from_hex qy' in let pk = concat #_ #32 #32 pk_x pk_y in let sig_r = from_hex r' in let sig_s = from_hex s' in let sig_expected = concat #_ #32 #32 sig_r sig_s in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg') pk (from_hex r') (from_hex s') in let sig_computed = ecdsa_signature_agile a msg_len (from_hex msg') (from_hex d) (from_hex k) in let compare_sig = if Some? sig_computed then PS.print_compare true 64 sig_expected (Some?.v sig_computed) else false in compare_sig && is_sig_valid
{ "checked_file": "/", "dependencies": [ "Spec.P256.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.Meta.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.P256.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Prims.bool -> FStar.All.ML Prims.unit
FStar.All.ML
[ "ml" ]
[]
[ "Prims.bool", "FStar.IO.print_string", "Prims.unit" ]
[]
false
true
false
false
false
let print_result (b: bool) : FStar.All.ML unit =
if b then IO.print_string "\nSuccess!\n" else IO.print_string "\nFailure!\n"
false
Lib.Meta.fst
Lib.Meta.int_of_hex
val int_of_hex: c:hex_digit -> int
val int_of_hex: c:hex_digit -> int
let int_of_hex = function | '0' -> 0 | '1' -> 1 | '2' -> 2 | '3' -> 3 | '4' -> 4 | '5' -> 5 | '6' -> 6 | '7' -> 7 | '8' -> 8 | '9' -> 9 | 'a' | 'A' -> 10 | 'b' | 'B' -> 11 | 'c' | 'C' -> 12 | 'd' | 'D' -> 13 | 'e' | 'E' -> 14 | 'f' | 'F' -> 15
{ "file_name": "lib/Lib.Meta.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 51, "start_col": 0, "start_line": 35 }
module Lib.Meta open Lib.IntTypes /// Helpers used in tests and tactics (see e.g. Test.LowStarize) #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" val is_hex_digit: Char.char -> bool let is_hex_digit = function | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F' -> true | _ -> false type hex_digit = c:Char.char{is_hex_digit c}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "Lib.Meta.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Lib.Meta.hex_digit -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Lib.Meta.hex_digit", "Prims.int" ]
[]
false
false
false
true
false
let int_of_hex =
function | '0' -> 0 | '1' -> 1 | '2' -> 2 | '3' -> 3 | '4' -> 4 | '5' -> 5 | '6' -> 6 | '7' -> 7 | '8' -> 8 | '9' -> 9 | 'a' | 'A' -> 10 | 'b' | 'B' -> 11 | 'c' | 'C' -> 12 | 'd' | 'D' -> 13 | 'e' | 'E' -> 14 | 'f' | 'F' -> 15
false
Spec.P256.Test.fst
Spec.P256.Test.test
val test: Prims.unit -> FStar.All.ML bool
val test: Prims.unit -> FStar.All.ML bool
let test () : FStar.All.ML bool = IO.print_string "\n[P-256 ECDSA-verify with SHA2-256]\n"; let res1 = List.for_all (test_sigver (Hash SHA2_256)) sigver_vectors_sha2_256 in print_result res1; IO.print_string "\n[P-256 ECDSA-sign with SHA2-256]\n"; let res2 = List.for_all (test_siggen (Hash SHA2_256)) siggen_vectors_sha2_256 in print_result res2; IO.print_string "\n[P-256 ECDSA-verify with SHA2-384]\n"; let res3 = List.for_all (test_sigver (Hash SHA2_384)) sigver_vectors_sha2_384 in print_result res3; IO.print_string "\n[P-256 ECDSA-sign with SHA2-384]\n"; let res4 = List.for_all (test_siggen (Hash SHA2_384)) siggen_vectors_sha2_384 in print_result res4; IO.print_string "\n[P-256 ECDSA-verify with SHA2-512]\n"; let res5 = List.for_all (test_sigver (Hash SHA2_512)) sigver_vectors_sha2_512 in print_result res5; IO.print_string "\n[P-256 ECDSA-sign with SHA2-512]\n"; let res6 = List.for_all (test_siggen (Hash SHA2_512)) siggen_vectors_sha2_512 in print_result res6; IO.print_string "\n[P-256 compressed keys]\n"; let res7 = List.for_all (test_pk_compressed (Hash SHA2_256)) sigver_vectors_sha2_256 in print_result res7; let res : bool = res1 && res2 && res3 && res4 && res5 && res6 && res7 in if res then begin IO.print_string "\n\n[P-256] PASS\n"; true end else begin IO.print_string "\n\n[P-256] FAIL\n"; false end
{ "file_name": "specs/tests/Spec.P256.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 143, "start_col": 0, "start_line": 111 }
module Spec.P256.Test open Lib.IntTypes open Lib.Sequence open Lib.Meta open Spec.P256 open Spec.ECDSA.Test.Vectors open Spec.Hash.Definitions module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" let test_pk_compressed (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false let test_sigver (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk = concat #_ #32 #32 pk_x pk_y in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg) pk (from_hex r) (from_hex s) in is_sig_valid = is_valid let test_siggen (a:hash_alg_ecdsa) (inp:vec_SigGen) : FStar.All.ML bool = let { msg'; d; qx'; qy'; k; r'; s' } = inp in let msg_len = String.strlen msg' / 2 in let sk_len = String.strlen d / 2 in let nonce_len = String.strlen k / 2 in let pk_x_len = String.strlen qx' / 2 in let pk_y_len = String.strlen qy' / 2 in let sig_r_len = String.strlen r' / 2 in let sig_s_len = String.strlen s' / 2 in if not (msg_len <= max_size_t && min_input_length a <= msg_len && sk_len = 32 && nonce_len = 32 && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx' in let pk_y = from_hex qy' in let pk = concat #_ #32 #32 pk_x pk_y in let sig_r = from_hex r' in let sig_s = from_hex s' in let sig_expected = concat #_ #32 #32 sig_r sig_s in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg') pk (from_hex r') (from_hex s') in let sig_computed = ecdsa_signature_agile a msg_len (from_hex msg') (from_hex d) (from_hex k) in let compare_sig = if Some? sig_computed then PS.print_compare true 64 sig_expected (Some?.v sig_computed) else false in compare_sig && is_sig_valid let print_result (b:bool) : FStar.All.ML unit = if b then IO.print_string "\nSuccess!\n" else IO.print_string "\nFailure!\n"
{ "checked_file": "/", "dependencies": [ "Spec.P256.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.Meta.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.P256.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.bool
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Prims.bool", "FStar.IO.print_string", "Prims.op_AmpAmp", "Spec.P256.Test.print_result", "FStar.List.for_all", "Spec.ECDSA.Test.Vectors.vec_SigVer", "Spec.P256.Test.test_pk_compressed", "Spec.P256.Hash", "Spec.Hash.Definitions.SHA2_256", "Spec.ECDSA.Test.Vectors.sigver_vectors_sha2_256", "Spec.ECDSA.Test.Vectors.vec_SigGen", "Spec.P256.Test.test_siggen", "Spec.Hash.Definitions.SHA2_512", "Spec.ECDSA.Test.Vectors.siggen_vectors_sha2_512", "Spec.P256.Test.test_sigver", "Spec.ECDSA.Test.Vectors.sigver_vectors_sha2_512", "Spec.Hash.Definitions.SHA2_384", "Spec.ECDSA.Test.Vectors.siggen_vectors_sha2_384", "Spec.ECDSA.Test.Vectors.sigver_vectors_sha2_384", "Spec.ECDSA.Test.Vectors.siggen_vectors_sha2_256" ]
[]
false
true
false
false
false
let test () : FStar.All.ML bool =
IO.print_string "\n[P-256 ECDSA-verify with SHA2-256]\n"; let res1 = List.for_all (test_sigver (Hash SHA2_256)) sigver_vectors_sha2_256 in print_result res1; IO.print_string "\n[P-256 ECDSA-sign with SHA2-256]\n"; let res2 = List.for_all (test_siggen (Hash SHA2_256)) siggen_vectors_sha2_256 in print_result res2; IO.print_string "\n[P-256 ECDSA-verify with SHA2-384]\n"; let res3 = List.for_all (test_sigver (Hash SHA2_384)) sigver_vectors_sha2_384 in print_result res3; IO.print_string "\n[P-256 ECDSA-sign with SHA2-384]\n"; let res4 = List.for_all (test_siggen (Hash SHA2_384)) siggen_vectors_sha2_384 in print_result res4; IO.print_string "\n[P-256 ECDSA-verify with SHA2-512]\n"; let res5 = List.for_all (test_sigver (Hash SHA2_512)) sigver_vectors_sha2_512 in print_result res5; IO.print_string "\n[P-256 ECDSA-sign with SHA2-512]\n"; let res6 = List.for_all (test_siggen (Hash SHA2_512)) siggen_vectors_sha2_512 in print_result res6; IO.print_string "\n[P-256 compressed keys]\n"; let res7 = List.for_all (test_pk_compressed (Hash SHA2_256)) sigver_vectors_sha2_256 in print_result res7; let res:bool = res1 && res2 && res3 && res4 && res5 && res6 && res7 in if res then (IO.print_string "\n\n[P-256] PASS\n"; true) else (IO.print_string "\n\n[P-256] FAIL\n"; false)
false
Lib.Meta.fst
Lib.Meta.from_hex
val from_hex (s: hex_string) : Seq.lseq uint8 (String.strlen s / 2)
val from_hex (s: hex_string) : Seq.lseq uint8 (String.strlen s / 2)
let from_hex (s:hex_string) : Seq.lseq uint8 (String.strlen s / 2) = Seq.seq_of_list (as_uint8s [] (String.list_of_string s))
{ "file_name": "lib/Lib.Meta.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 75, "start_col": 0, "start_line": 74 }
module Lib.Meta open Lib.IntTypes /// Helpers used in tests and tactics (see e.g. Test.LowStarize) #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" val is_hex_digit: Char.char -> bool let is_hex_digit = function | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F' -> true | _ -> false type hex_digit = c:Char.char{is_hex_digit c} val int_of_hex: c:hex_digit -> int let int_of_hex = function | '0' -> 0 | '1' -> 1 | '2' -> 2 | '3' -> 3 | '4' -> 4 | '5' -> 5 | '6' -> 6 | '7' -> 7 | '8' -> 8 | '9' -> 9 | 'a' | 'A' -> 10 | 'b' | 'B' -> 11 | 'c' | 'C' -> 12 | 'd' | 'D' -> 13 | 'e' | 'E' -> 14 | 'f' | 'F' -> 15 val byte_of_hex: a:hex_digit -> b:hex_digit -> int let byte_of_hex a b = FStar.Mul.(int_of_hex a * 16 + int_of_hex b) unfold type hex_string = s:string{normalize (String.strlen s % 2 = 0) /\ normalize (List.Tot.for_all is_hex_digit (String.list_of_string s))} #push-options "--fuel 2" let rec as_uint8s acc (cs:list Char.char{normalize (List.length cs % 2 = 0) /\ normalize (List.Tot.for_all is_hex_digit cs)}): Tot (l:list uint8{List.length l = List.length acc + List.length cs / 2}) (decreases (List.length cs)) = match cs with | c1 :: c2 :: cs' -> as_uint8s (u8 (byte_of_hex c1 c2) :: acc) cs' | _ -> List.rev_length acc; List.rev acc
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "Lib.Meta.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Lib.Meta.hex_string -> FStar.Seq.Properties.lseq Lib.IntTypes.uint8 (FStar.String.strlen s / 2)
Prims.Tot
[ "total" ]
[]
[ "Lib.Meta.hex_string", "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.uint8", "Lib.Meta.as_uint8s", "Prims.Nil", "FStar.String.list_of_string", "FStar.Seq.Properties.lseq", "Prims.op_Division", "FStar.String.strlen" ]
[]
false
false
false
false
false
let from_hex (s: hex_string) : Seq.lseq uint8 (String.strlen s / 2) =
Seq.seq_of_list (as_uint8s [] (String.list_of_string s))
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata'
val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t)
val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t)
let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 15, "end_line": 28, "start_col": 0, "start_line": 17 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> LowParse.Spec.Base.bare_parser t
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Bytes.bytes", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "Prims.bool", "LowParse.Spec.Base.parse", "FStar.Seq.Base.slice", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.bare_parser", "Prims.unit" ]
[]
false
false
false
false
false
let parse_fldata' #k #t p sz =
let () = () in fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_injective
val parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz)))
val parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz)))
let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b))
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 67, "end_line": 45, "start_col": 0, "start_line": 30 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Base.injective (LowParse.Spec.FLData.parse_fldata' p sz))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.l_imp", "LowParse.Spec.Base.injective_precond", "LowParse.Spec.FLData.parse_fldata'", "LowParse.Spec.Base.injective_postcond", "FStar.Classical.move_requires", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "FStar.Seq.Base.slice", "LowParse.Bytes.byte", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Base.injective" ]
[]
false
false
true
false
false
let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) =
parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b))
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_kind
val parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind
val parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind
let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None )
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 57, "start_col": 0, "start_line": 49 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.strong_parser_kind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.ParserKindMetadataFail", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_kind_metadata_t" ]
[]
false
false
false
true
false
let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind =
strong_parser_kind sz sz (match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None)
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.serialize_fldata_strong
val serialize_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (serializer (parse_fldata_strong s sz))
val serialize_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (serializer (parse_fldata_strong s sz))
let serialize_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (serializer (parse_fldata_strong s sz)) = serialize_fldata_strong' s sz
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 168, "start_col": 0, "start_line": 161 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 = Seq.length (serialize s x) == sz let parse_fldata_strong_t (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot Type = (x: t { parse_fldata_strong_pred s sz x } ) let parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x)) = serializer_correct_implies_complete p s inline_for_extraction let parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz)) = coerce_parser (parse_fldata_strong_t s sz) (parse_strengthen (parse_fldata p sz) (parse_fldata_strong_pred s sz) (parse_fldata_strong_correct s sz)) #set-options "--z3rlimit 16" let serialize_fldata_strong' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (bare_serializer (parse_fldata_strong_t s sz)) = (fun (x: parse_fldata_strong_t s sz) -> s x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> LowParse.Spec.Base.serializer (LowParse.Spec.FLData.parse_fldata_strong s sz)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Spec.FLData.serialize_fldata_strong'", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_strong" ]
[]
false
false
false
false
false
let serialize_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (serializer (parse_fldata_strong s sz)) =
serialize_fldata_strong' s sz
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata
val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t)
val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t)
let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 71, "start_col": 0, "start_line": 67 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> LowParse.Spec.Base.parser (LowParse.Spec.FLData.parse_fldata_kind sz k) t
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Spec.FLData.parse_fldata'", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_injective" ]
[]
false
false
false
false
false
let parse_fldata #b #t p sz =
parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_strong
val parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz))
val parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz))
let parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz)) = coerce_parser (parse_fldata_strong_t s sz) (parse_strengthen (parse_fldata p sz) (parse_fldata_strong_pred s sz) (parse_fldata_strong_correct s sz))
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 107, "end_line": 147, "start_col": 0, "start_line": 138 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 = Seq.length (serialize s x) == sz let parse_fldata_strong_t (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot Type = (x: t { parse_fldata_strong_pred s sz x } ) let parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x)) = serializer_correct_implies_complete p s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> LowParse.Spec.Base.parser (LowParse.Spec.FLData.parse_fldata_kind sz k) (LowParse.Spec.FLData.parse_fldata_strong_t s sz)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Spec.Base.coerce_parser", "LowParse.Spec.FLData.parse_fldata_strong_t", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata_strong_pred", "LowParse.Spec.Combinators.parse_strengthen", "LowParse.Spec.FLData.parse_fldata", "LowParse.Spec.FLData.parse_fldata_strong_correct" ]
[]
false
false
false
false
false
let parse_fldata_strong (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot (parser (parse_fldata_kind sz k) (parse_fldata_strong_t s sz)) =
coerce_parser (parse_fldata_strong_t s sz) (parse_strengthen (parse_fldata p sz) (parse_fldata_strong_pred s sz) (parse_fldata_strong_correct s sz))
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_consumes_all_correct
val parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b))
val parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b))
let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 102, "start_col": 0, "start_line": 93 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> b: LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll) (ensures LowParse.Spec.Base.parse (LowParse.Spec.FLData.parse_fldata p sz) b == LowParse.Spec.Base.parse (LowParse.Spec.FLData.parse_fldata_consumes_all p sz) b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.unit", "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.ParserConsumesAll", "Prims.squash", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.FLData.parse_fldata", "LowParse.Spec.FLData.parse_fldata_consumes_all", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) =
parser_kind_prop_equiv k p
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_strong_correct
val parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x))
val parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x))
let parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x)) = serializer_correct_implies_complete p s
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 41, "end_line": 135, "start_col": 0, "start_line": 123 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True)) let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None let parse_fldata_consumes_all_correct (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) (b: bytes) : Lemma (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (parse (parse_fldata p sz) b == parse (parse_fldata_consumes_all p sz) b)) = parser_kind_prop_equiv k p let parse_fldata_strong_pred (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (x: t) : GTot Type0 = Seq.length (serialize s x) == sz let parse_fldata_strong_t (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) : Tot Type = (x: t { parse_fldata_strong_pred s sz x } )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> sz: Prims.nat -> xbytes: LowParse.Bytes.bytes -> consumed: LowParse.Spec.Base.consumed_length xbytes -> x: t -> FStar.Pervasives.Lemma (requires LowParse.Spec.Base.parse (LowParse.Spec.FLData.parse_fldata p sz) xbytes == FStar.Pervasives.Native.Some (x, consumed)) (ensures LowParse.Spec.FLData.parse_fldata_strong_pred s sz x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.nat", "LowParse.Bytes.bytes", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.serializer_correct_implies_complete", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.parse", "LowParse.Spec.FLData.parse_fldata", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.squash", "LowParse.Spec.FLData.parse_fldata_strong_pred", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parse_fldata_strong_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (sz: nat) (xbytes: bytes) (consumed: consumed_length xbytes) (x: t) : Lemma (requires (parse (parse_fldata p sz) xbytes == Some (x, consumed))) (ensures (parse_fldata_strong_pred s sz x)) =
serializer_correct_implies_complete p s
false
LowParse.Spec.FLData.fst
LowParse.Spec.FLData.parse_fldata_consumes_all
val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True))
val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True))
let parse_fldata_consumes_all #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None
{ "file_name": "src/lowparse/LowParse.Spec.FLData.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 15, "end_line": 91, "start_col": 0, "start_line": 82 }
(* Parse data of some explicitly fixed length *) module LowParse.Spec.FLData include LowParse.Spec.Combinators module Seq = FStar.Seq module Classical = FStar.Classical inline_for_extraction val parse_fldata' (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (bare_parser t) let parse_fldata' #k #t p sz = let () = () in // Necessary to pass arity checking fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, consumed) -> if (consumed <: nat) = (sz <: nat) then Some (v, (sz <: consumed_length s)) else None | _ -> None let parse_fldata_injective (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Lemma (ensures (injective (parse_fldata' p sz))) = parser_kind_prop_equiv k p; let f (b1 b2: bytes) : Lemma (requires (injective_precond (parse_fldata' p sz) b1 b2)) (ensures (injective_postcond (parse_fldata' p sz) b1 b2)) = assert (injective_precond p (Seq.slice b1 0 sz) (Seq.slice b2 0 sz)) in Classical.forall_intro_2 (fun b -> Classical.move_requires (f b)) // unfold inline_for_extraction let parse_fldata_kind (sz: nat) (k: parser_kind) : Tot parser_kind = strong_parser_kind sz sz ( match k.parser_kind_metadata with | Some ParserKindMetadataFail -> Some ParserKindMetadataFail | _ -> None ) inline_for_extraction val parse_fldata (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Tot (parser (parse_fldata_kind sz k) t) let parse_fldata #b #t p sz = parse_fldata_injective p sz; parser_kind_prop_equiv b p; parser_kind_prop_equiv (parse_fldata_kind sz b) (parse_fldata' p sz); parse_fldata' p sz val parse_fldata_consumes_all (#k: parser_kind) (#t: Type) (p: parser k t) (sz: nat) : Pure (bare_parser t) (requires (k.parser_kind_subkind == Some ParserConsumesAll)) (ensures (fun _ -> True))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.FLData.fst" }
[ { "abbrev": true, "full_module": "FStar.Classical", "short_module": "Classical" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: LowParse.Spec.Base.parser k t -> sz: Prims.nat -> Prims.Pure (LowParse.Spec.Base.bare_parser t)
Prims.Pure
[]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.nat", "LowParse.Bytes.bytes", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "Prims.bool", "LowParse.Spec.Base.parse", "FStar.Seq.Base.slice", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.bare_parser", "Prims.unit" ]
[]
false
false
false
false
false
let parse_fldata_consumes_all #k #t p sz =
let () = () in fun (s: bytes) -> if Seq.length s < sz then None else match parse p (Seq.slice s 0 sz) with | Some (v, _) -> Some (v, (sz <: consumed_length s)) | _ -> None
false
Steel.ST.CancellableSpinLock.fst
Steel.ST.CancellableSpinLock.cancel
val cancel (#v:vprop) (c:cancellable_lock v) : STT unit (can_release c) (fun _ -> emp)
val cancel (#v:vprop) (c:cancellable_lock v) : STT unit (can_release c) (fun _ -> emp)
let cancel c = free c.lref
{ "file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 72, "start_col": 0, "start_line": 72 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module Steel.ST.CancellableSpinLock open Steel.ST.Effect open Steel.ST.Util open Steel.FractionalPermission open Steel.ST.Reference open Steel.ST.SpinLock module G = FStar.Ghost [@@__reduce__] let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop = fun b -> pts_to r full_perm b `star` (if b then v else emp) [@@__reduce__] let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v) noeq type cancellable_lock (v:vprop) = { lref : ref bool; llock : lock (lock_inv lref v) } let new_cancellable_lock v = let r = alloc true in intro_exists true (lock_inv_pred r v); let l = new_lock (lock_inv r v) in return ({lref = r; llock = l}) [@__reduce__] let can_release #v c = pts_to c.lref full_perm true let acquire #v c = acquire c.llock; let b_erased = elim_exists () in let b = read c.lref in if b then begin rewrite (if b_erased then v else emp) v; rewrite (v `star` can_release c) (maybe_acquired b c) end else begin intro_exists (G.reveal b_erased) (lock_inv_pred c.lref v); release c.llock; rewrite emp (maybe_acquired b c) end; return b let release #v c = intro_exists true (lock_inv_pred c.lref v); release c.llock
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.CancellableSpinLock.fst" }
[ { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Steel.ST.CancellableSpinLock.cancellable_lock v -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.ST.CancellableSpinLock.cancellable_lock", "Steel.ST.Reference.free", "Prims.bool", "FStar.Ghost.hide", "Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__lref", "Prims.unit" ]
[]
false
true
false
false
false
let cancel c =
free c.lref
false
Spec.P256.Test.fst
Spec.P256.Test.test_sigver
val test_sigver (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool
val test_sigver (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool
let test_sigver (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk = concat #_ #32 #32 pk_x pk_y in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg) pk (from_hex r) (from_hex s) in is_sig_valid = is_valid
{ "file_name": "specs/tests/Spec.P256.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 63, "start_col": 0, "start_line": 41 }
module Spec.P256.Test open Lib.IntTypes open Lib.Sequence open Lib.Meta open Spec.P256 open Spec.ECDSA.Test.Vectors open Spec.Hash.Definitions module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" let test_pk_compressed (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false
{ "checked_file": "/", "dependencies": [ "Spec.P256.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.Meta.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.P256.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.P256.hash_alg_ecdsa -> inp: Spec.ECDSA.Test.Vectors.vec_SigVer -> FStar.All.ML Prims.bool
FStar.All.ML
[ "ml" ]
[]
[ "Spec.P256.hash_alg_ecdsa", "Spec.ECDSA.Test.Vectors.vec_SigVer", "Lib.Meta.hex_string", "Prims.bool", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Spec.P256.min_input_length", "Prims.op_Equality", "Prims.int", "Spec.P256.ecdsa_verification_agile", "Lib.Meta.from_hex", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Addition", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Lib.IntTypes.uint8", "FStar.Seq.Properties.lseq", "Prims.op_Division", "FStar.String.strlen" ]
[]
false
true
false
false
false
let test_sigver (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool =
let { msg = msg ; qx = qx ; qy = qy ; r = r ; s = s ; result = result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk = concat #_ #32 #32 pk_x pk_y in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg) pk (from_hex r) (from_hex s) in is_sig_valid = is_valid
false
Spec.P256.Test.fst
Spec.P256.Test.test_pk_compressed
val test_pk_compressed (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool
val test_pk_compressed (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool
let test_pk_compressed (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false
{ "file_name": "specs/tests/Spec.P256.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 38, "start_col": 0, "start_line": 15 }
module Spec.P256.Test open Lib.IntTypes open Lib.Sequence open Lib.Meta open Spec.P256 open Spec.ECDSA.Test.Vectors open Spec.Hash.Definitions module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 1 --ifuel 1"
{ "checked_file": "/", "dependencies": [ "Spec.P256.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.Meta.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.P256.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.P256.hash_alg_ecdsa -> inp: Spec.ECDSA.Test.Vectors.vec_SigVer -> FStar.All.ML Prims.bool
FStar.All.ML
[ "ml" ]
[]
[ "Spec.P256.hash_alg_ecdsa", "Spec.ECDSA.Test.Vectors.vec_SigVer", "Lib.Meta.hex_string", "Prims.bool", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Spec.P256.min_input_length", "Prims.op_Equality", "Prims.int", "Lib.ByteSequence.lbytes", "Lib.PrintSequence.print_compare", "FStar.Pervasives.Native.option", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.P256.pk_compressed_to_raw", "Spec.P256.pk_compressed_from_raw", "Prims.op_Addition", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Lib.IntTypes.uint8", "FStar.Seq.Properties.lseq", "Prims.op_Division", "FStar.String.strlen", "Lib.Meta.from_hex" ]
[]
false
true
false
false
false
let test_pk_compressed (a: hash_alg_ecdsa) (inp: vec_SigVer) : FStar.All.ML bool =
let { msg = msg ; qx = qx ; qy = qy ; r = r ; s = s ; result = result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false
false
Spec.P256.Test.fst
Spec.P256.Test.test_siggen
val test_siggen (a: hash_alg_ecdsa) (inp: vec_SigGen) : FStar.All.ML bool
val test_siggen (a: hash_alg_ecdsa) (inp: vec_SigGen) : FStar.All.ML bool
let test_siggen (a:hash_alg_ecdsa) (inp:vec_SigGen) : FStar.All.ML bool = let { msg'; d; qx'; qy'; k; r'; s' } = inp in let msg_len = String.strlen msg' / 2 in let sk_len = String.strlen d / 2 in let nonce_len = String.strlen k / 2 in let pk_x_len = String.strlen qx' / 2 in let pk_y_len = String.strlen qy' / 2 in let sig_r_len = String.strlen r' / 2 in let sig_s_len = String.strlen s' / 2 in if not (msg_len <= max_size_t && min_input_length a <= msg_len && sk_len = 32 && nonce_len = 32 && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx' in let pk_y = from_hex qy' in let pk = concat #_ #32 #32 pk_x pk_y in let sig_r = from_hex r' in let sig_s = from_hex s' in let sig_expected = concat #_ #32 #32 sig_r sig_s in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg') pk (from_hex r') (from_hex s') in let sig_computed = ecdsa_signature_agile a msg_len (from_hex msg') (from_hex d) (from_hex k) in let compare_sig = if Some? sig_computed then PS.print_compare true 64 sig_expected (Some?.v sig_computed) else false in compare_sig && is_sig_valid
{ "file_name": "specs/tests/Spec.P256.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 104, "start_col": 0, "start_line": 66 }
module Spec.P256.Test open Lib.IntTypes open Lib.Sequence open Lib.Meta open Spec.P256 open Spec.ECDSA.Test.Vectors open Spec.Hash.Definitions module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" let test_pk_compressed (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk_raw = concat #_ #32 #32 pk_x pk_y in let pk_c = pk_compressed_from_raw pk_raw in let pk_raw_c = pk_compressed_to_raw pk_c in match pk_raw_c with | Some pk_raw_c -> PS.print_compare true 64 pk_raw pk_raw_c | None -> false let test_sigver (a:hash_alg_ecdsa) (inp:vec_SigVer) : FStar.All.ML bool = let { msg; qx; qy; r; s; result } = inp in let msg_len = String.strlen msg / 2 in let pk_x_len = String.strlen qx / 2 in let pk_y_len = String.strlen qy / 2 in let sig_r_len = String.strlen r / 2 in let sig_s_len = String.strlen s / 2 in let is_valid = result in if not (msg_len <= max_size_t && min_input_length a <= msg_len && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx in let pk_y = from_hex qy in let pk = concat #_ #32 #32 pk_x pk_y in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg) pk (from_hex r) (from_hex s) in is_sig_valid = is_valid
{ "checked_file": "/", "dependencies": [ "Spec.P256.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.ECDSA.Test.Vectors.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.Meta.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.P256.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.ECDSA.Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.P256.hash_alg_ecdsa -> inp: Spec.ECDSA.Test.Vectors.vec_SigGen -> FStar.All.ML Prims.bool
FStar.All.ML
[ "ml" ]
[]
[ "Spec.P256.hash_alg_ecdsa", "Spec.ECDSA.Test.Vectors.vec_SigGen", "Lib.Meta.hex_string", "Prims.op_Negation", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Spec.P256.min_input_length", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.Pervasives.Native.uu___is_Some", "Lib.ByteSequence.lbytes", "Lib.PrintSequence.print_compare", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Pervasives.Native.option", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.P256.ecdsa_signature_agile", "Lib.Meta.from_hex", "Spec.P256.ecdsa_verification_agile", "Prims.op_Addition", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Lib.IntTypes.uint8", "FStar.Seq.Properties.lseq", "Prims.op_Division", "FStar.String.strlen" ]
[]
false
true
false
false
false
let test_siggen (a: hash_alg_ecdsa) (inp: vec_SigGen) : FStar.All.ML bool =
let { msg' = msg' ; d = d ; qx' = qx' ; qy' = qy' ; k = k ; r' = r' ; s' = s' } = inp in let msg_len = String.strlen msg' / 2 in let sk_len = String.strlen d / 2 in let nonce_len = String.strlen k / 2 in let pk_x_len = String.strlen qx' / 2 in let pk_y_len = String.strlen qy' / 2 in let sig_r_len = String.strlen r' / 2 in let sig_s_len = String.strlen s' / 2 in if not (msg_len <= max_size_t && min_input_length a <= msg_len && sk_len = 32 && nonce_len = 32 && pk_x_len = 32 && pk_y_len = 32 && sig_r_len = 32 && sig_s_len = 32) then false else let pk_x = from_hex qx' in let pk_y = from_hex qy' in let pk = concat #_ #32 #32 pk_x pk_y in let sig_r = from_hex r' in let sig_s = from_hex s' in let sig_expected = concat #_ #32 #32 sig_r sig_s in let is_sig_valid = ecdsa_verification_agile a msg_len (from_hex msg') pk (from_hex r') (from_hex s') in let sig_computed = ecdsa_signature_agile a msg_len (from_hex msg') (from_hex d) (from_hex k) in let compare_sig = if Some? sig_computed then PS.print_compare true 64 sig_expected (Some?.v sig_computed) else false in compare_sig && is_sig_valid
false
Hacl.Impl.Curve25519.Generic.fst
Hacl.Impl.Curve25519.Generic.ladder0_
val ladder0_: #s:field_spec -> k:scalar -> q:point s -> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\ LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))) (ensures fun h0 _ h1 -> modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\ fget_xz h1 nq == M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
val ladder0_: #s:field_spec -> k:scalar -> q:point s -> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\ LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))) (ensures fun h0 _ h1 -> modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\ fget_xz h1 nq == M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
let ladder0_ #s k q p01_tmp1_swap tmp2 = let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1); assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap); // bit 255 is 0 and bit 254 is 1 cswap2 #s (u64 1) nq nq_p1; point_add_and_double #s q p01_tmp1 tmp2; swap.(0ul) <- u64 1; //Got about 1K speedup by removing 4 iterations here. //First iteration can be skipped because top bit of scalar is 0 ladder_step_loop #s k q p01_tmp1_swap tmp2; let sw = swap.(0ul) in cswap2 #s sw nq nq_p1
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 301, "start_col": 0, "start_line": 279 }
module Hacl.Impl.Curve25519.Generic open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Curve25519.Fields include Hacl.Impl.Curve25519.Finv include Hacl.Impl.Curve25519.AddAndDouble module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module LSeq = Lib.Sequence module C = Hacl.Impl.Curve25519.Fields.Core module S = Spec.Curve25519 module M = Hacl.Spec.Curve25519.AddAndDouble module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas friend Lib.LoopCombinators #set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" inline_for_extraction noextract let scalar = lbuffer uint8 32ul inline_for_extraction noextract val scalar_bit: s:scalar -> n:size_t{v n < 256} -> Stack uint64 (requires fun h0 -> live h0 s) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1) let scalar_bit s n = let h0 = ST.get () in mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul; assert_norm (1 = pow2 1 - 1); assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1)); to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1) inline_for_extraction noextract val decode_point: #s:field_spec -> o:point s -> i:lbuffer uint8 32ul -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\ fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1) [@ Meta.Attribute.specialize ] let decode_point #s o i = push_frame(); let tmp = create 4ul (u64 0) in let h0 = ST.get () in uints_from_bytes_le #U64 tmp i; let h1 = ST.get () in BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i); assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i)); let tmp3 = tmp.(3ul) in tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff; mod_mask_lemma tmp3 63ul; assert_norm (0x7fffffffffffffff = pow2 63 - 1); assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff)); let h2 = ST.get () in assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63); Lemmas.lemma_felem64_mod255 (as_seq h1 tmp); assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255); let x : felem s = sub o 0ul (nlimb s) in let z : felem s = sub o (nlimb s) (nlimb s) in set_one z; load_felem x tmp; pop_frame() val encode_point: #s:field_spec -> o:lbuffer uint8 32ul -> i:point s -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i /\ state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i)) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i)) [@ Meta.Attribute.specialize ] let encode_point #s o i = push_frame(); let x : felem s = sub i 0ul (nlimb s) in let z : felem s = sub i (nlimb s) (nlimb s) in let tmp = create_felem s in let u64s = create 4ul (u64 0) in let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in let h0 = ST.get () in finv tmp z tmp_w; fmul tmp tmp x tmp_w; let h1 = ST.get () in assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x)); assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21))); store_felem u64s tmp; let h2 = ST.get () in assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp)); uints_to_bytes_le #U64 4ul o u64s; let h3 = ST.get () in BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp); assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp)); pop_frame() // TODO: why re-define the signature here? val cswap2: #s:field_spec -> bit:uint64{v bit <= 1} -> p1:felem2 s -> p2:felem2 s -> Stack unit (requires fun h0 -> live h0 p1 /\ live h0 p2 /\ disjoint p1 p2) (ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\ (v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\ (v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\ (fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2)) [@ Meta.Attribute.inline_ ] let cswap2 #s bit p0 p1 = C.cswap2 #s bit p0 p1 val ladder_step: #s:field_spec -> k:scalar -> q:point s -> i:size_t{v i < 251} -> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\ LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in v (LSeq.index (as_seq h0 bit) 0) <= 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))) (ensures fun h0 _ h1 -> modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i) (fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\ v (LSeq.index (as_seq h1 bit) 0) <= 1 /\ state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\ state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\ state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1))) #push-options "--z3rlimit 200 --fuel 0 --ifuel 1" [@ Meta.Attribute.inline_ ] let ladder_step #s k q i p01_tmp1_swap tmp2 = let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1); assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap); let h0 = ST.get () in let bit = scalar_bit k (253ul -. i) in assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i))); let sw = swap.(0ul) ^. bit in logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit; cswap2 #s sw nq nq_p1; point_add_and_double #s q p01_tmp1 tmp2; swap.(0ul) <- bit #pop-options #push-options "--z3rlimit 300 --fuel 1 --ifuel 1" val ladder_step_loop: #s:field_spec -> k:scalar -> q:point s -> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\ LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in v (LSeq.index (as_seq h0 bit) 0) <= 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))) (ensures fun h0 _ h1 -> modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in let (p0, p1, b) = Lib.LoopCombinators.repeati 251 (S.ladder_step (as_seq h0 k) (fget_xz h0 q)) (fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\ v (LSeq.index (as_seq h1 bit) 0) <= 1 /\ state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\ state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1))) [@ Meta.Attribute.inline_ ] let ladder_step_loop #s k q p01_tmp1_swap tmp2 = let h0 = ST.get () in [@ inline_let] let spec_fh h0 = S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in [@ inline_let] let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) = let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in (fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in [@ inline_let] let inv h (i:nat{i <= 251}) = let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\ v (LSeq.index (as_seq h bit) 0) <= 1 /\ state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\ state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\ state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\ acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in Lib.Loops.for 0ul 251ul inv (fun i -> Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i); ladder_step #s k q i p01_tmp1_swap tmp2) #pop-options #push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800" val ladder0_: #s:field_spec -> k:scalar -> q:point s -> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\ LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\ state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))) (ensures fun h0 _ h1 -> modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\ (let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\ fget_xz h1 nq == M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked", "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "Hacl.Impl.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "Hacl.Impl.Curve25519.AddAndDouble.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Curve25519.Generic.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field64.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.AddAndDouble", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.AddAndDouble", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Finv", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "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.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": true, "z3rlimit": 800, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Hacl.Impl.Curve25519.Generic.scalar -> q: Hacl.Impl.Curve25519.AddAndDouble.point s -> p01_tmp1_swap: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (8ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s +! 1ul) -> tmp2: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Generic.scalar", "Hacl.Impl.Curve25519.AddAndDouble.point", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Generic.cswap2", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "Hacl.Impl.Curve25519.Generic.ladder_step_loop", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.u64", "Hacl.Impl.Curve25519.AddAndDouble.point_add_and_double", "Prims._assert", "Prims.eq2", "Lib.Buffer.buffer_t", "Prims.l_or", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.Buffer.length", "Lib.IntTypes.v", "FStar.UInt32.t", "Lib.Buffer.gsub", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Lib.IntTypes.mul" ]
[]
false
true
false
false
false
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in let nq:point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in let nq_p1:point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq); assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1); assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1); assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap); cswap2 #s (u64 1) nq nq_p1; point_add_and_double #s q p01_tmp1 tmp2; swap.(0ul) <- u64 1; ladder_step_loop #s k q p01_tmp1_swap tmp2; let sw = swap.(0ul) in cswap2 #s sw nq nq_p1
false
Steel.MonotonicHigherReference.fst
Steel.MonotonicHigherReference.extract_pure
val extract_pure (#a #uses #p #f: _) (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (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)
val extract_pure (#a #uses #p #f: _) (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (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)
let extract_pure #a #uses #p #f (r:ref a p) (v:Ghost.erased a) (h:Ghost.erased (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) = rewrite_slprop (pts_to_body r f v h) (PR.pts_to r h `star` pure (history_val h v f)) (fun _ -> ()); elim_pure (history_val h v f); rewrite_slprop (PR.pts_to r h) (pts_to_body r f v h) (fun m -> emp_unit (M.pts_to r h); pure_star_interp (M.pts_to r h) (history_val h v f) m )
{ "file_name": "lib/steel/Steel.MonotonicHigherReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 93, "start_col": 0, "start_line": 77 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.MonotonicHigherReference open FStar.Ghost open FStar.PCM open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.PCMReference open Steel.FractionalPermission open Steel.Preorder module Preorder = FStar.Preorder module Q = Steel.Preorder module M = Steel.Memory module PR = Steel.PCMReference open FStar.Real #set-options "--ide_id_info_off" let ref a p = M.ref (history a p) pcm_history [@@__reduce__] let pts_to_body #a #p (r:ref a p) (f:perm) (v:Ghost.erased 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:Ghost.erased 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 #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelT unit (PR.pts_to r h) (fun _ -> pts_to_body r f v h) = rewrite_slprop (PR.pts_to r h) (pts_to_body _ _ _ _) (fun m -> emp_unit (M.pts_to r h); pure_star_interp (M.pts_to r h) (history_val h v f) m) let intro_pure_full #a #p #f (r:ref a p) (v:a) (h:history a p { history_val h v f }) : SteelT unit (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
{ "checked_file": "/", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.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.MonotonicHigherReference.fst" }
[ { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": true, "full_module": "Steel.PCMReference", "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.PCMReference", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.MonotonicHigherReference.ref a p -> v: FStar.Ghost.erased a -> h: FStar.Ghost.erased (Steel.Preorder.history a p) -> Steel.Effect.Atomic.SteelGhostT (_: Prims.unit{Steel.Preorder.history_val (FStar.Ghost.reveal h) v f})
Steel.Effect.Atomic.SteelGhostT
[]
[]
[ "Steel.Memory.inames", "FStar.Preorder.preorder", "Steel.FractionalPermission.perm", "Steel.MonotonicHigherReference.ref", "FStar.Ghost.erased", "Steel.Preorder.history", "Steel.Effect.Atomic.rewrite_slprop", "Steel.PCMReference.pts_to", "Steel.Preorder.pcm_history", "FStar.Ghost.reveal", "Steel.MonotonicHigherReference.pts_to_body", "Steel.Memory.mem", "Steel.Memory.pure_star_interp", "Steel.Memory.pts_to", "Steel.Preorder.history_val", "Prims.unit", "Steel.Memory.emp_unit", "Steel.Effect.Atomic.elim_pure", "Steel.Effect.Common.star", "Steel.Effect.Common.pure", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let extract_pure #a #uses #p #f (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (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) =
rewrite_slprop (pts_to_body r f v h) ((PR.pts_to r h) `star` (pure (history_val h v f))) (fun _ -> ()); elim_pure (history_val h v f); rewrite_slprop (PR.pts_to r h) (pts_to_body r f v h) (fun m -> emp_unit (M.pts_to r h); pure_star_interp (M.pts_to r h) (history_val h v f) m)
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.key_dh_secret
val key_dh_secret : cs: Spec.Agile.HPKE.ciphersuite -> Type0
let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs))
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 78, "end_line": 18, "start_col": 0, "start_line": 18 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_dh_key" ]
[]
false
false
false
true
true
let key_dh_secret (cs: S.ciphersuite) =
lbuffer uint8 (size (S.size_dh_key cs))
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.key_aead
val key_aead : cs: Spec.Agile.HPKE.ciphersuite -> Type0
let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs))
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 22, "start_col": 0, "start_line": 22 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_aead_key" ]
[]
false
false
false
true
true
let key_aead (cs: S.ciphersuite) =
lbuffer uint8 (size (S.size_aead_key cs))
false
Hacl.Spec.Bignum.Montgomery.fsti
Hacl.Spec.Bignum.Montgomery.bn_mont_pre
val bn_mont_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t nLen -> mu: Hacl.Spec.Bignum.Definitions.limb t -> Prims.logical
let bn_mont_pre (#t:limb_t) (#nLen:size_pos) (n:lbignum t nLen) (mu:limb t) = (1 + bn_v n * v mu) % pow2 (bits t) == 0 /\ bn_v n % 2 = 1 /\ 1 < bn_v n /\ bn_v n < pow2 (bits t * nLen)
{ "file_name": "code/bignum/Hacl.Spec.Bignum.Montgomery.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 16, "start_col": 0, "start_line": 13 }
module Hacl.Spec.Bignum.Montgomery open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module M = Hacl.Spec.Montgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.Montgomery.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t nLen -> mu: Hacl.Spec.Bignum.Definitions.limb t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_Equality", "Prims.op_LessThan", "Prims.logical" ]
[]
false
false
false
false
true
let bn_mont_pre (#t: limb_t) (#nLen: size_pos) (n: lbignum t nLen) (mu: limb t) =
(1 + bn_v n * v mu) % pow2 (bits t) == 0 /\ bn_v n % 2 = 1 /\ 1 < bn_v n /\ bn_v n < pow2 (bits t * nLen)
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_one
val lemma_mul_one (#f:G.field) (a:G.felem f) : Lemma (fmul a G.one == a)
val lemma_mul_one (#f:G.field) (a:G.felem f) : Lemma (fmul a G.one == a)
let lemma_mul_one #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 22, "start_col": 0, "start_line": 17 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; () let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul a Spec.GaloisField.one == a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly", "Vale.Math.Poly2.Galois.Lemmas.fmul", "Spec.GaloisField.one", "Prims.unit", "Vale.Math.Poly2.Lemmas.lemma_mod_small", "Vale.Math.Poly2.lemma_mul_one", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Galois.irred_poly", "Vale.Math.Poly2.Galois.to_poly" ]
[]
true
false
true
false
false
let lemma_mul_one #f a =
let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.serialized_point_dh
val serialized_point_dh : cs: Spec.Agile.HPKE.ciphersuite -> Type0
let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs))
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 91, "end_line": 20, "start_col": 0, "start_line": 20 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_dh_serialized" ]
[]
false
false
false
true
true
let serialized_point_dh (cs: S.ciphersuite) =
lbuffer uint8 (size (S.size_dh_serialized cs))
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.key_dh_public
val key_dh_public : cs: Spec.Agile.HPKE.ciphersuite -> Type0
let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs))
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 16, "start_col": 0, "start_line": 16 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_dh_public" ]
[]
false
false
false
true
true
let key_dh_public (cs: S.ciphersuite) =
lbuffer uint8 (size (S.size_dh_public cs))
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly
val lemma_eq_to_poly (#f:G.field) (a b:G.felem f) : Lemma (requires to_poly a == to_poly b) (ensures a == b)
val lemma_eq_to_poly (#f:G.field) (a b:G.felem f) : Lemma (requires to_poly a == to_poly b) (ensures a == b)
let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; ()
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 8, "start_col": 0, "start_line": 5 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> b: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (requires Vale.Math.Poly2.Galois.to_poly a == Vale.Math.Poly2.Galois.to_poly b) (ensures a == b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Prims.unit", "Vale.Math.Poly2.Galois.lemma_felem_poly" ]
[]
true
false
true
false
false
let lemma_eq_to_poly #f a b =
lemma_felem_poly a; lemma_felem_poly b; ()
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_zero
val lemma_mul_zero (#f:G.field) (a:G.felem f) : Lemma (fmul a G.zero == G.zero)
val lemma_mul_zero (#f:G.field) (a:G.felem f) : Lemma (fmul a G.zero == G.zero)
let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 15, "start_col": 0, "start_line": 10 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; ()
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul a Spec.GaloisField.zero == Spec.GaloisField.zero)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly", "Vale.Math.Poly2.Galois.Lemmas.fmul", "Spec.GaloisField.zero", "Prims.unit", "Vale.Math.Poly2.Lemmas.lemma_mod_small", "Vale.Math.Poly2_s.zero", "Vale.Math.Poly2.lemma_mul_zero", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Galois.irred_poly", "Vale.Math.Poly2.Galois.to_poly" ]
[]
true
false
true
false
false
let lemma_mul_zero #f a =
let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.nonce_aead
val nonce_aead : cs: Spec.Agile.HPKE.ciphersuite -> Type0
let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs))
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 24, "start_col": 0, "start_line": 24 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_aead_nonce" ]
[]
false
false
false
true
true
let nonce_aead (cs: S.ciphersuite) =
lbuffer uint8 (size (S.size_aead_nonce cs))
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.gt
val gt : int -> int -> Tot bool
val gt : int -> int -> Tot bool
let gt n1 n2 = n1 > n2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 39, "start_col": 0, "start_line": 39 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.int -> n2: Prims.int -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_GreaterThan", "Prims.bool" ]
[]
false
false
false
true
false
let gt n1 n2 =
n1 > n2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.lt
val lt : int -> int -> Tot bool
val lt : int -> int -> Tot bool
let lt n1 n2 = n1 < n2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 36, "start_col": 0, "start_line": 36 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.int -> n2: Prims.int -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_LessThan", "Prims.bool" ]
[]
false
false
false
true
false
let lt n1 n2 =
n1 < n2
false
SteelTableJoin.fst
SteelTableJoin.v2'
val v2' (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
val v2' (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
let v2' (#p: Ghost.erased nat) (al: ptr) (err: ptr) : STT unit (pts_to1 al p `star` pts_to1 err 0) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = elim_exists () in // let _ = elim_pure _ in let _ = noop () in let _ = join al ar in return ()
{ "file_name": "share/steel/tests/SteelTableJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 47, "start_col": 0, "start_line": 37 }
module SteelTableJoin open Steel.ST.GenElim assume val ptr : Type0 assume val pts_to1 (p: ptr) (v: Ghost.erased nat) : vprop assume val split (#v: Ghost.erased nat) (p: ptr) : STT ptr (pts_to1 p v) (fun res -> exists_ (fun vl -> exists_ (fun vr -> pts_to1 p vl `star` pts_to1 res vr))) assume val join (#opened: _) (#pl #pr: Ghost.erased nat) (al ar: ptr) : STGhostT (Ghost.erased nat) opened (pts_to1 al pl `star` pts_to1 ar pr) (fun res -> pts_to1 al res) assume val v1 (#p: Ghost.erased nat) (a: ptr) (err: ptr) : STT unit (pts_to1 a p `star` pts_to1 err 0) (fun _ -> pts_to1 a p `star` exists_ (fun v -> pts_to1 err v)) let v2 (#p: Ghost.erased nat) (al: ptr) (err: ptr) : STT unit (pts_to1 al p `star` pts_to1 err 0) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = gen_elim () in let _ = join al ar in intro_exists _ (fun v -> pts_to1 al _ `star` pts_to1 err v); intro_exists _ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v)); return ()
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "SteelTableJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
al: SteelTableJoin.ptr -> err: SteelTableJoin.ptr -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "FStar.Ghost.erased", "Prims.nat", "SteelTableJoin.ptr", "Steel.ST.Util.return", "Prims.unit", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "SteelTableJoin.pts_to1", "Steel.Effect.Common.vprop", "SteelTableJoin.join", "Steel.ST.GenElim.Base.fstp", "FStar.Ghost.reveal", "FStar.Pervasives.Native.tuple2", "Steel.ST.GenElim.Base.sndp", "Steel.ST.Util.noop", "Steel.ST.Util.elim_exists", "SteelTableJoin.v1", "Steel.ST.GenElim.gen_elim", "Steel.Effect.Common.star", "Prims.l_and", "Prims.l_True", "Prims.prop", "SteelTableJoin.split" ]
[]
false
true
false
false
false
let v2' (#p: Ghost.erased nat) (al err: ptr) : STT unit ((pts_to1 al p) `star` (pts_to1 err 0)) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v)))) =
let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = elim_exists () in let _ = noop () in let _ = join al ar in return ()
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.max_length_info
val max_length_info : a: Spec.Agile.HPKE.hash_algorithm -> Prims.int
let max_length_info (a:S.hash_algorithm) = max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 122, "end_line": 29, "start_col": 0, "start_line": 28 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs)) inline_for_extraction noextract let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs)) (* Redefining this to work around Low*'s limitation on buffer size *)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Agile.HPKE.hash_algorithm -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.hash_algorithm", "Prims.op_Subtraction", "Lib.IntTypes.max_size_t", "Spec.Agile.HPKE.size_label_version", "Spec.Agile.HPKE.size_suite_id_hpke", "Spec.Agile.HPKE.size_label_info_hash", "Spec.Hash.Definitions.block_length", "Prims.int" ]
[]
false
false
false
true
false
let max_length_info (a: S.hash_algorithm) =
max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.in_tree
val in_tree : int -> tree -> Tot bool
val in_tree : int -> tree -> Tot bool
let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 26, "start_col": 0, "start_line": 23 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.op_BarBar", "Prims.op_Equality", "BinarySearchTreeBasic.in_tree", "Prims.bool" ]
[ "recursion" ]
false
false
false
true
false
let rec in_tree x t =
match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.is_bst
val is_bst : tree -> Tot bool
val is_bst : tree -> Tot bool
let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 45, "start_col": 0, "start_line": 42 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeBasic.tree -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "BinarySearchTreeBasic.tree", "Prims.int", "Prims.op_AmpAmp", "BinarySearchTreeBasic.all", "BinarySearchTreeBasic.gt", "BinarySearchTreeBasic.lt", "BinarySearchTreeBasic.is_bst", "Prims.bool" ]
[ "recursion" ]
false
false
false
true
false
let rec is_bst t =
match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.ge
val ge : int -> int -> Tot bool
val ge : int -> int -> Tot bool
let ge n1 n2 = n1 >= n2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 114, "start_col": 0, "start_line": 114 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.int -> n2: Prims.int -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.bool" ]
[]
false
false
false
true
false
let ge n1 n2 =
n1 >= n2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.all
val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)})
val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)})
let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 33, "start_col": 0, "start_line": 30 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: Prims.int -> Prims.bool) -> t: BinarySearchTreeBasic.tree -> r: Prims.bool{r <==> (forall (x: Prims.int). BinarySearchTreeBasic.in_tree x t ==> p x)}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.bool", "BinarySearchTreeBasic.tree", "Prims.op_AmpAmp", "BinarySearchTreeBasic.all", "Prims.l_iff", "Prims.b2t", "Prims.l_Forall", "Prims.l_imp", "BinarySearchTreeBasic.in_tree" ]
[ "recursion" ]
false
false
false
false
false
let rec all p t =
match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.search
val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t})
val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t})
let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 63, "start_col": 0, "start_line": 58 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t} -> r: Prims.bool{r <==> BinarySearchTreeBasic.in_tree x t}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "Prims.op_Equality", "Prims.bool", "Prims.op_LessThan", "BinarySearchTreeBasic.search", "Prims.l_iff", "BinarySearchTreeBasic.in_tree" ]
[ "recursion" ]
false
false
false
false
false
let rec search x t =
match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_commute
val lemma_mul_commute (#f:G.field) (a b:G.felem f) : Lemma (fmul a b == fmul b a)
val lemma_mul_commute (#f:G.field) (a b:G.felem f) : Lemma (fmul a b == fmul b a)
let lemma_mul_commute #f a b = let pa = to_poly a in let pb = to_poly b in let m = irred_poly f in lemma_mul_commute pa pb; lemma_eq_to_poly (fmul a b) (fmul b a)
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 29, "start_col": 0, "start_line": 24 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; () let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero let lemma_mul_one #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> b: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul a b == Vale.Math.Poly2.Galois.Lemmas.fmul b a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly", "Vale.Math.Poly2.Galois.Lemmas.fmul", "Prims.unit", "Vale.Math.Poly2.lemma_mul_commute", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Galois.irred_poly", "Vale.Math.Poly2.Galois.to_poly" ]
[]
true
false
true
false
false
let lemma_mul_commute #f a b =
let pa = to_poly a in let pb = to_poly b in let m = irred_poly f in lemma_mul_commute pa pb; lemma_eq_to_poly (fmul a b) (fmul b a)
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_associate
val lemma_mul_associate (#f:G.field) (a b c:G.felem f) : Lemma (fmul a (fmul b c) == fmul (fmul a b) c)
val lemma_mul_associate (#f:G.field) (a b c:G.felem f) : Lemma (fmul a (fmul b c) == fmul (fmul a b) c)
let lemma_mul_associate #f a b c = let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in lemma_mul_associate pa pb pc; // (((a * b) % m) * c) % m // (a * ((b * c) % m)) % m PL.lemma_mod_mul_mod (pa *. pb) m pc; PL.lemma_mod_mul_mod (pb *. pc) m pa; Vale.Math.Poly2.lemma_mul_commute pa (pb *. pc); Vale.Math.Poly2.lemma_mul_commute pa ((pb *. pc) %. m); lemma_eq_to_poly (fmul a (fmul b c)) (fmul (fmul a b) c)
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 43, "start_col": 0, "start_line": 31 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; () let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero let lemma_mul_one #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a let lemma_mul_commute #f a b = let pa = to_poly a in let pb = to_poly b in let m = irred_poly f in lemma_mul_commute pa pb; lemma_eq_to_poly (fmul a b) (fmul b a)
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> b: Spec.GaloisField.felem f -> c: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul a (Vale.Math.Poly2.Galois.Lemmas.fmul b c) == Vale.Math.Poly2.Galois.Lemmas.fmul (Vale.Math.Poly2.Galois.Lemmas.fmul a b) c)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly", "Vale.Math.Poly2.Galois.Lemmas.fmul", "Prims.unit", "Vale.Math.Poly2.lemma_mul_commute", "Vale.Math.Poly2.op_Percent_Dot", "Vale.Math.Poly2.op_Star_Dot", "Vale.Math.Poly2.Lemmas.lemma_mod_mul_mod", "Vale.Math.Poly2.lemma_mul_associate", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Galois.irred_poly", "Vale.Math.Poly2.Galois.to_poly" ]
[]
true
false
true
false
false
let lemma_mul_associate #f a b c =
let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in lemma_mul_associate pa pb pc; PL.lemma_mod_mul_mod (pa *. pb) m pc; PL.lemma_mod_mul_mod (pb *. pc) m pa; Vale.Math.Poly2.lemma_mul_commute pa (pb *. pc); Vale.Math.Poly2.lemma_mul_commute pa ((pb *. pc) %. m); lemma_eq_to_poly (fmul a (fmul b c)) (fmul (fmul a b) c)
false
Pulse.Typing.Combinators.fst
Pulse.Typing.Combinators.mk_bind_atomic_atomic
val mk_bind_atomic_atomic:bind_t C_STAtomic? C_STAtomic?
val mk_bind_atomic_atomic:bind_t C_STAtomic? C_STAtomic?
let mk_bind_atomic_atomic : bind_t C_STAtomic? C_STAtomic? = fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_k -> let _, x = px in let b = nvar_as_binder px (comp_res c1) in let C_STAtomic inames1 obs1 sc1 = c1 in let C_STAtomic inames2 obs2 sc2 = c2 in if at_most_one_observable obs1 obs2 then ( if eq_tm inames1 inames2 then begin let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) end else if bias_k then ( let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 inames2 obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let c1 = C_STAtomic inames2 obs1 sc1 in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) ) else begin let new_inames = tm_join_inames inames1 inames2 in let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 new_inames obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let d_e2 = T_Sub _ _ _ _ d_e2 (STS_AtomicInvs _ sc2 inames2 new_inames obs2 obs2 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let c1 = C_STAtomic new_inames obs1 sc1 in let c2 = C_STAtomic new_inames obs2 sc2 in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) end ) else ( T.fail "Should have been handled separately" )
{ "file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 270, "start_col": 0, "start_line": 237 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Typing.Combinators module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure assume val invert_forall_typing (#g #u #b #body:_) (d:tot_typing g (tm_forall_sl u b body) tm_vprop) (x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) }) : GTot ( tot_typing g b.binder_ty (tm_type u) & tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop ) assume val construct_forall_typing (#g #u #b #body:_) (x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) }) (dt:tot_typing g b.binder_ty (tm_type u)) (db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop) : GTot (tot_typing g (tm_forall_sl u b body) tm_vprop) let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1) : GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) & (tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop)) (decreases v) = match v with | VE_Refl _ _ -> (fun x -> x), (fun x -> x) | VE_Sym _ _ _ v' -> let f, g = vprop_equiv_typing v' in g, f | VE_Trans g t0 t2 t1 v02 v21 -> let f02, f20 = vprop_equiv_typing v02 in let f21, f12 = vprop_equiv_typing v21 in (fun x -> f21 (f02 x)), (fun x -> f20 (f12 x)) | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> let f0, f0' = vprop_equiv_typing v0 in let f1, f1' = vprop_equiv_typing v1 in let ff (x:tot_typing g (tm_star s0 s1) tm_vprop) : tot_typing g (tm_star s0' s1') tm_vprop = let s0_typing = star_typing_inversion_l x in let s1_typing = star_typing_inversion_r x in let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in star_typing s0'_typing s1'_typing in let gg (x:tot_typing g (tm_star s0' s1') tm_vprop) : tot_typing g (tm_star s0 s1) tm_vprop = let s0'_typing = star_typing_inversion_l x in let s1'_typing = star_typing_inversion_r x in star_typing (f0' s0'_typing) (f1' s1'_typing) in ff, gg | VE_Unit g t -> let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop) : tot_typing g t tm_vprop = let r = star_typing_inversion_r x in r in let bk (x:tot_typing g t tm_vprop) : tot_typing g (tm_star tm_emp t) tm_vprop = star_typing emp_typing x in fwd, bk | VE_Comm g t0 t1 -> let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop) : tot_typing g (tm_star t1 t0) tm_vprop = let tt0 = star_typing_inversion_l x in let tt1 = star_typing_inversion_r x in star_typing tt1 tt0 in f t0 t1, f t1 t0 | VE_Assoc g t0 t1 t2 -> let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop) : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop = let tt0 = star_typing_inversion_l x in let tt12 = star_typing_inversion_r x in let tt1 = star_typing_inversion_l tt12 in let tt2 = star_typing_inversion_r tt12 in star_typing (star_typing tt0 tt1) tt2 in let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop) : tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop = let tt01 = star_typing_inversion_l x in let tt2 = star_typing_inversion_r x in let tt0 = star_typing_inversion_l tt01 in let tt1 = star_typing_inversion_r tt01 in star_typing tt0 (star_typing tt1 tt2) in fwd, bk | VE_Ext g t0 t1 token -> let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in (fun _ -> d2), (fun _ -> d1) | VE_Fa g x u b t0 t1 d -> let d0, d1 = vprop_equiv_typing d in (fun fa0_typing -> let b_typing, t0_typing = invert_forall_typing fa0_typing x in let t1_typing = d0 t0_typing in construct_forall_typing #g #u x b_typing t1_typing), (fun fa1_typing -> let b_typing, t1_typing = invert_forall_typing fa1_typing x in let t0_typing = d1 t1_typing in construct_forall_typing #g #u #b #t0 x b_typing t0_typing) #push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats" let bind_t (case_c1 case_c2:comp_st -> bool) = (g:env) -> (pre:term) -> (e1:st_term) -> (e2:st_term) -> (c1:comp_st{ case_c1 c1 }) -> (c2:comp_st{ case_c2 c2 }) -> (px:nvar { ~ (Set.mem (snd px) (dom g)) }) -> (d_e1:st_typing g e1 c1) -> (d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) -> (d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) -> (res_typing:universe_of g (comp_res c2) (comp_u c2)) -> (post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2)) (open_term_nv (comp_post c2) px) tm_vprop) -> (bias_towards_continuation:bool) -> T.TacH (t:st_term & c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\ (bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } & st_typing g t c) (requires fun _ -> let _, x = px in comp_pre c1 == pre /\ None? (lookup g x) /\ (~(x `Set.mem` freevars_st e2)) /\ open_term (comp_post c1) x == comp_pre c2 /\ (~ (x `Set.mem` freevars (comp_post c2)))) (ensures fun _ _ -> True) let mk_bind_st_st : bind_t C_ST? C_ST? = fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ -> let _, x = px in let b = nvar_as_binder px (comp_res c1) in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) let inames_of (c:comp_st) : term = match c with | C_ST _ | C_STGhost _ -> tm_emp_inames | C_STAtomic inames _ _ -> inames let with_inames (c:comp_st) (i:term) = match c with | C_ST _ -> c | C_STGhost sc -> C_STGhost sc | C_STAtomic _ obs sc -> C_STAtomic i obs sc let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term) : T.Tac (c':comp_st { with_inames c new_inames == c' } & st_typing g e c') = match c with | C_ST _ | C_STGhost _ -> (| c, d_e |) | C_STAtomic inames obs sc -> let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in (| with_inames c new_inames, d_e |) let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) = C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c) let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c) : T.Tac (option (st_typing g e (st_ghost_as_atomic c))) = let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in match w with | None -> None | Some w -> let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in Some d let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c) : T.Tac (st_typing g e (st_ghost_as_atomic c)) = let w = try_lift_ghost_atomic d in match w with | None -> let open Pulse.PP in let t = comp_res c in fail_doc g (Some t.range) [ text "Expected a term with a non-informative (e.g., erased) type; got" ^/^ pp t ] | Some d -> d let mk_bind_ghost_ghost : bind_t C_STGhost? C_STGhost? = fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ -> let _, x = px in let b = nvar_as_binder px (comp_res c1) in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.Combinators.fst" }
[ { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 8, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Pulse.Typing.Combinators.bind_t C_STAtomic? C_STAtomic?
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp_st", "Prims.b2t", "Pulse.Syntax.Base.uu___is_C_STAtomic", "Pulse.Syntax.Base.nvar", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Base.var", "FStar.Pervasives.Native.snd", "Pulse.Syntax.Base.ppname", "Pulse.Typing.Env.dom", "Pulse.Typing.st_typing", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.comp_res", "Pulse.Syntax.Pure.tm_type", "Pulse.Syntax.Base.comp_u", "Pulse.Typing.Env.push_binding", "FStar.Pervasives.Native.fst", "Pulse.Syntax.Naming.open_st_term_nv", "Pulse.Typing.universe_of", "Pulse.Syntax.Naming.open_term_nv", "Pulse.Syntax.Base.comp_post", "Pulse.Syntax.Base.tm_vprop", "Prims.bool", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.st_comp", "Pulse.Typing.at_most_one_observable", "Pulse.Syntax.Base.eq_tm", "FStar.Pervasives.Mkdtuple3", "Prims.l_and", "Prims.eq2", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Typing.Combinators.st_comp_with_pre", "Prims.l_imp", "Pulse.Syntax.Base.effect_annot", "Pulse.Syntax.Base.effect_annot_of_comp", "Pulse.Typing.wr", "Pulse.Typing.bind_comp_out", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Typing.T_Bind", "Pulse.Typing.bind_comp", "Pulse.Typing.Bind_comp", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.C_STAtomic", "Pulse.Syntax.Base.comp", "Pulse.Typing.T_Sub", "Pulse.Typing.st_sub", "Pulse.Typing.STS_AtomicInvs", "Pulse.Typing.prop_validity", "Pulse.Typing.tm_inames_subset", "Pulse.Checker.Pure.check_prop_validity", "Pulse.Typing.tm_inames_subset_typing", "Pulse.Typing.tm_join_inames", "FStar.Tactics.V2.Derived.fail", "Pulse.Syntax.Base.binder", "Pulse.Typing.Combinators.nvar_as_binder" ]
[]
false
false
false
true
false
let mk_bind_atomic_atomic:bind_t C_STAtomic? C_STAtomic? =
fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_k -> let _, x = px in let b = nvar_as_binder px (comp_res c1) in let C_STAtomic inames1 obs1 sc1 = c1 in let C_STAtomic inames2 obs2 sc2 = c2 in if at_most_one_observable obs1 obs2 then (if eq_tm inames1 inames2 then let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |) else if bias_k then (let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 inames2 obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let c1 = C_STAtomic inames2 obs1 sc1 in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)) else let new_inames = tm_join_inames inames1 inames2 in let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 new_inames obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let d_e2 = T_Sub _ _ _ _ d_e2 (STS_AtomicInvs _ sc2 inames2 new_inames obs2 obs2 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in let c1 = C_STAtomic new_inames obs1 sc1 in let c2 = C_STAtomic new_inames obs2 sc2 in let bc = Bind_comp g x c1 c2 res_typing x post_typing in (| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)) else (T.fail "Should have been handled separately")
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.insert
val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))})
val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))})
let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 73, "start_col": 0, "start_line": 68 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t} -> r: BinarySearchTreeBasic.tree { BinarySearchTreeBasic.is_bst r /\ (forall (y: Prims.int). BinarySearchTreeBasic.in_tree y r <==> BinarySearchTreeBasic.in_tree y t \/ x = y) }
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "BinarySearchTreeBasic.Node", "BinarySearchTreeBasic.Leaf", "Prims.op_Equality", "Prims.bool", "Prims.op_LessThan", "BinarySearchTreeBasic.insert", "Prims.l_and", "Prims.l_Forall", "Prims.l_iff", "BinarySearchTreeBasic.in_tree", "Prims.l_or" ]
[ "recursion" ]
false
false
false
false
false
let rec insert x t =
match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2)
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.insert'
val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))))
val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))))
let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 88, "start_col": 0, "start_line": 80 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree -> Prims.Pure BinarySearchTreeBasic.tree
Prims.Pure
[]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "BinarySearchTreeBasic.Node", "BinarySearchTreeBasic.Leaf", "Prims.op_Equality", "Prims.bool", "Prims.op_LessThan", "BinarySearchTreeBasic.insert'" ]
[ "recursion" ]
false
false
false
false
false
let rec insert' x t =
match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2)
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.find_max
val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t})
val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t})
let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 118, "start_col": 0, "start_line": 118 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t /\ Node? t} -> x: Prims.int { BinarySearchTreeBasic.all (BinarySearchTreeBasic.ge x) t /\ BinarySearchTreeBasic.in_tree x t }
Prims.Tot
[ "total" ]
[]
[ "BinarySearchTreeBasic.tree", "Prims.l_and", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "BinarySearchTreeBasic.uu___is_Node", "Prims.int", "BinarySearchTreeBasic.uu___is_Leaf", "Prims.bool", "BinarySearchTreeBasic.find_max", "BinarySearchTreeBasic.all", "BinarySearchTreeBasic.ge", "BinarySearchTreeBasic.in_tree" ]
[ "recursion" ]
false
false
false
false
false
let rec find_max (Node n _ t2) =
if Leaf? t2 then n else find_max t2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.find_max'
val find_max' : t:tree{Node? t}-> Tot int
val find_max' : t:tree{Node? t}-> Tot int
let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 121, "start_col": 0, "start_line": 121 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeBasic.tree{Node? t} -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.uu___is_Node", "Prims.int", "BinarySearchTreeBasic.uu___is_Leaf", "Prims.bool", "BinarySearchTreeBasic.find_max'" ]
[ "recursion" ]
false
false
false
false
false
let rec find_max' (Node n _ t2) =
if Leaf? t2 then n else find_max' t2
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_distribute_left
val lemma_mul_distribute_left (#f:G.field) (a b c:G.felem f) : Lemma (fmul (fadd a b) c == fadd (fmul a c) (fmul b c))
val lemma_mul_distribute_left (#f:G.field) (a b c:G.felem f) : Lemma (fmul (fadd a b) c == fadd (fmul a c) (fmul b c))
let lemma_mul_distribute_left #f a b c = let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in PL.lemma_mul_distribute_left pa pb pc; PL.lemma_mod_distribute (pa *. pc) (pb *. pc) m; lemma_eq_to_poly (fmul (fadd a b) c) (fadd (fmul a c) (fmul b c))
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 52, "start_col": 0, "start_line": 45 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; () let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero let lemma_mul_one #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a let lemma_mul_commute #f a b = let pa = to_poly a in let pb = to_poly b in let m = irred_poly f in lemma_mul_commute pa pb; lemma_eq_to_poly (fmul a b) (fmul b a) let lemma_mul_associate #f a b c = let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in lemma_mul_associate pa pb pc; // (((a * b) % m) * c) % m // (a * ((b * c) % m)) % m PL.lemma_mod_mul_mod (pa *. pb) m pc; PL.lemma_mod_mul_mod (pb *. pc) m pa; Vale.Math.Poly2.lemma_mul_commute pa (pb *. pc); Vale.Math.Poly2.lemma_mul_commute pa ((pb *. pc) %. m); lemma_eq_to_poly (fmul a (fmul b c)) (fmul (fmul a b) c)
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> b: Spec.GaloisField.felem f -> c: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul (Vale.Math.Poly2.Galois.Lemmas.fadd a b) c == Vale.Math.Poly2.Galois.Lemmas.fadd (Vale.Math.Poly2.Galois.Lemmas.fmul a c) (Vale.Math.Poly2.Galois.Lemmas.fmul b c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Vale.Math.Poly2.Galois.Lemmas.lemma_eq_to_poly", "Vale.Math.Poly2.Galois.Lemmas.fmul", "Vale.Math.Poly2.Galois.Lemmas.fadd", "Prims.unit", "Vale.Math.Poly2.Lemmas.lemma_mod_distribute", "Vale.Math.Poly2.op_Star_Dot", "Vale.Math.Poly2.Lemmas.lemma_mul_distribute_left", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Galois.irred_poly", "Vale.Math.Poly2.Galois.to_poly" ]
[]
true
false
true
false
false
let lemma_mul_distribute_left #f a b c =
let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in PL.lemma_mul_distribute_left pa pb pc; PL.lemma_mod_distribute (pa *. pc) (pb *. pc) m; lemma_eq_to_poly (fmul (fadd a b) c) (fadd (fmul a c) (fmul b c))
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.insert''
val insert'' : int -> tree -> Tot tree
val insert'' : int -> tree -> Tot tree
let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 97, "start_col": 0, "start_line": 92 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree -> BinarySearchTreeBasic.tree
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "BinarySearchTreeBasic.Node", "BinarySearchTreeBasic.Leaf", "Prims.op_Equality", "Prims.bool", "Prims.op_LessThan", "BinarySearchTreeBasic.insert''" ]
[ "recursion" ]
false
false
false
true
false
let rec insert'' x t =
match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2)
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.find_max_eq
val find_max_eq : t:tree{Node? t /\ is_bst t} -> Lemma (find_max t = find_max' t)
val find_max_eq : t:tree{Node? t /\ is_bst t} -> Lemma (find_max t = find_max' t)
let find_max_eq t = find_max_lemma t
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 128, "start_col": 0, "start_line": 128 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2 val find_max' : t:tree{Node? t}-> Tot int let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2 val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t)) let rec find_max_lemma (Node _ _ t2) = if Node? t2 then find_max_lemma t2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeBasic.tree{Node? t /\ BinarySearchTreeBasic.is_bst t} -> FStar.Pervasives.Lemma (ensures BinarySearchTreeBasic.find_max t = BinarySearchTreeBasic.find_max' t)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "BinarySearchTreeBasic.tree", "Prims.l_and", "Prims.b2t", "BinarySearchTreeBasic.uu___is_Node", "BinarySearchTreeBasic.is_bst", "BinarySearchTreeBasic.find_max_lemma", "Prims.unit" ]
[]
true
false
true
false
false
let find_max_eq t =
find_max_lemma t
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.delete'
val delete' : x : int -> t:tree -> Tot tree (decreases t)
val delete' : x : int -> t:tree -> Tot tree (decreases t)
let rec delete' x t = match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match (t1, t2) with | (Leaf, Leaf) -> Leaf | (_, Leaf) -> t1 | (Leaf, _) -> t2 | _ -> let y = find_max' t1 in Node y (delete' y t1) t2 else if x < n then Node n (delete' x t1) t2 else Node n t1 (delete' x t2)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 157, "start_col": 0, "start_line": 147 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2 val find_max' : t:tree{Node? t}-> Tot int let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2 val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t)) let rec find_max_lemma (Node _ _ t2) = if Node? t2 then find_max_lemma t2 val find_max_eq : t:tree{Node? t /\ is_bst t} -> Lemma (find_max t = find_max' t) let find_max_eq t = find_max_lemma t val delete : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ not (in_tree x r) /\ (forall y. x <> y ==> (in_tree y t = in_tree y r))}) (decreases t) #set-options "--z3rlimit 15" let rec delete x t = match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match t1, t2 with | Leaf, Leaf -> Leaf | _ , Leaf -> t1 | Leaf, _ -> t2 | _ -> let y = find_max t1 in Node y (delete y t1) t2 else if x < n then Node n (delete x t1) t2 else Node n t1 (delete x t2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree -> Prims.Tot BinarySearchTreeBasic.tree
Prims.Tot
[ "total", "" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "BinarySearchTreeBasic.Leaf", "Prims.op_Equality", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "BinarySearchTreeBasic.Node", "BinarySearchTreeBasic.delete'", "BinarySearchTreeBasic.find_max'", "Prims.bool", "Prims.op_LessThan" ]
[ "recursion" ]
false
false
false
true
false
let rec delete' x t =
match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match (t1, t2) with | Leaf, Leaf -> Leaf | _, Leaf -> t1 | Leaf, _ -> t2 | _ -> let y = find_max' t1 in Node y (delete' y t1) t2 else if x < n then Node n (delete' x t1) t2 else Node n t1 (delete' x t2)
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.find_max_lemma
val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t))
val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t))
let rec find_max_lemma (Node _ _ t2) = if Node? t2 then find_max_lemma t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 125, "start_col": 0, "start_line": 125 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2 val find_max' : t:tree{Node? t}-> Tot int let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2 val find_max_lemma : t:tree{Node? t /\ is_bst t} ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: BinarySearchTreeBasic.tree{Node? t /\ BinarySearchTreeBasic.is_bst t} -> FStar.Pervasives.Lemma (ensures BinarySearchTreeBasic.in_tree (BinarySearchTreeBasic.find_max' t) t /\ BinarySearchTreeBasic.all (BinarySearchTreeBasic.ge (BinarySearchTreeBasic.find_max' t)) t)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "BinarySearchTreeBasic.tree", "Prims.l_and", "Prims.b2t", "BinarySearchTreeBasic.uu___is_Node", "BinarySearchTreeBasic.is_bst", "Prims.int", "BinarySearchTreeBasic.find_max_lemma", "Prims.bool", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec find_max_lemma (Node _ _ t2) =
if Node? t2 then find_max_lemma t2
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.insert_lemma
val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y))
val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y))
let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 108, "start_col": 0, "start_line": 106 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t} -> FStar.Pervasives.Lemma (ensures BinarySearchTreeBasic.is_bst (BinarySearchTreeBasic.insert'' x t) /\ (forall (y: Prims.int). BinarySearchTreeBasic.in_tree y (BinarySearchTreeBasic.insert'' x t) <==> BinarySearchTreeBasic.in_tree y t \/ x = y))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "BinarySearchTreeBasic.insert_lemma", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec insert_lemma x t =
match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2
false
Vale.Math.Poly2.Galois.Lemmas.fst
Vale.Math.Poly2.Galois.Lemmas.lemma_mul_distribute_right
val lemma_mul_distribute_right (#f:G.field) (a b c:G.felem f) : Lemma (fmul a (fadd b c) == fadd (fmul a b) (fmul a c))
val lemma_mul_distribute_right (#f:G.field) (a b c:G.felem f) : Lemma (fmul a (fadd b c) == fadd (fmul a b) (fmul a c))
let lemma_mul_distribute_right #f a b c = lemma_mul_distribute_left b c a; // fmul (fadd b c) a == fadd (fmul b a) (fmul c a) lemma_mul_commute a b; lemma_mul_commute a c; lemma_mul_commute a (fadd b c); ()
{ "file_name": "vale/code/lib/math/Vale.Math.Poly2.Galois.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 60, "start_col": 0, "start_line": 54 }
module Vale.Math.Poly2.Galois.Lemmas open FStar.Mul module PL = Vale.Math.Poly2.Lemmas let lemma_eq_to_poly #f a b = lemma_felem_poly a; lemma_felem_poly b; () let lemma_mul_zero #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_zero pa; PL.lemma_mod_small zero m; lemma_eq_to_poly (fmul a G.zero) G.zero let lemma_mul_one #f a = let pa = to_poly a in let m = irred_poly f in lemma_mul_one pa; PL.lemma_mod_small pa m; lemma_eq_to_poly (fmul a G.one) a let lemma_mul_commute #f a b = let pa = to_poly a in let pb = to_poly b in let m = irred_poly f in lemma_mul_commute pa pb; lemma_eq_to_poly (fmul a b) (fmul b a) let lemma_mul_associate #f a b c = let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in lemma_mul_associate pa pb pc; // (((a * b) % m) * c) % m // (a * ((b * c) % m)) % m PL.lemma_mod_mul_mod (pa *. pb) m pc; PL.lemma_mod_mul_mod (pb *. pc) m pa; Vale.Math.Poly2.lemma_mul_commute pa (pb *. pc); Vale.Math.Poly2.lemma_mul_commute pa ((pb *. pc) %. m); lemma_eq_to_poly (fmul a (fmul b c)) (fmul (fmul a b) c) let lemma_mul_distribute_left #f a b c = let pa = to_poly a in let pb = to_poly b in let pc = to_poly c in let m = irred_poly f in PL.lemma_mul_distribute_left pa pb pc; PL.lemma_mod_distribute (pa *. pc) (pb *. pc) m; lemma_eq_to_poly (fmul (fadd a b) c) (fadd (fmul a c) (fmul b c))
{ "checked_file": "/", "dependencies": [ "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2.Galois.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": "PL" }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2_s", "short_module": "P" }, { "abbrev": true, "full_module": "Spec.GaloisField", "short_module": "G" }, { "abbrev": true, "full_module": "Lib.IntTypes", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Galois", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.GaloisField.felem f -> b: Spec.GaloisField.felem f -> c: Spec.GaloisField.felem f -> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Galois.Lemmas.fmul a (Vale.Math.Poly2.Galois.Lemmas.fadd b c) == Vale.Math.Poly2.Galois.Lemmas.fadd (Vale.Math.Poly2.Galois.Lemmas.fmul a b) (Vale.Math.Poly2.Galois.Lemmas.fmul a c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.GaloisField.field", "Spec.GaloisField.felem", "Prims.unit", "Vale.Math.Poly2.Galois.Lemmas.lemma_mul_commute", "Vale.Math.Poly2.Galois.Lemmas.fadd", "Vale.Math.Poly2.Galois.Lemmas.lemma_mul_distribute_left" ]
[]
true
false
true
false
false
let lemma_mul_distribute_right #f a b c =
lemma_mul_distribute_left b c a; lemma_mul_commute a b; lemma_mul_commute a c; lemma_mul_commute a (fadd b c); ()
false
Steel.ST.CancellableSpinLock.fst
Steel.ST.CancellableSpinLock.release
val release (#v:vprop) (c:cancellable_lock v) : STT unit (v `star` can_release c) (fun _ -> emp)
val release (#v:vprop) (c:cancellable_lock v) : STT unit (v `star` can_release c) (fun _ -> emp)
let release #v c = intro_exists true (lock_inv_pred c.lref v); release c.llock
{ "file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 70, "start_col": 0, "start_line": 68 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Aseem Rastogi *) module Steel.ST.CancellableSpinLock open Steel.ST.Effect open Steel.ST.Util open Steel.FractionalPermission open Steel.ST.Reference open Steel.ST.SpinLock module G = FStar.Ghost [@@__reduce__] let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop = fun b -> pts_to r full_perm b `star` (if b then v else emp) [@@__reduce__] let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v) noeq type cancellable_lock (v:vprop) = { lref : ref bool; llock : lock (lock_inv lref v) } let new_cancellable_lock v = let r = alloc true in intro_exists true (lock_inv_pred r v); let l = new_lock (lock_inv r v) in return ({lref = r; llock = l}) [@__reduce__] let can_release #v c = pts_to c.lref full_perm true let acquire #v c = acquire c.llock; let b_erased = elim_exists () in let b = read c.lref in if b then begin rewrite (if b_erased then v else emp) v; rewrite (v `star` can_release c) (maybe_acquired b c) end else begin intro_exists (G.reveal b_erased) (lock_inv_pred c.lref v); release c.llock; rewrite emp (maybe_acquired b c) end; return b
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.SpinLock.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.CancellableSpinLock.fst" }
[ { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Steel.ST.CancellableSpinLock.cancellable_lock v -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.ST.CancellableSpinLock.cancellable_lock", "Steel.ST.SpinLock.release", "Steel.ST.CancellableSpinLock.lock_inv", "Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__lref", "Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__llock", "Prims.unit", "Steel.ST.Util.intro_exists", "Prims.bool", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.CancellableSpinLock.lock_inv_pred" ]
[]
false
true
false
false
false
let release #v c =
intro_exists true (lock_inv_pred c.lref v); release c.llock
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.delete
val delete : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ not (in_tree x r) /\ (forall y. x <> y ==> (in_tree y t = in_tree y r))}) (decreases t)
val delete : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ not (in_tree x r) /\ (forall y. x <> y ==> (in_tree y t = in_tree y r))}) (decreases t)
let rec delete x t = match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match t1, t2 with | Leaf, Leaf -> Leaf | _ , Leaf -> t1 | Leaf, _ -> t2 | _ -> let y = find_max t1 in Node y (delete y t1) t2 else if x < n then Node n (delete x t1) t2 else Node n t1 (delete x t2)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 144, "start_col": 0, "start_line": 134 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2 val find_max' : t:tree{Node? t}-> Tot int let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2 val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t)) let rec find_max_lemma (Node _ _ t2) = if Node? t2 then find_max_lemma t2 val find_max_eq : t:tree{Node? t /\ is_bst t} -> Lemma (find_max t = find_max' t) let find_max_eq t = find_max_lemma t val delete : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ not (in_tree x r) /\ (forall y. x <> y ==> (in_tree y t = in_tree y r))}) (decreases t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t} -> Prims.Tot (r: BinarySearchTreeBasic.tree { BinarySearchTreeBasic.is_bst r /\ Prims.op_Negation (BinarySearchTreeBasic.in_tree x r) /\ (forall (y: Prims.int). x <> y ==> BinarySearchTreeBasic.in_tree y t = BinarySearchTreeBasic.in_tree y r) })
Prims.Tot
[ "total", "" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "BinarySearchTreeBasic.Leaf", "Prims.op_Equality", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "BinarySearchTreeBasic.Node", "BinarySearchTreeBasic.delete", "Prims.l_and", "BinarySearchTreeBasic.all", "BinarySearchTreeBasic.ge", "BinarySearchTreeBasic.in_tree", "BinarySearchTreeBasic.find_max", "Prims.op_Negation", "Prims.l_Forall", "Prims.l_imp", "Prims.op_disEquality", "Prims.bool", "Prims.op_LessThan" ]
[ "recursion" ]
false
false
false
false
false
let rec delete x t =
match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match t1, t2 with | Leaf, Leaf -> Leaf | _, Leaf -> t1 | Leaf, _ -> t2 | _ -> let y = find_max t1 in Node y (delete y t1) t2 else if x < n then Node n (delete x t1) t2 else Node n t1 (delete x t2)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_inj_r
val lemma_append_inj_r: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a{length s1 = length t1 /\ length s2 = length t2 /\ equal (append s1 s2) (append t1 t2)} -> i:nat{i < length s2} -> Lemma (ensures (index s2 i == index t2 i))
val lemma_append_inj_r: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a{length s1 = length t1 /\ length s2 = length t2 /\ equal (append s1 s2) (append t1 t2)} -> i:nat{i < length s2} -> Lemma (ensures (index s2 i == index t2 i))
let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1)))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 63, "end_line": 28, "start_col": 0, "start_line": 26 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> t1: FStar.Seq.Base.seq a -> t2: FStar.Seq.Base.seq a { FStar.Seq.Base.length s1 = FStar.Seq.Base.length t1 /\ FStar.Seq.Base.length s2 = FStar.Seq.Base.length t2 /\ FStar.Seq.Base.equal (FStar.Seq.Base.append s1 s2) (FStar.Seq.Base.append t1 t2) } -> i: Prims.nat{i < FStar.Seq.Base.length s2} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index s2 i == FStar.Seq.Base.index t2 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "Prims.op_LessThan", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.index", "Prims.op_Addition", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_append_inj_r #_ s1 s2 t1 t2 i =
assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1)))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.mem_index
val mem_index (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x))
val mem_index (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x))
let mem_index = mem_index'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 60, "start_col": 0, "start_line": 60 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires FStar.Seq.Properties.mem x s) (ensures exists (i: Prims.nat{i < FStar.Seq.Base.length s}). FStar.Seq.Base.index s i == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.mem_index'" ]
[]
true
false
true
false
false
let mem_index =
mem_index'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_len_disj
val lemma_append_len_disj: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a {(length s1 = length t1 \/ length s2 = length t2) /\ (equal (append s1 s2) (append t1 t2))} -> Lemma (ensures (length s1 = length t1 /\ length s2 = length t2))
val lemma_append_len_disj: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a {(length s1 = length t1 \/ length s2 = length t2) /\ (equal (append s1 s2) (append t1 t2))} -> Lemma (ensures (length s1 = length t1 /\ length s2 = length t2))
let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 32, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> t1: FStar.Seq.Base.seq a -> t2: FStar.Seq.Base.seq a { (FStar.Seq.Base.length s1 = FStar.Seq.Base.length t1 \/ FStar.Seq.Base.length s2 = FStar.Seq.Base.length t2) /\ FStar.Seq.Base.equal (FStar.Seq.Base.append s1 s2) (FStar.Seq.Base.append t1 t2) } -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length s1 = FStar.Seq.Base.length t1 /\ FStar.Seq.Base.length s2 = FStar.Seq.Base.length t2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.l_and", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "Prims.cut", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_append_len_disj #_ s1 s2 t1 t2 =
cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2)
false
BinarySearchTreeBasic.fst
BinarySearchTreeBasic.delete_lemma
val delete_lemma : x:int -> t:tree{is_bst t} -> Lemma (ensures (is_bst (delete' x t) /\ not (in_tree x (delete' x t)) /\ (forall y. x <> y ==> (in_tree y (delete' x t) = in_tree y t)))) (decreases t)
val delete_lemma : x:int -> t:tree{is_bst t} -> Lemma (ensures (is_bst (delete' x t) /\ not (in_tree x (delete' x t)) /\ (forall y. x <> y ==> (in_tree y (delete' x t) = in_tree y t)))) (decreases t)
let rec delete_lemma x t = match t with | Leaf -> () | Node n t1 t2 -> if x <> n then (delete_lemma x t1; delete_lemma x t2) else if Node? t1 then (find_max_lemma t1; delete_lemma (find_max' t1) t1)
{ "file_name": "examples/data_structures/BinarySearchTreeBasic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 168, "start_col": 0, "start_line": 164 }
(* 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 BinarySearchTreeBasic type tree = | Leaf : tree | Node : n:int -> tree -> tree -> tree val in_tree : int -> tree -> Tot bool let rec in_tree x t = match t with | Leaf -> false | Node n t1 t2 -> x = n || in_tree x t1 || in_tree x t2 val all : p:(int -> Tot bool) -> t:tree -> Tot (r:bool{r <==> (forall x. in_tree x t ==> p x)}) let rec all p t = match t with | Leaf -> true | Node n t1 t2 -> p n && all p t1 && all p t2 val lt : int -> int -> Tot bool let lt n1 n2 = n1 < n2 val gt : int -> int -> Tot bool let gt n1 n2 = n1 > n2 val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (gt n) t1 && all (lt n) t2 && is_bst t1 && is_bst t2 (* Changing to the following equivalent variant of is_bst triggers errors all over the rest of this file (filed as #339) val is_bst : tree -> Tot bool let rec is_bst t = match t with | Leaf -> true | Node n t1 t2 -> all (fun n' -> n > n') t1 && all (fun n' -> n' < n) t2 && is_bst t1 && is_bst t2 *) val search : x:int -> t:tree{is_bst t} -> Tot (r:bool{r <==> in_tree x t}) let rec search x t = match t with | Leaf -> false | Node n t1 t2 -> if x = n then true else if x < n then search x t1 else search x t2 val insert : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y))}) let rec insert x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert x t1) t2 else Node n t1 (insert x t2) (* This variant also works, previously filed as #155 *) val insert' : x:int -> t:tree -> Pure tree (requires (b2t (is_bst t))) (ensures (fun r -> is_bst r /\ (forall y. in_tree y r <==> (in_tree y t \/ x = y)))) let rec insert' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then (let y = insert' x t1 in Node n (insert' x t1) t2) else Node n t1 (insert' x t2) (* One more variant with weak spec + extrinsic insert_lemma *) val insert'' : int -> tree -> Tot tree let rec insert'' x t = match t with | Leaf -> Node x Leaf Leaf | Node n t1 t2 -> if x = n then t else if x < n then Node n (insert'' x t1) t2 else Node n t1 (insert'' x t2) #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val insert_lemma : x:int -> t:tree{is_bst t} -> Lemma (is_bst (insert'' x t) /\ (forall y. in_tree y (insert'' x t) <==> in_tree y t \/ x = y)) //AR: tightening a bit here, since works locally but fails on CI #push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec insert_lemma x t = match t with | Leaf -> () | Node _ t1 t2 -> insert_lemma x t1; insert_lemma x t2 #pop-options #pop-options val ge : int -> int -> Tot bool let ge n1 n2 = n1 >= n2 val find_max : t:tree{is_bst t /\ Node? t} -> Tot (x:int{b2t (all (ge x) t) /\ in_tree x t}) let rec find_max (Node n _ t2) = if Leaf? t2 then n else find_max t2 val find_max' : t:tree{Node? t}-> Tot int let rec find_max' (Node n _ t2) = if Leaf? t2 then n else find_max' t2 val find_max_lemma : t:tree{Node? t /\ is_bst t} -> Lemma (in_tree (find_max' t) t /\ b2t (all (ge (find_max' t)) t)) let rec find_max_lemma (Node _ _ t2) = if Node? t2 then find_max_lemma t2 val find_max_eq : t:tree{Node? t /\ is_bst t} -> Lemma (find_max t = find_max' t) let find_max_eq t = find_max_lemma t val delete : x:int -> t:tree{is_bst t} -> Tot (r:tree{is_bst r /\ not (in_tree x r) /\ (forall y. x <> y ==> (in_tree y t = in_tree y r))}) (decreases t) #set-options "--z3rlimit 15" let rec delete x t = match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match t1, t2 with | Leaf, Leaf -> Leaf | _ , Leaf -> t1 | Leaf, _ -> t2 | _ -> let y = find_max t1 in Node y (delete y t1) t2 else if x < n then Node n (delete x t1) t2 else Node n t1 (delete x t2) val delete' : x : int -> t:tree -> Tot tree (decreases t) let rec delete' x t = match t with | Leaf -> Leaf | Node n t1 t2 -> if n = x then match (t1, t2) with | (Leaf, Leaf) -> Leaf | (_, Leaf) -> t1 | (Leaf, _) -> t2 | _ -> let y = find_max' t1 in Node y (delete' y t1) t2 else if x < n then Node n (delete' x t1) t2 else Node n t1 (delete' x t2) #set-options "--z3rlimit 20" val delete_lemma : x:int -> t:tree{is_bst t} -> Lemma (ensures (is_bst (delete' x t) /\ not (in_tree x (delete' x t)) /\ (forall y. x <> y ==> (in_tree y (delete' x t) = in_tree y t))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "BinarySearchTreeBasic.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int -> t: BinarySearchTreeBasic.tree{BinarySearchTreeBasic.is_bst t} -> FStar.Pervasives.Lemma (ensures BinarySearchTreeBasic.is_bst (BinarySearchTreeBasic.delete' x t) /\ Prims.op_Negation (BinarySearchTreeBasic.in_tree x (BinarySearchTreeBasic.delete' x t)) /\ (forall (y: Prims.int). x <> y ==> BinarySearchTreeBasic.in_tree y (BinarySearchTreeBasic.delete' x t) = BinarySearchTreeBasic.in_tree y t)) (decreases t)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.int", "BinarySearchTreeBasic.tree", "Prims.b2t", "BinarySearchTreeBasic.is_bst", "Prims.op_disEquality", "BinarySearchTreeBasic.delete_lemma", "Prims.unit", "Prims.bool", "BinarySearchTreeBasic.uu___is_Node", "BinarySearchTreeBasic.find_max'", "BinarySearchTreeBasic.find_max_lemma" ]
[ "recursion" ]
false
false
true
false
false
let rec delete_lemma x t =
match t with | Leaf -> () | Node n t1 t2 -> if x <> n then (delete_lemma x t1; delete_lemma x t2) else if Node? t1 then (find_max_lemma t1; delete_lemma (find_max' t1) t1)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_cons_inj
val lemma_cons_inj: #a:Type -> v1:a -> v2:a -> s1:seq a -> s2:seq a -> Lemma (requires (equal (cons v1 s1) (cons v2 s2))) (ensures (v1 == v2 /\ equal s1 s2))
val lemma_cons_inj: #a:Type -> v1:a -> v2:a -> s1:seq a -> s2:seq a -> Lemma (requires (equal (cons v1 s1) (cons v2 s2))) (ensures (v1 == v2 /\ equal s1 s2))
let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 47, "start_col": 0, "start_line": 43 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v1: a -> v2: a -> s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.equal (FStar.Seq.Base.cons v1 s1) (FStar.Seq.Base.cons v2 s2)) (ensures v1 == v2 /\ FStar.Seq.Base.equal s1 s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.index", "Prims.unit", "FStar.Seq.Properties.lemma_append_inj", "FStar.Seq.Base.create" ]
[]
true
false
true
false
false
let lemma_cons_inj #_ v1 v2 s1 s2 =
let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert (index t1 0 == index t2 0)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_inj_l
val lemma_append_inj_l: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a{length s1 = length t1 /\ equal (append s1 s2) (append t1 t2)} -> i:nat{i < length s1} -> Lemma (index s1 i == index t1 i)
val lemma_append_inj_l: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a{length s1 = length t1 /\ equal (append s1 s2) (append t1 t2)} -> i:nat{i < length s1} -> Lemma (index s1 i == index t1 i)
let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 24, "start_col": 0, "start_line": 22 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> t1: FStar.Seq.Base.seq a -> t2: FStar.Seq.Base.seq a { FStar.Seq.Base.length s1 = FStar.Seq.Base.length t1 /\ FStar.Seq.Base.equal (FStar.Seq.Base.append s1 s2) (FStar.Seq.Base.append t1 t2) } -> i: Prims.nat{i < FStar.Seq.Base.length s1} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index s1 i == FStar.Seq.Base.index t1 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "Prims.op_LessThan", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.index", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_append_inj_l #_ s1 s2 t1 t2 i =
assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_tail_append
val lemma_tail_append: #a:Type -> s1:seq a{length s1 > 0} -> s2:seq a -> Lemma (tail (append s1 s2) == append (tail s1) s2)
val lemma_tail_append: #a:Type -> s1:seq a{length s1 > 0} -> s2:seq a -> Lemma (tail (append s1 s2) == append (tail s1) s2)
let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 88, "end_line": 41, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a {FStar.Seq.Base.length s1 > 0} -> s2: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Properties.tail (FStar.Seq.Base.append s1 s2) == FStar.Seq.Base.append (FStar.Seq.Properties.tail s1) s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Seq.Base.length", "Prims.cut", "FStar.Seq.Base.equal", "FStar.Seq.Properties.tail", "FStar.Seq.Base.append", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_tail_append #_ s1 s2 =
cut (equal (tail (append s1 s2)) (append (tail s1) s2))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_inj
val lemma_append_inj: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a {length s1 = length t1 \/ length s2 = length t2} -> Lemma (requires (equal (append s1 s2) (append t1 t2))) (ensures (equal s1 t1 /\ equal s2 t2))
val lemma_append_inj: #a:Type -> s1:seq a -> s2:seq a -> t1:seq a -> t2:seq a {length s1 = length t1 \/ length s2 = length t2} -> Lemma (requires (equal (append s1 s2) (append t1 t2))) (ensures (equal s1 t1 /\ equal s2 t2))
let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 124, "end_line": 37, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> t1: FStar.Seq.Base.seq a -> t2: FStar.Seq.Base.seq a { FStar.Seq.Base.length s1 = FStar.Seq.Base.length t1 \/ FStar.Seq.Base.length s2 = FStar.Seq.Base.length t2 } -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.equal (FStar.Seq.Base.append s1 s2) (FStar.Seq.Base.append t1 t2)) (ensures FStar.Seq.Base.equal s1 t1 /\ FStar.Seq.Base.equal s2 t2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "FStar.Classical.forall_intro", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Seq.Properties.lemma_append_inj_r", "Prims.unit", "FStar.Seq.Properties.lemma_append_inj_l", "FStar.Seq.Properties.lemma_append_len_disj" ]
[]
false
false
true
false
false
let lemma_append_inj #_ s1 s2 t1 t2 =
lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i: nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i: nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_split
val lemma_split : #a:Type -> s:seq a -> i:nat{(0 <= i /\ i <= length s)} -> Lemma (ensures (append (fst (split s i)) (snd (split s i)) == s))
val lemma_split : #a:Type -> s:seq a -> i:nat{(0 <= i /\ i <= length s)} -> Lemma (ensures (append (fst (split s i)) (snd (split s i)) == s))
let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 50, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat{0 <= i /\ i <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.append (FStar.Pervasives.Native.fst (FStar.Seq.Properties.split s i)) (FStar.Pervasives.Native.snd (FStar.Seq.Properties.split s i)) == s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.cut", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "FStar.Pervasives.Native.fst", "FStar.Seq.Properties.split", "FStar.Pervasives.Native.snd", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_split #_ s i =
cut (equal (append (fst (split s i)) (snd (split s i))) s)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.sorted_feq
val sorted_feq (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s))
val sorted_feq (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s))
let sorted_feq = sorted_feq'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 92, "start_col": 0, "start_line": 92 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> _: a -> Prims.bool) -> g: (_: a -> _: a -> Prims.bool) -> s: FStar.Seq.Base.seq a {forall (x: a) (y: a). f x y == g x y} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Properties.sorted f s <==> FStar.Seq.Properties.sorted g s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.sorted_feq'" ]
[]
true
false
true
false
false
let sorted_feq =
sorted_feq'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_count
val lemma_append_count: #a:eqtype -> lo:seq a -> hi:seq a -> Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi)))
val lemma_append_count: #a:eqtype -> lo:seq a -> hi:seq a -> Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi)))
let lemma_append_count = lemma_append_count'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 108, "start_col": 0, "start_line": 108 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lo: FStar.Seq.Base.seq a -> hi: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.Seq.Properties.count x (FStar.Seq.Base.append lo hi) = FStar.Seq.Properties.count x lo + FStar.Seq.Properties.count x hi)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.lemma_append_count'" ]
[]
true
false
true
false
false
let lemma_append_count =
lemma_append_count'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_slice_first_in_append'
val lemma_slice_first_in_append' (#a: Type) (s1 s2: seq a) (i: nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2) )) (decreases (length s1))
val lemma_slice_first_in_append' (#a: Type) (s1 s2: seq a) (i: nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2) )) (decreases (length s1))
let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 70, "start_col": 0, "start_line": 64 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> i: Prims.nat{i <= FStar.Seq.Base.length s1} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (FStar.Seq.Base.slice (FStar.Seq.Base.append s1 s2) i (FStar.Seq.Base.length (FStar.Seq.Base.append s1 s2))) (FStar.Seq.Base.append (FStar.Seq.Base.slice s1 i (FStar.Seq.Base.length s1)) s2)) (decreases FStar.Seq.Base.length s1)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.Seq.Properties.lemma_slice_first_in_append'", "FStar.Seq.Properties.tail", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Seq.Base.append", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_slice_first_in_append' (#a: Type) (s1 s2: seq a) (i: nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2) )) (decreases (length s1)) =
if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.slice_upd
val slice_upd: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j /\ j <= length s} -> k:nat{k < length s} -> v:a -> Lemma (requires k < i \/ j <= k) (ensures slice (upd s k v) i j == slice s i j) [SMTPat (slice (upd s k v) i j)]
val slice_upd: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j /\ j <= length s} -> k:nat{k < length s} -> v:a -> Lemma (requires k < i \/ j <= k) (ensures slice (upd s k v) i j == slice s i j) [SMTPat (slice (upd s k v) i j)]
let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 75, "start_col": 0, "start_line": 74 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat -> j: Prims.nat{i <= j /\ j <= FStar.Seq.Base.length s} -> k: Prims.nat{k < FStar.Seq.Base.length s} -> v: a -> FStar.Pervasives.Lemma (requires k < i \/ j <= k) (ensures FStar.Seq.Base.slice (FStar.Seq.Base.upd s k v) i j == FStar.Seq.Base.slice s i j) [SMTPat (FStar.Seq.Base.slice (FStar.Seq.Base.upd s k v) i j)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.op_LessThan", "FStar.Seq.Base.lemma_eq_intro", "FStar.Seq.Base.slice", "FStar.Seq.Base.upd", "Prims.unit" ]
[]
true
false
true
false
false
let slice_upd #_ s i j k v =
lemma_eq_intro (slice (upd s k v) i j) (slice s i j)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_mem_count
val lemma_mem_count: #a:eqtype -> s:seq a -> f:(a -> Tot bool) -> Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x))
val lemma_mem_count: #a:eqtype -> s:seq a -> f:(a -> Tot bool) -> Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x))
let lemma_mem_count = lemma_mem_count'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 125, "start_col": 0, "start_line": 125 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> f: (_: a -> Prims.bool) -> FStar.Pervasives.Lemma (requires forall (i: Prims.nat{i < FStar.Seq.Base.length s}). f (FStar.Seq.Base.index s i)) (ensures forall (x: a). FStar.Seq.Properties.mem x s ==> f x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.lemma_mem_count'" ]
[]
true
false
true
false
false
let lemma_mem_count =
lemma_mem_count'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.sorted_feq'
val sorted_feq' (#a: Type) (f g: (a -> a -> Tot bool)) (s: seq a {forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s))
val sorted_feq' (#a: Type) (f g: (a -> a -> Tot bool)) (s: seq a {forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s))
let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 90, "start_col": 0, "start_line": 84 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> _: a -> Prims.bool) -> g: (_: a -> _: a -> Prims.bool) -> s: FStar.Seq.Base.seq a {forall (x: a) (y: a). f x y == g x y} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Properties.sorted f s <==> FStar.Seq.Properties.sorted g s) (decreases FStar.Seq.Base.length s)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.bool", "FStar.Seq.Base.seq", "Prims.l_Forall", "Prims.eq2", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Properties.sorted_feq'", "FStar.Seq.Properties.tail", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "FStar.Seq.Properties.sorted", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec sorted_feq' (#a: Type) (f g: (a -> a -> Tot bool)) (s: seq a {forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) =
if length s <= 1 then () else sorted_feq' f g (tail s)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.sorted_concat_lemma
val sorted_concat_lemma: #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi))))
val sorted_concat_lemma: #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi))))
let sorted_concat_lemma = sorted_concat_lemma'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 148, "start_col": 0, "start_line": 148 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> _: a -> Prims.bool){FStar.Seq.Properties.total_order a f} -> lo: FStar.Seq.Base.seq a {FStar.Seq.Properties.sorted f lo} -> pivot: a -> hi: FStar.Seq.Base.seq a {FStar.Seq.Properties.sorted f hi} -> FStar.Pervasives.Lemma (requires forall (y: a). (FStar.Seq.Properties.mem y lo ==> f y pivot) /\ (FStar.Seq.Properties.mem y hi ==> f pivot y)) (ensures FStar.Seq.Properties.sorted f (FStar.Seq.Base.append lo (FStar.Seq.Base.cons pivot hi)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.sorted_concat_lemma'" ]
[]
true
false
true
false
false
let sorted_concat_lemma =
sorted_concat_lemma'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_slice_first_in_append
val lemma_slice_first_in_append: #a:Type -> s1:seq a -> s2:seq a -> i:nat{i <= length s1} -> Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2)))
val lemma_slice_first_in_append: #a:Type -> s1:seq a -> s2:seq a -> i:nat{i <= length s1} -> Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2)))
let lemma_slice_first_in_append = lemma_slice_first_in_append'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 72, "start_col": 0, "start_line": 72 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> i: Prims.nat{i <= FStar.Seq.Base.length s1} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (FStar.Seq.Base.slice (FStar.Seq.Base.append s1 s2) i (FStar.Seq.Base.length (FStar.Seq.Base.append s1 s2))) (FStar.Seq.Base.append (FStar.Seq.Base.slice s1 i (FStar.Seq.Base.length s1)) s2))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.lemma_slice_first_in_append'" ]
[]
true
false
true
false
false
let lemma_slice_first_in_append =
lemma_slice_first_in_append'
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_count_aux
val lemma_append_count_aux: #a:eqtype -> x:a -> lo:seq a -> hi:seq a -> Lemma (requires True) (ensures (count x (append lo hi) = (count x lo + count x hi)))
val lemma_append_count_aux: #a:eqtype -> x:a -> lo:seq a -> hi:seq a -> Lemma (requires True) (ensures (count x (append lo hi) = (count x lo + count x hi)))
let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 110, "start_col": 0, "start_line": 110 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> lo: FStar.Seq.Base.seq a -> hi: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Properties.count x (FStar.Seq.Base.append lo hi) = FStar.Seq.Properties.count x lo + FStar.Seq.Properties.count x hi)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "FStar.Seq.Properties.lemma_append_count", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_append_count_aux #_ _ lo hi =
lemma_append_count lo hi
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.upd_slice
val upd_slice: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j /\ j <= length s} -> k:nat{k < j - i} -> v:a -> Lemma (requires i + k < j) (ensures upd (slice s i j) k v == slice (upd s (i + k) v) i j) [SMTPat (upd (slice s i j) k v)]
val upd_slice: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j /\ j <= length s} -> k:nat{k < j - i} -> v:a -> Lemma (requires i + k < j) (ensures upd (slice s i j) k v == slice (upd s (i + k) v) i j) [SMTPat (upd (slice s i j) k v)]
let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 78, "start_col": 0, "start_line": 77 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat -> j: Prims.nat{i <= j /\ j <= FStar.Seq.Base.length s} -> k: Prims.nat{k < j - i} -> v: a -> FStar.Pervasives.Lemma (requires i + k < j) (ensures FStar.Seq.Base.upd (FStar.Seq.Base.slice s i j) k v == FStar.Seq.Base.slice (FStar.Seq.Base.upd s (i + k) v) i j) [SMTPat (FStar.Seq.Base.upd (FStar.Seq.Base.slice s i j) k v)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.op_LessThan", "Prims.op_Subtraction", "FStar.Seq.Base.lemma_eq_intro", "FStar.Seq.Base.upd", "FStar.Seq.Base.slice", "Prims.op_Addition", "Prims.unit" ]
[]
true
false
true
false
false
let upd_slice #_ s i j k v =
lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j)
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.openBase_st
val openBase_st : cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
let openBase_st (cs:S.ciphersuite) (p:Type0) = pkE: key_dh_public cs { S.is_valid_not_export_only_ciphersuite cs } -> skR: key_dh_secret cs -> infolen: size_t {v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> aadlen: size_t {v aadlen <= SAEAD.max_length (S.aead_alg_of cs)} -> aad: lbuffer uint8 aadlen -> ctlen: size_t{16 < v ctlen /\ v ctlen <= SAEAD.max_length (S.aead_alg_of cs) } -> ct:lbuffer uint8 ctlen -> o_pt: lbuffer uint8 (size (v ctlen - 16)) -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pt /\ live h0 skR /\ live h0 pkE /\ live h0 info /\ live h0 aad /\ live h0 ct /\ disjoint o_pt skR /\ disjoint o_pt pkE /\ disjoint o_pt info /\ disjoint o_pt aad /\ disjoint o_pt ct ) (ensures fun h0 result h1 -> modifies (loc o_pt) h0 h1 /\ (let sealed = S.openBase cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) (as_seq h0 aad) (as_seq h0 ct) in match result with | 0ul -> Some? sealed /\ (let pt = Some?.v sealed in as_seq h1 o_pt `Seq.equal` pt) | 1ul -> True | _ -> False) )
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 160, "start_col": 0, "start_line": 133 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs)) inline_for_extraction noextract let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs)) (* Redefining this to work around Low*'s limitation on buffer size *) inline_for_extraction noextract let max_length_info (a:S.hash_algorithm) = max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a val context_s (cs:S.ciphersuite) : Type0 val ctx_loc (#cs:S.ciphersuite) (ctx:context_s cs) : GTot B.loc val ctx_invariant (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot prop val as_ctx (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot (S.encryption_context cs) val frame_ctx (#cs:S.ciphersuite) (ctx:context_s cs) (l:B.loc) (h0 h1:mem) : Lemma (requires ctx_invariant h0 ctx /\ B.loc_disjoint (ctx_loc ctx) l /\ modifies l h0 h1) (ensures ctx_invariant h1 ctx /\ as_ctx h0 ctx == as_ctx h1 ctx) [SMTPat (modifies l h0 h1); SMTPat (ctx_invariant h0 ctx)] inline_for_extraction noextract let setupBaseS_st (cs:S.ciphersuite) (p:Type0) = o_pkE: key_dh_public cs -> o_ctx: context_s cs -> skE: key_dh_secret cs -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pkE /\ ctx_invariant h0 o_ctx /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ disjoint o_pkE skE /\ disjoint o_pkE pkR /\ disjoint o_pkE info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) /\ B.loc_disjoint (loc o_pkE) (ctx_loc o_ctx)) (ensures fun h0 result h1 -> modifies (loc o_pkE |+| ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseS cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let pkE, ctx = Some?.v output in as_seq h1 o_pkE == pkE /\ as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) ) inline_for_extraction noextract let setupBaseR_st (cs:S.ciphersuite) (p:Type0) = o_ctx : context_s cs -> pkE: key_dh_public cs -> skR: key_dh_secret cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ ctx_invariant h0 o_ctx /\ live h0 pkE /\ live h0 skR /\ live h0 info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) ) (ensures fun h0 result h1 -> modifies (ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseR cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let ctx = Some?.v output in as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) ) (* The error code here is not exact w.r.t. the spec. The reason is that, in the spec, the overflow of an internal counter is defined when it runs above 2**96. In the code, this counter is represented as a uint64, so the overflow occurs earlier. Apart from this case, the behaviour of the impl and the spec should be identical *) inline_for_extraction noextract let sealBase_st (cs:S.ciphersuite) (p:Type0) = skE: key_dh_secret cs { S.is_valid_not_export_only_ciphersuite cs } -> pkR: serialized_point_dh cs -> infolen: size_t {v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> aadlen: size_t {v aadlen <= SAEAD.max_length (S.aead_alg_of cs)} -> aad: lbuffer uint8 aadlen -> plainlen: size_t {v plainlen <= SAEAD.max_length (S.aead_alg_of cs) /\ v plainlen + 16 <= max_size_t} -> plain: lbuffer uint8 plainlen -> o_enc: key_dh_public cs -> o_ct: lbuffer uint8 (size (v plainlen + 16)) -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_enc /\ live h0 o_ct /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ live h0 aad /\ live h0 plain /\ disjoint o_enc skE /\ disjoint o_enc pkR /\ disjoint o_enc info /\ disjoint o_enc aad /\ disjoint o_enc plain /\ disjoint o_ct skE /\ disjoint o_ct pkR /\ disjoint o_ct info /\ disjoint o_ct aad /\ disjoint o_ct plain /\ disjoint o_ct o_enc ) (ensures fun h0 result h1 -> modifies (loc o_enc |+| loc o_ct) h0 h1 /\ (let sealed = S.sealBase cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) (as_seq h0 aad) (as_seq h0 plain) in match result with | 0ul -> Some? sealed /\ (let enc, ct = Some?.v sealed in as_seq h1 o_enc `Seq.equal` enc /\ as_seq h1 o_ct `Seq.equal` ct) | 1ul -> True | _ -> False) ) (* Same issue as above for the exactness of the error code *)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Hacl.Impl.HPKE.key_dh_public", "Prims.b2t", "Spec.Agile.HPKE.is_valid_not_export_only_ciphersuite", "Hacl.Impl.HPKE.key_dh_secret", "Lib.IntTypes.size_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.HPKE.max_length_info", "Spec.Agile.HPKE.hash_of_cs", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Agile.AEAD.max_length", "Spec.Agile.HPKE.aead_alg_of", "Prims.l_and", "Prims.op_LessThan", "Lib.IntTypes.size", "Prims.op_Subtraction", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.uu___is_Some", "Spec.Agile.AEAD.decrypted", "Lib.Buffer.as_seq", "FStar.Seq.Base.equal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.l_True", "Prims.l_False", "Prims.logical", "FStar.Pervasives.Native.option", "Spec.Agile.HPKE.openBase", "Spec.Agile.HPKE.size_dh_public", "Spec.Agile.HPKE.size_dh_key" ]
[]
false
false
false
true
true
let openBase_st (cs: S.ciphersuite) (p: Type0) =
pkE: key_dh_public cs {S.is_valid_not_export_only_ciphersuite cs} -> skR: key_dh_secret cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> aadlen: size_t{v aadlen <= SAEAD.max_length (S.aead_alg_of cs)} -> aad: lbuffer uint8 aadlen -> ctlen: size_t{16 < v ctlen /\ v ctlen <= SAEAD.max_length (S.aead_alg_of cs)} -> ct: lbuffer uint8 ctlen -> o_pt: lbuffer uint8 (size (v ctlen - 16)) -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pt /\ live h0 skR /\ live h0 pkE /\ live h0 info /\ live h0 aad /\ live h0 ct /\ disjoint o_pt skR /\ disjoint o_pt pkE /\ disjoint o_pt info /\ disjoint o_pt aad /\ disjoint o_pt ct) (ensures fun h0 result h1 -> modifies (loc o_pt) h0 h1 /\ (let sealed = S.openBase cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) (as_seq h0 aad) (as_seq h0 ct) in match result with | 0ul -> Some? sealed /\ (let pt = Some?.v sealed in (as_seq h1 o_pt) `Seq.equal` pt) | 1ul -> True | _ -> False))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.mem_index'
val mem_index' (#a: eqtype) (x: a) (s: seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s))
val mem_index' (#a: eqtype) (x: a) (s: seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s))
let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 58, "start_col": 0, "start_line": 52 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires FStar.Seq.Properties.mem x s) (ensures exists (i: Prims.nat{i < FStar.Seq.Base.length s}). FStar.Seq.Base.index s i == x) (decreases FStar.Seq.Base.length s)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.bool", "FStar.Seq.Properties.head", "FStar.Seq.Properties.mem_index'", "FStar.Seq.Properties.tail", "Prims.unit", "Prims.b2t", "FStar.Seq.Properties.mem", "Prims.squash", "Prims.l_Exists", "Prims.nat", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec mem_index' (#a: eqtype) (x: a) (s: seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) =
if length s = 0 then () else if head s = x then () else mem_index' x (tail s)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.perm_len
val perm_len (#a:eqtype) (s1 s2: seq a) : Lemma (requires (permutation a s1 s2)) (ensures (length s1 == length s2))
val perm_len (#a:eqtype) (s1 s2: seq a) : Lemma (requires (permutation a s1 s2)) (ensures (length s1 == length s2))
let perm_len = perm_len'
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 238, "start_col": 0, "start_line": 238 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi))) let sorted_concat_lemma = sorted_concat_lemma' let split_5 #a s i j = let frag_lo = slice s 0 i in let frag_i = slice s i (i + 1) in let frag_mid = slice s (i + 1) j in let frag_j = slice s j (j + 1) in let frag_hi = slice s (j + 1) (length s) in upd (upd (upd (upd (create 5 frag_lo) 1 frag_i) 2 frag_mid) 3 frag_j) 4 frag_hi let lemma_swap_permutes_aux_frag_eq #a s i j i' j' = cut (equal (slice s i' j') (slice (swap s i j) i' j')); cut (equal (slice s i (i + 1)) (slice (swap s i j) j (j + 1))); cut (equal (slice s j (j + 1)) (slice (swap s i j) i (i + 1))) #push-options "--z3rlimit 20" let lemma_swap_permutes_aux #_ s i j x = if j=i then cut (equal (swap s i j) s) else begin let s5 = split_5 s i j in let frag_lo, frag_i, frag_mid, frag_j, frag_hi = index s5 0, index s5 1, index s5 2, index s5 3, index s5 4 in lemma_append_count_aux x frag_lo (append frag_i (append frag_mid (append frag_j frag_hi))); lemma_append_count_aux x frag_i (append frag_mid (append frag_j frag_hi)); lemma_append_count_aux x frag_mid (append frag_j frag_hi); lemma_append_count_aux x frag_j frag_hi; let s' = swap s i j in let s5' = split_5 s' i j in let frag_lo', frag_j', frag_mid', frag_i', frag_hi' = index s5' 0, index s5' 1, index s5' 2, index s5' 3, index s5' 4 in lemma_swap_permutes_aux_frag_eq s i j 0 i; lemma_swap_permutes_aux_frag_eq s i j (i + 1) j; lemma_swap_permutes_aux_frag_eq s i j (j + 1) (length s); lemma_append_count_aux x frag_lo (append frag_j (append frag_mid (append frag_i frag_hi))); lemma_append_count_aux x frag_j (append frag_mid (append frag_i frag_hi)); lemma_append_count_aux x frag_mid (append frag_i frag_hi); lemma_append_count_aux x frag_i frag_hi end #pop-options let append_permutations #a s1 s2 s1' s2' = ( lemma_append_count s1 s2; lemma_append_count s1' s2' ) let lemma_swap_permutes #a s i j = FStar.Classical.forall_intro #a #(fun x -> count x s = count x (swap s i j)) (lemma_swap_permutes_aux s i j) (* perm_len: A lemma that shows that two sequences that are permutations of each other also have the same length *) //a proof optimization: Z3 only needs to unfold the recursive definition of `count` once #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let rec perm_len' (#a:eqtype) (s1 s2: seq a) : Lemma (requires (permutation a s1 s2)) (ensures (length s1 == length s2)) (decreases (length s1)) = if length s1 = 0 then begin if length s2 = 0 then () else assert (count (index s2 0) s2 > 0) end else let s1_hd = head s1 in let s1_tl = tail s1 in assert (count s1_hd s1 > 0); assert (count s1_hd s2 > 0); assert (length s2 > 0); let s2_hd = head s2 in let s2_tl = tail s2 in if s1_hd = s2_hd then (assert (permutation a s1_tl s2_tl); perm_len' s1_tl s2_tl) else let i = index_mem s1_hd s2 in let s_pfx, s_sfx = split_eq s2 i in assert (equal s_sfx (append (create 1 s1_hd) (tail s_sfx))); let s2' = append s_pfx (tail s_sfx) in lemma_append_count s_pfx s_sfx; lemma_append_count (create 1 s1_hd) (tail s_sfx); lemma_append_count s_pfx (tail s_sfx); assert (permutation a s1_tl s2'); perm_len' s1_tl s2' #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires FStar.Seq.Properties.permutation a s1 s2) (ensures FStar.Seq.Base.length s1 == FStar.Seq.Base.length s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Properties.perm_len'" ]
[]
true
false
true
false
false
let perm_len =
perm_len'
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.setupBaseS_st
val setupBaseS_st : cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
let setupBaseS_st (cs:S.ciphersuite) (p:Type0) = o_pkE: key_dh_public cs -> o_ctx: context_s cs -> skE: key_dh_secret cs -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pkE /\ ctx_invariant h0 o_ctx /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ disjoint o_pkE skE /\ disjoint o_pkE pkR /\ disjoint o_pkE info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) /\ B.loc_disjoint (loc o_pkE) (ctx_loc o_ctx)) (ensures fun h0 result h1 -> modifies (loc o_pkE |+| ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseS cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let pkE, ctx = Some?.v output in as_seq h1 o_pkE == pkE /\ as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) )
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 67, "start_col": 0, "start_line": 42 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs)) inline_for_extraction noextract let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs)) (* Redefining this to work around Low*'s limitation on buffer size *) inline_for_extraction noextract let max_length_info (a:S.hash_algorithm) = max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a val context_s (cs:S.ciphersuite) : Type0 val ctx_loc (#cs:S.ciphersuite) (ctx:context_s cs) : GTot B.loc val ctx_invariant (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot prop val as_ctx (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot (S.encryption_context cs) val frame_ctx (#cs:S.ciphersuite) (ctx:context_s cs) (l:B.loc) (h0 h1:mem) : Lemma (requires ctx_invariant h0 ctx /\ B.loc_disjoint (ctx_loc ctx) l /\ modifies l h0 h1) (ensures ctx_invariant h1 ctx /\ as_ctx h0 ctx == as_ctx h1 ctx) [SMTPat (modifies l h0 h1); SMTPat (ctx_invariant h0 ctx)]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Hacl.Impl.HPKE.key_dh_public", "Hacl.Impl.HPKE.context_s", "Hacl.Impl.HPKE.key_dh_secret", "Hacl.Impl.HPKE.serialized_point_dh", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.HPKE.max_length_info", "Spec.Agile.HPKE.hash_of_cs", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.HPKE.ctx_invariant", "Lib.Buffer.disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Impl.HPKE.ctx_loc", "Lib.Buffer.loc", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "Spec.Agile.HPKE.key_dh_public_s", "Spec.Agile.HPKE.encryption_context", "Prims.eq2", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_dh_public", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "Hacl.Impl.HPKE.as_ctx", "Prims.logical", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Pervasives.Native.uu___is_None", "Prims.l_False", "FStar.Pervasives.Native.option", "Spec.Agile.HPKE.setupBaseS", "Spec.Agile.HPKE.size_dh_key", "Spec.Agile.HPKE.size_dh_serialized" ]
[]
false
false
false
true
true
let setupBaseS_st (cs: S.ciphersuite) (p: Type0) =
o_pkE: key_dh_public cs -> o_ctx: context_s cs -> skE: key_dh_secret cs -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pkE /\ ctx_invariant h0 o_ctx /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ disjoint o_pkE skE /\ disjoint o_pkE pkR /\ disjoint o_pkE info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) /\ B.loc_disjoint (loc o_pkE) (ctx_loc o_ctx)) (ensures fun h0 result h1 -> modifies (loc o_pkE |+| ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseS cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let pkE, ctx = Some?.v output in as_seq h1 o_pkE == pkE /\ as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_count_slice
val lemma_count_slice: #a:eqtype -> s:seq a -> i:nat{i<=length s} -> Lemma (requires True) (ensures (forall x. count x s = count x (slice s 0 i) + count x (slice s i (length s))))
val lemma_count_slice: #a:eqtype -> s:seq a -> i:nat{i<=length s} -> Lemma (requires True) (ensures (forall x. count x s = count x (slice s 0 i) + count x (slice s i (length s))))
let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 129, "start_col": 0, "start_line": 127 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat{i <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.Seq.Properties.count x s = FStar.Seq.Properties.count x (FStar.Seq.Base.slice s 0 i) + FStar.Seq.Properties.count x (FStar.Seq.Base.slice s i (FStar.Seq.Base.length s)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Properties.lemma_append_count", "FStar.Seq.Base.slice", "Prims.unit", "Prims.cut", "FStar.Seq.Base.equal", "FStar.Seq.Base.append" ]
[]
true
false
true
false
false
let lemma_count_slice #_ s i =
cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.append_permutations
val append_permutations: #a:eqtype -> s1:seq a -> s2:seq a -> s1':seq a -> s2':seq a -> Lemma (requires permutation a s1 s1' /\ permutation a s2 s2') (ensures permutation a (append s1 s2) (append s1' s2'))
val append_permutations: #a:eqtype -> s1:seq a -> s2:seq a -> s1':seq a -> s2':seq a -> Lemma (requires permutation a s1 s1' /\ permutation a s2 s2') (ensures permutation a (append s1 s2) (append s1' s2'))
let append_permutations #a s1 s2 s1' s2' = ( lemma_append_count s1 s2; lemma_append_count s1' s2' )
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 196, "start_col": 0, "start_line": 192 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi))) let sorted_concat_lemma = sorted_concat_lemma' let split_5 #a s i j = let frag_lo = slice s 0 i in let frag_i = slice s i (i + 1) in let frag_mid = slice s (i + 1) j in let frag_j = slice s j (j + 1) in let frag_hi = slice s (j + 1) (length s) in upd (upd (upd (upd (create 5 frag_lo) 1 frag_i) 2 frag_mid) 3 frag_j) 4 frag_hi let lemma_swap_permutes_aux_frag_eq #a s i j i' j' = cut (equal (slice s i' j') (slice (swap s i j) i' j')); cut (equal (slice s i (i + 1)) (slice (swap s i j) j (j + 1))); cut (equal (slice s j (j + 1)) (slice (swap s i j) i (i + 1))) #push-options "--z3rlimit 20" let lemma_swap_permutes_aux #_ s i j x = if j=i then cut (equal (swap s i j) s) else begin let s5 = split_5 s i j in let frag_lo, frag_i, frag_mid, frag_j, frag_hi = index s5 0, index s5 1, index s5 2, index s5 3, index s5 4 in lemma_append_count_aux x frag_lo (append frag_i (append frag_mid (append frag_j frag_hi))); lemma_append_count_aux x frag_i (append frag_mid (append frag_j frag_hi)); lemma_append_count_aux x frag_mid (append frag_j frag_hi); lemma_append_count_aux x frag_j frag_hi; let s' = swap s i j in let s5' = split_5 s' i j in let frag_lo', frag_j', frag_mid', frag_i', frag_hi' = index s5' 0, index s5' 1, index s5' 2, index s5' 3, index s5' 4 in lemma_swap_permutes_aux_frag_eq s i j 0 i; lemma_swap_permutes_aux_frag_eq s i j (i + 1) j; lemma_swap_permutes_aux_frag_eq s i j (j + 1) (length s); lemma_append_count_aux x frag_lo (append frag_j (append frag_mid (append frag_i frag_hi))); lemma_append_count_aux x frag_j (append frag_mid (append frag_i frag_hi)); lemma_append_count_aux x frag_mid (append frag_i frag_hi); lemma_append_count_aux x frag_i frag_hi end #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> s1': FStar.Seq.Base.seq a -> s2': FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires FStar.Seq.Properties.permutation a s1 s1' /\ FStar.Seq.Properties.permutation a s2 s2') (ensures FStar.Seq.Properties.permutation a (FStar.Seq.Base.append s1 s2) (FStar.Seq.Base.append s1' s2'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "FStar.Seq.Properties.lemma_append_count", "Prims.unit" ]
[]
true
false
true
false
false
let append_permutations #a s1 s2 s1' s2' =
(lemma_append_count s1 s2; lemma_append_count s1' s2')
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_mem_count'
val lemma_mem_count' (#a: eqtype) (s: seq a) (f: (a -> Tot bool)) : Lemma (requires (forall (i: nat{i < length s}). f (index s i))) (ensures (forall (x: a). mem x s ==> f x)) (decreases (length s))
val lemma_mem_count' (#a: eqtype) (s: seq a) (f: (a -> Tot bool)) : Lemma (requires (forall (i: nat{i < length s}). f (index s i))) (ensures (forall (x: a). mem x s ==> f x)) (decreases (length s))
let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 123, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> f: (_: a -> Prims.bool) -> FStar.Pervasives.Lemma (requires forall (i: Prims.nat{i < FStar.Seq.Base.length s}). f (FStar.Seq.Base.index s i)) (ensures forall (x: a). FStar.Seq.Properties.mem x s ==> f x) (decreases FStar.Seq.Base.length s)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.bool", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "FStar.Seq.Properties.lemma_mem_count'", "FStar.Seq.Properties.tail", "Prims.unit", "Prims.cut", "Prims.l_Forall", "Prims.b2t", "FStar.Seq.Base.index", "Prims.op_Addition", "Prims.nat", "Prims.op_LessThan", "Prims.squash", "Prims.l_imp", "FStar.Seq.Properties.mem", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_mem_count' (#a: eqtype) (s: seq a) (f: (a -> Tot bool)) : Lemma (requires (forall (i: nat{i < length s}). f (index s i))) (ensures (forall (x: a). mem x s ==> f x)) (decreases (length s)) =
if length s = 0 then () else (let t = i: nat{i < length (tail s)} in cut (forall (i: t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f)
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_swap_permutes
val lemma_swap_permutes (#a:eqtype) (s:seq a) (i:nat{i<length s}) (j:nat{i <= j && j<length s}) : Lemma (permutation a s (swap s i j))
val lemma_swap_permutes (#a:eqtype) (s:seq a) (i:nat{i<length s}) (j:nat{i <= j && j<length s}) : Lemma (permutation a s (swap s i j))
let lemma_swap_permutes #a s i j = FStar.Classical.forall_intro #a #(fun x -> count x s = count x (swap s i j)) (lemma_swap_permutes_aux s i j)
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 202, "start_col": 0, "start_line": 198 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi))) let sorted_concat_lemma = sorted_concat_lemma' let split_5 #a s i j = let frag_lo = slice s 0 i in let frag_i = slice s i (i + 1) in let frag_mid = slice s (i + 1) j in let frag_j = slice s j (j + 1) in let frag_hi = slice s (j + 1) (length s) in upd (upd (upd (upd (create 5 frag_lo) 1 frag_i) 2 frag_mid) 3 frag_j) 4 frag_hi let lemma_swap_permutes_aux_frag_eq #a s i j i' j' = cut (equal (slice s i' j') (slice (swap s i j) i' j')); cut (equal (slice s i (i + 1)) (slice (swap s i j) j (j + 1))); cut (equal (slice s j (j + 1)) (slice (swap s i j) i (i + 1))) #push-options "--z3rlimit 20" let lemma_swap_permutes_aux #_ s i j x = if j=i then cut (equal (swap s i j) s) else begin let s5 = split_5 s i j in let frag_lo, frag_i, frag_mid, frag_j, frag_hi = index s5 0, index s5 1, index s5 2, index s5 3, index s5 4 in lemma_append_count_aux x frag_lo (append frag_i (append frag_mid (append frag_j frag_hi))); lemma_append_count_aux x frag_i (append frag_mid (append frag_j frag_hi)); lemma_append_count_aux x frag_mid (append frag_j frag_hi); lemma_append_count_aux x frag_j frag_hi; let s' = swap s i j in let s5' = split_5 s' i j in let frag_lo', frag_j', frag_mid', frag_i', frag_hi' = index s5' 0, index s5' 1, index s5' 2, index s5' 3, index s5' 4 in lemma_swap_permutes_aux_frag_eq s i j 0 i; lemma_swap_permutes_aux_frag_eq s i j (i + 1) j; lemma_swap_permutes_aux_frag_eq s i j (j + 1) (length s); lemma_append_count_aux x frag_lo (append frag_j (append frag_mid (append frag_i frag_hi))); lemma_append_count_aux x frag_j (append frag_mid (append frag_i frag_hi)); lemma_append_count_aux x frag_mid (append frag_i frag_hi); lemma_append_count_aux x frag_i frag_hi end #pop-options let append_permutations #a s1 s2 s1' s2' = ( lemma_append_count s1 s2; lemma_append_count s1' s2' )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat{i < FStar.Seq.Base.length s} -> j: Prims.nat{i <= j && j < FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Properties.permutation a s (FStar.Seq.Properties.swap s i j))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "FStar.Classical.forall_intro", "Prims.op_Equality", "FStar.Seq.Properties.count", "FStar.Seq.Properties.swap", "FStar.Seq.Properties.lemma_swap_permutes_aux", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_swap_permutes #a s i j =
FStar.Classical.forall_intro #a #(fun x -> count x s = count x (swap s i j)) (lemma_swap_permutes_aux s i j)
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.sealBase_st
val sealBase_st : cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
let sealBase_st (cs:S.ciphersuite) (p:Type0) = skE: key_dh_secret cs { S.is_valid_not_export_only_ciphersuite cs } -> pkR: serialized_point_dh cs -> infolen: size_t {v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> aadlen: size_t {v aadlen <= SAEAD.max_length (S.aead_alg_of cs)} -> aad: lbuffer uint8 aadlen -> plainlen: size_t {v plainlen <= SAEAD.max_length (S.aead_alg_of cs) /\ v plainlen + 16 <= max_size_t} -> plain: lbuffer uint8 plainlen -> o_enc: key_dh_public cs -> o_ct: lbuffer uint8 (size (v plainlen + 16)) -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_enc /\ live h0 o_ct /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ live h0 aad /\ live h0 plain /\ disjoint o_enc skE /\ disjoint o_enc pkR /\ disjoint o_enc info /\ disjoint o_enc aad /\ disjoint o_enc plain /\ disjoint o_ct skE /\ disjoint o_ct pkR /\ disjoint o_ct info /\ disjoint o_ct aad /\ disjoint o_ct plain /\ disjoint o_ct o_enc ) (ensures fun h0 result h1 -> modifies (loc o_enc |+| loc o_ct) h0 h1 /\ (let sealed = S.sealBase cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) (as_seq h0 aad) (as_seq h0 plain) in match result with | 0ul -> Some? sealed /\ (let enc, ct = Some?.v sealed in as_seq h1 o_enc `Seq.equal` enc /\ as_seq h1 o_ct `Seq.equal` ct) | 1ul -> True | _ -> False) )
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 129, "start_col": 0, "start_line": 99 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs)) inline_for_extraction noextract let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs)) (* Redefining this to work around Low*'s limitation on buffer size *) inline_for_extraction noextract let max_length_info (a:S.hash_algorithm) = max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a val context_s (cs:S.ciphersuite) : Type0 val ctx_loc (#cs:S.ciphersuite) (ctx:context_s cs) : GTot B.loc val ctx_invariant (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot prop val as_ctx (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot (S.encryption_context cs) val frame_ctx (#cs:S.ciphersuite) (ctx:context_s cs) (l:B.loc) (h0 h1:mem) : Lemma (requires ctx_invariant h0 ctx /\ B.loc_disjoint (ctx_loc ctx) l /\ modifies l h0 h1) (ensures ctx_invariant h1 ctx /\ as_ctx h0 ctx == as_ctx h1 ctx) [SMTPat (modifies l h0 h1); SMTPat (ctx_invariant h0 ctx)] inline_for_extraction noextract let setupBaseS_st (cs:S.ciphersuite) (p:Type0) = o_pkE: key_dh_public cs -> o_ctx: context_s cs -> skE: key_dh_secret cs -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pkE /\ ctx_invariant h0 o_ctx /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ disjoint o_pkE skE /\ disjoint o_pkE pkR /\ disjoint o_pkE info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) /\ B.loc_disjoint (loc o_pkE) (ctx_loc o_ctx)) (ensures fun h0 result h1 -> modifies (loc o_pkE |+| ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseS cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let pkE, ctx = Some?.v output in as_seq h1 o_pkE == pkE /\ as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) ) inline_for_extraction noextract let setupBaseR_st (cs:S.ciphersuite) (p:Type0) = o_ctx : context_s cs -> pkE: key_dh_public cs -> skR: key_dh_secret cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ ctx_invariant h0 o_ctx /\ live h0 pkE /\ live h0 skR /\ live h0 info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) ) (ensures fun h0 result h1 -> modifies (ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseR cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let ctx = Some?.v output in as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) ) (* The error code here is not exact w.r.t. the spec. The reason is that, in the spec, the overflow of an internal counter is defined when it runs above 2**96. In the code, this counter is represented as a uint64, so the overflow occurs earlier. Apart from this case, the behaviour of the impl and the spec should be identical *)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Hacl.Impl.HPKE.key_dh_secret", "Prims.b2t", "Spec.Agile.HPKE.is_valid_not_export_only_ciphersuite", "Hacl.Impl.HPKE.serialized_point_dh", "Lib.IntTypes.size_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.HPKE.max_length_info", "Spec.Agile.HPKE.hash_of_cs", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Agile.AEAD.max_length", "Spec.Agile.HPKE.aead_alg_of", "Prims.l_and", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Impl.HPKE.key_dh_public", "Lib.IntTypes.size", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "Spec.Agile.HPKE.key_dh_public_s", "Spec.Agile.AEAD.encrypted", "Lib.Buffer.as_seq", "FStar.Seq.Base.equal", "Spec.Agile.HPKE.size_dh_public", "Prims.logical", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.l_True", "Prims.l_False", "FStar.Pervasives.Native.option", "Spec.Agile.HPKE.sealBase", "Spec.Agile.HPKE.size_dh_key", "Spec.Agile.HPKE.size_dh_serialized" ]
[]
false
false
false
true
true
let sealBase_st (cs: S.ciphersuite) (p: Type0) =
skE: key_dh_secret cs {S.is_valid_not_export_only_ciphersuite cs} -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> aadlen: size_t{v aadlen <= SAEAD.max_length (S.aead_alg_of cs)} -> aad: lbuffer uint8 aadlen -> plainlen: size_t{v plainlen <= SAEAD.max_length (S.aead_alg_of cs) /\ v plainlen + 16 <= max_size_t} -> plain: lbuffer uint8 plainlen -> o_enc: key_dh_public cs -> o_ct: lbuffer uint8 (size (v plainlen + 16)) -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_enc /\ live h0 o_ct /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ live h0 aad /\ live h0 plain /\ disjoint o_enc skE /\ disjoint o_enc pkR /\ disjoint o_enc info /\ disjoint o_enc aad /\ disjoint o_enc plain /\ disjoint o_ct skE /\ disjoint o_ct pkR /\ disjoint o_ct info /\ disjoint o_ct aad /\ disjoint o_ct plain /\ disjoint o_ct o_enc) (ensures fun h0 result h1 -> modifies (loc o_enc |+| loc o_ct) h0 h1 /\ (let sealed = S.sealBase cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) (as_seq h0 aad) (as_seq h0 plain) in match result with | 0ul -> Some? sealed /\ (let enc, ct = Some?.v sealed in (as_seq h1 o_enc) `Seq.equal` enc /\ (as_seq h1 o_ct) `Seq.equal` ct) | 1ul -> True | _ -> False))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_append_count'
val lemma_append_count' (#a: eqtype) (lo hi: seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo))
val lemma_append_count' (#a: eqtype) (lo hi: seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo))
let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 106, "start_col": 0, "start_line": 94 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lo: FStar.Seq.Base.seq a -> hi: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.Seq.Properties.count x (FStar.Seq.Base.append lo hi) = FStar.Seq.Properties.count x lo + FStar.Seq.Properties.count x hi) (decreases FStar.Seq.Base.length lo)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.cut", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "Prims.bool", "FStar.Seq.Properties.tail", "FStar.Seq.Base.cons", "FStar.Seq.Properties.head", "Prims.unit", "FStar.Seq.Properties.lemma_append_count'", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.b2t", "FStar.Seq.Properties.count", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_append_count' (#a: eqtype) (lo hi: seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) =
if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h))
false
Hacl.Impl.HPKE.fsti
Hacl.Impl.HPKE.setupBaseR_st
val setupBaseR_st : cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
let setupBaseR_st (cs:S.ciphersuite) (p:Type0) = o_ctx : context_s cs -> pkE: key_dh_public cs -> skR: key_dh_secret cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ ctx_invariant h0 o_ctx /\ live h0 pkE /\ live h0 skR /\ live h0 info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) ) (ensures fun h0 result h1 -> modifies (ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseR cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let ctx = Some?.v output in as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) )
{ "file_name": "code/hpke/Hacl.Impl.HPKE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 91, "start_col": 0, "start_line": 70 }
module Hacl.Impl.HPKE open FStar.HyperStack open FStar.HyperStack.All module B = LowStar.Buffer open Lib.Buffer open Lib.IntTypes module S = Spec.Agile.HPKE module SAEAD = Spec.Agile.AEAD #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let key_dh_public (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_public cs)) inline_for_extraction noextract let key_dh_secret (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_key cs)) inline_for_extraction noextract let serialized_point_dh (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_dh_serialized cs)) inline_for_extraction noextract let key_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_key cs)) inline_for_extraction noextract let nonce_aead (cs:S.ciphersuite) = lbuffer uint8 (size (S.size_aead_nonce cs)) (* Redefining this to work around Low*'s limitation on buffer size *) inline_for_extraction noextract let max_length_info (a:S.hash_algorithm) = max_size_t - S.size_label_version - S.size_suite_id_hpke - S.size_label_info_hash - Spec.Hash.Definitions.block_length a val context_s (cs:S.ciphersuite) : Type0 val ctx_loc (#cs:S.ciphersuite) (ctx:context_s cs) : GTot B.loc val ctx_invariant (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot prop val as_ctx (#cs:S.ciphersuite) (h:mem) (ctx:context_s cs) : GTot (S.encryption_context cs) val frame_ctx (#cs:S.ciphersuite) (ctx:context_s cs) (l:B.loc) (h0 h1:mem) : Lemma (requires ctx_invariant h0 ctx /\ B.loc_disjoint (ctx_loc ctx) l /\ modifies l h0 h1) (ensures ctx_invariant h1 ctx /\ as_ctx h0 ctx == as_ctx h1 ctx) [SMTPat (modifies l h0 h1); SMTPat (ctx_invariant h0 ctx)] inline_for_extraction noextract let setupBaseS_st (cs:S.ciphersuite) (p:Type0) = o_pkE: key_dh_public cs -> o_ctx: context_s cs -> skE: key_dh_secret cs -> pkR: serialized_point_dh cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ live h0 o_pkE /\ ctx_invariant h0 o_ctx /\ live h0 skE /\ live h0 pkR /\ live h0 info /\ disjoint o_pkE skE /\ disjoint o_pkE pkR /\ disjoint o_pkE info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info) /\ B.loc_disjoint (loc o_pkE) (ctx_loc o_ctx)) (ensures fun h0 result h1 -> modifies (loc o_pkE |+| ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseS cs (as_seq h0 skE) (as_seq h0 pkR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let pkE, ctx = Some?.v output in as_seq h1 o_pkE == pkE /\ as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False ) )
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.HPKE.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "SAEAD" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Spec.Agile.HPKE.ciphersuite -> p: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Agile.HPKE.ciphersuite", "Hacl.Impl.HPKE.context_s", "Hacl.Impl.HPKE.key_dh_public", "Hacl.Impl.HPKE.key_dh_secret", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.HPKE.max_length_info", "Spec.Agile.HPKE.hash_of_cs", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Hacl.Impl.HPKE.ctx_invariant", "Lib.Buffer.live", "Lib.Buffer.MUT", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Impl.HPKE.ctx_loc", "Lib.Buffer.loc", "Lib.Buffer.modifies", "FStar.Pervasives.Native.uu___is_Some", "Spec.Agile.HPKE.encryption_context", "Prims.eq2", "Hacl.Impl.HPKE.as_ctx", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Pervasives.Native.uu___is_None", "Prims.l_False", "Prims.logical", "FStar.Pervasives.Native.option", "Spec.Agile.HPKE.setupBaseR", "Lib.Buffer.as_seq", "Lib.IntTypes.size", "Spec.Agile.HPKE.size_dh_public", "Spec.Agile.HPKE.size_dh_key" ]
[]
false
false
false
true
true
let setupBaseR_st (cs: S.ciphersuite) (p: Type0) =
o_ctx: context_s cs -> pkE: key_dh_public cs -> skR: key_dh_secret cs -> infolen: size_t{v infolen <= max_length_info (S.hash_of_cs cs)} -> info: lbuffer uint8 infolen -> Stack UInt32.t (requires fun h0 -> p /\ ctx_invariant h0 o_ctx /\ live h0 pkE /\ live h0 skR /\ live h0 info /\ B.loc_disjoint (ctx_loc o_ctx) (loc info)) (ensures fun h0 result h1 -> modifies (ctx_loc o_ctx) h0 h1 /\ (let output = S.setupBaseR cs (as_seq h0 pkE) (as_seq h0 skR) (as_seq h0 info) in match result with | 0ul -> Some? output /\ (let ctx = Some?.v output in as_ctx h1 o_ctx == ctx) | 1ul -> None? output | _ -> False))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.lemma_mem_append
val lemma_mem_append : #a:eqtype -> s1:seq a -> s2:seq a -> Lemma (ensures (forall x. mem x (append s1 s2) <==> (mem x s1 || mem x s2)))
val lemma_mem_append : #a:eqtype -> s1:seq a -> s2:seq a -> Lemma (ensures (forall x. mem x (append s1 s2) <==> (mem x s1 || mem x s2)))
let lemma_mem_append #_ s1 s2 = lemma_append_count s1 s2
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 242, "start_col": 0, "start_line": 242 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi))) let sorted_concat_lemma = sorted_concat_lemma' let split_5 #a s i j = let frag_lo = slice s 0 i in let frag_i = slice s i (i + 1) in let frag_mid = slice s (i + 1) j in let frag_j = slice s j (j + 1) in let frag_hi = slice s (j + 1) (length s) in upd (upd (upd (upd (create 5 frag_lo) 1 frag_i) 2 frag_mid) 3 frag_j) 4 frag_hi let lemma_swap_permutes_aux_frag_eq #a s i j i' j' = cut (equal (slice s i' j') (slice (swap s i j) i' j')); cut (equal (slice s i (i + 1)) (slice (swap s i j) j (j + 1))); cut (equal (slice s j (j + 1)) (slice (swap s i j) i (i + 1))) #push-options "--z3rlimit 20" let lemma_swap_permutes_aux #_ s i j x = if j=i then cut (equal (swap s i j) s) else begin let s5 = split_5 s i j in let frag_lo, frag_i, frag_mid, frag_j, frag_hi = index s5 0, index s5 1, index s5 2, index s5 3, index s5 4 in lemma_append_count_aux x frag_lo (append frag_i (append frag_mid (append frag_j frag_hi))); lemma_append_count_aux x frag_i (append frag_mid (append frag_j frag_hi)); lemma_append_count_aux x frag_mid (append frag_j frag_hi); lemma_append_count_aux x frag_j frag_hi; let s' = swap s i j in let s5' = split_5 s' i j in let frag_lo', frag_j', frag_mid', frag_i', frag_hi' = index s5' 0, index s5' 1, index s5' 2, index s5' 3, index s5' 4 in lemma_swap_permutes_aux_frag_eq s i j 0 i; lemma_swap_permutes_aux_frag_eq s i j (i + 1) j; lemma_swap_permutes_aux_frag_eq s i j (j + 1) (length s); lemma_append_count_aux x frag_lo (append frag_j (append frag_mid (append frag_i frag_hi))); lemma_append_count_aux x frag_j (append frag_mid (append frag_i frag_hi)); lemma_append_count_aux x frag_mid (append frag_i frag_hi); lemma_append_count_aux x frag_i frag_hi end #pop-options let append_permutations #a s1 s2 s1' s2' = ( lemma_append_count s1 s2; lemma_append_count s1' s2' ) let lemma_swap_permutes #a s i j = FStar.Classical.forall_intro #a #(fun x -> count x s = count x (swap s i j)) (lemma_swap_permutes_aux s i j) (* perm_len: A lemma that shows that two sequences that are permutations of each other also have the same length *) //a proof optimization: Z3 only needs to unfold the recursive definition of `count` once #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let rec perm_len' (#a:eqtype) (s1 s2: seq a) : Lemma (requires (permutation a s1 s2)) (ensures (length s1 == length s2)) (decreases (length s1)) = if length s1 = 0 then begin if length s2 = 0 then () else assert (count (index s2 0) s2 > 0) end else let s1_hd = head s1 in let s1_tl = tail s1 in assert (count s1_hd s1 > 0); assert (count s1_hd s2 > 0); assert (length s2 > 0); let s2_hd = head s2 in let s2_tl = tail s2 in if s1_hd = s2_hd then (assert (permutation a s1_tl s2_tl); perm_len' s1_tl s2_tl) else let i = index_mem s1_hd s2 in let s_pfx, s_sfx = split_eq s2 i in assert (equal s_sfx (append (create 1 s1_hd) (tail s_sfx))); let s2' = append s_pfx (tail s_sfx) in lemma_append_count s_pfx s_sfx; lemma_append_count (create 1 s1_hd) (tail s_sfx); lemma_append_count s_pfx (tail s_sfx); assert (permutation a s1_tl s2'); perm_len' s1_tl s2' #pop-options let perm_len = perm_len' let cons_perm #_ tl s = lemma_tl (head s) tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.Seq.Properties.mem x (FStar.Seq.Base.append s1 s2) <==> FStar.Seq.Properties.mem x s1 || FStar.Seq.Properties.mem x s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "FStar.Seq.Properties.lemma_append_count", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_mem_append #_ s1 s2 =
lemma_append_count s1 s2
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.sorted_concat_lemma'
val sorted_concat_lemma' (#a: eqtype) (f: (a -> a -> Tot bool){total_order a f}) (lo: seq a {sorted f lo}) (pivot: a) (hi: seq a {sorted f hi}) : Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo))
val sorted_concat_lemma' (#a: eqtype) (f: (a -> a -> Tot bool){total_order a f}) (lo: seq a {sorted f lo}) (pivot: a) (hi: seq a {sorted f hi}) : Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo))
let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi)))
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 146, "start_col": 0, "start_line": 131 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> _: a -> Prims.bool){FStar.Seq.Properties.total_order a f} -> lo: FStar.Seq.Base.seq a {FStar.Seq.Properties.sorted f lo} -> pivot: a -> hi: FStar.Seq.Base.seq a {FStar.Seq.Properties.sorted f hi} -> FStar.Pervasives.Lemma (requires forall (y: a). (FStar.Seq.Properties.mem y lo ==> f y pivot) /\ (FStar.Seq.Properties.mem y hi ==> f pivot y)) (ensures FStar.Seq.Properties.sorted f (FStar.Seq.Base.append lo (FStar.Seq.Base.cons pivot hi))) (decreases FStar.Seq.Base.length lo)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.eqtype", "Prims.bool", "FStar.Seq.Properties.total_order", "FStar.Seq.Base.seq", "Prims.b2t", "FStar.Seq.Properties.sorted", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.cut", "FStar.Seq.Base.equal", "FStar.Seq.Properties.tail", "FStar.Seq.Base.cons", "Prims.unit", "FStar.Seq.Base.append", "FStar.Seq.Properties.lemma_tl", "FStar.Seq.Properties.head", "FStar.Seq.Properties.lemma_append_cons", "FStar.Seq.Properties.sorted_concat_lemma'" ]
[ "recursion" ]
false
false
true
false
false
let rec sorted_concat_lemma': #a: eqtype -> f: (a -> a -> Tot bool){total_order a f} -> lo: seq a {sorted f lo} -> pivot: a -> hi: seq a {sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) =
fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi)))
false
FStar.Seq.Properties.fst
FStar.Seq.Properties.cons_perm
val cons_perm: #a:eqtype -> tl:seq a -> s:seq a{length s > 0} -> Lemma (requires (permutation a tl (tail s))) (ensures (permutation a (cons (head s) tl) s))
val cons_perm: #a:eqtype -> tl:seq a -> s:seq a{length s > 0} -> Lemma (requires (permutation a tl (tail s))) (ensures (permutation a (cons (head s) tl) s))
let cons_perm #_ tl s = lemma_tl (head s) tl
{ "file_name": "ulib/FStar.Seq.Properties.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 240, "start_col": 0, "start_line": 240 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Seq.Properties open FStar.Seq.Base module Seq = FStar.Seq.Base let lemma_append_inj_l #_ s1 s2 t1 t2 i = assert (index s1 i == (index (append s1 s2) i)); assert (index t1 i == (index (append t1 t2) i)) let lemma_append_inj_r #_ s1 s2 t1 t2 i = assert (index s2 i == (index (append s1 s2) (i + length s1))); assert (index t2 i == (index (append t1 t2) (i + length t1))) let lemma_append_len_disj #_ s1 s2 t1 t2 = cut (length (append s1 s2) == length s1 + length s2); cut (length (append t1 t2) == length t1 + length t2) let lemma_append_inj #_ s1 s2 t1 t2 = lemma_append_len_disj s1 s2 t1 t2; FStar.Classical.forall_intro #(i:nat{i < length s1}) #(fun i -> index s1 i == index t1 i) (lemma_append_inj_l s1 s2 t1 t2); FStar.Classical.forall_intro #(i:nat{i < length s2}) #(fun i -> index s2 i == index t2 i) (lemma_append_inj_r s1 s2 t1 t2) let lemma_head_append #_ _ _ = () let lemma_tail_append #_ s1 s2 = cut (equal (tail (append s1 s2)) (append (tail s1) s2)) let lemma_cons_inj #_ v1 v2 s1 s2 = let t1 = create 1 v1 in let t2 = create 1 v2 in lemma_append_inj t1 s1 t2 s2; assert(index t1 0 == index t2 0) let lemma_split #_ s i = cut (equal (append (fst (split s i)) (snd (split s i))) s) let rec mem_index' (#a:eqtype) (x:a) (s:seq a) : Lemma (requires (mem x s)) (ensures (exists i. index s i == x)) (decreases (length s)) = if length s = 0 then () else if head s = x then () else mem_index' x (tail s) let mem_index = mem_index' let lemma_slice_append #_ _ _ = () let rec lemma_slice_first_in_append' (#a:Type) (s1:seq a) (s2:seq a) (i:nat{i <= length s1}) : Lemma (ensures (equal (slice (append s1 s2) i (length (append s1 s2))) (append (slice s1 i (length s1)) s2))) (decreases (length s1)) = if i = 0 then () else lemma_slice_first_in_append' (tail s1) s2 (i - 1) let lemma_slice_first_in_append = lemma_slice_first_in_append' let slice_upd #_ s i j k v = lemma_eq_intro (slice (upd s k v) i j) (slice s i j) let upd_slice #_ s i j k v = lemma_eq_intro (upd (slice s i j) k v) (slice (upd s (i + k) v) i j) let lemma_append_cons #_ _ _ = () let lemma_tl #_ _ _ = () let rec sorted_feq' (#a:Type) (f g : (a -> a -> Tot bool)) (s:seq a{forall x y. f x y == g x y}) : Lemma (ensures (sorted f s <==> sorted g s)) (decreases (length s)) = if length s <= 1 then () else sorted_feq' f g (tail s) let sorted_feq = sorted_feq' let rec lemma_append_count' (#a:eqtype) (lo:seq a) (hi:seq a) : Lemma (requires True) (ensures (forall x. count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = if length lo = 0 then cut (equal (append lo hi) hi) else (cut (equal (cons (head lo) (append (tail lo) hi)) (append lo hi)); lemma_append_count' (tail lo) hi; let tl_l_h = append (tail lo) hi in let lh = cons (head lo) tl_l_h in cut (equal (tail lh) tl_l_h)) let lemma_append_count = lemma_append_count' let lemma_append_count_aux #_ _ lo hi = lemma_append_count lo hi let lemma_mem_inversion #_ _ = () let rec lemma_mem_count' (#a:eqtype) (s:seq a) (f:a -> Tot bool) : Lemma (requires (forall (i:nat{i<length s}). f (index s i))) (ensures (forall (x:a). mem x s ==> f x)) (decreases (length s)) = if length s = 0 then () else (let t = i:nat{i<length (tail s)} in cut (forall (i:t). index (tail s) i = index s (i + 1)); lemma_mem_count' (tail s) f) let lemma_mem_count = lemma_mem_count' let lemma_count_slice #_ s i = cut (equal s (append (slice s 0 i) (slice s i (length s)))); lemma_append_count (slice s 0 i) (slice s i (length s)) let rec sorted_concat_lemma': #a:eqtype -> f:(a -> a -> Tot bool){total_order a f} -> lo:seq a{sorted f lo} -> pivot:a -> hi:seq a{sorted f hi} -> Lemma (requires (forall y. (mem y lo ==> f y pivot) /\ (mem y hi ==> f pivot y))) (ensures (sorted f (append lo (cons pivot hi)))) (decreases (length lo)) = fun #_ f lo pivot hi -> if length lo = 0 then (cut (equal (append lo (cons pivot hi)) (cons pivot hi)); cut (equal (tail (cons pivot hi)) hi)) else (sorted_concat_lemma' f (tail lo) pivot hi; lemma_append_cons lo (cons pivot hi); lemma_tl (head lo) (append (tail lo) (cons pivot hi))) let sorted_concat_lemma = sorted_concat_lemma' let split_5 #a s i j = let frag_lo = slice s 0 i in let frag_i = slice s i (i + 1) in let frag_mid = slice s (i + 1) j in let frag_j = slice s j (j + 1) in let frag_hi = slice s (j + 1) (length s) in upd (upd (upd (upd (create 5 frag_lo) 1 frag_i) 2 frag_mid) 3 frag_j) 4 frag_hi let lemma_swap_permutes_aux_frag_eq #a s i j i' j' = cut (equal (slice s i' j') (slice (swap s i j) i' j')); cut (equal (slice s i (i + 1)) (slice (swap s i j) j (j + 1))); cut (equal (slice s j (j + 1)) (slice (swap s i j) i (i + 1))) #push-options "--z3rlimit 20" let lemma_swap_permutes_aux #_ s i j x = if j=i then cut (equal (swap s i j) s) else begin let s5 = split_5 s i j in let frag_lo, frag_i, frag_mid, frag_j, frag_hi = index s5 0, index s5 1, index s5 2, index s5 3, index s5 4 in lemma_append_count_aux x frag_lo (append frag_i (append frag_mid (append frag_j frag_hi))); lemma_append_count_aux x frag_i (append frag_mid (append frag_j frag_hi)); lemma_append_count_aux x frag_mid (append frag_j frag_hi); lemma_append_count_aux x frag_j frag_hi; let s' = swap s i j in let s5' = split_5 s' i j in let frag_lo', frag_j', frag_mid', frag_i', frag_hi' = index s5' 0, index s5' 1, index s5' 2, index s5' 3, index s5' 4 in lemma_swap_permutes_aux_frag_eq s i j 0 i; lemma_swap_permutes_aux_frag_eq s i j (i + 1) j; lemma_swap_permutes_aux_frag_eq s i j (j + 1) (length s); lemma_append_count_aux x frag_lo (append frag_j (append frag_mid (append frag_i frag_hi))); lemma_append_count_aux x frag_j (append frag_mid (append frag_i frag_hi)); lemma_append_count_aux x frag_mid (append frag_i frag_hi); lemma_append_count_aux x frag_i frag_hi end #pop-options let append_permutations #a s1 s2 s1' s2' = ( lemma_append_count s1 s2; lemma_append_count s1' s2' ) let lemma_swap_permutes #a s i j = FStar.Classical.forall_intro #a #(fun x -> count x s = count x (swap s i j)) (lemma_swap_permutes_aux s i j) (* perm_len: A lemma that shows that two sequences that are permutations of each other also have the same length *) //a proof optimization: Z3 only needs to unfold the recursive definition of `count` once #push-options "--fuel 1 --ifuel 1 --z3rlimit 20" let rec perm_len' (#a:eqtype) (s1 s2: seq a) : Lemma (requires (permutation a s1 s2)) (ensures (length s1 == length s2)) (decreases (length s1)) = if length s1 = 0 then begin if length s2 = 0 then () else assert (count (index s2 0) s2 > 0) end else let s1_hd = head s1 in let s1_tl = tail s1 in assert (count s1_hd s1 > 0); assert (count s1_hd s2 > 0); assert (length s2 > 0); let s2_hd = head s2 in let s2_tl = tail s2 in if s1_hd = s2_hd then (assert (permutation a s1_tl s2_tl); perm_len' s1_tl s2_tl) else let i = index_mem s1_hd s2 in let s_pfx, s_sfx = split_eq s2 i in assert (equal s_sfx (append (create 1 s1_hd) (tail s_sfx))); let s2' = append s_pfx (tail s_sfx) in lemma_append_count s_pfx s_sfx; lemma_append_count (create 1 s1_hd) (tail s_sfx); lemma_append_count s_pfx (tail s_sfx); assert (permutation a s1_tl s2'); perm_len' s1_tl s2' #pop-options let perm_len = perm_len'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.Seq.Properties.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq.Base", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tl: FStar.Seq.Base.seq a -> s: FStar.Seq.Base.seq a {FStar.Seq.Base.length s > 0} -> FStar.Pervasives.Lemma (requires FStar.Seq.Properties.permutation a tl (FStar.Seq.Properties.tail s)) (ensures FStar.Seq.Properties.permutation a (FStar.Seq.Base.cons (FStar.Seq.Properties.head s) tl) s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Seq.Base.length", "FStar.Seq.Properties.lemma_tl", "FStar.Seq.Properties.head", "Prims.unit" ]
[]
true
false
true
false
false
let cons_perm #_ tl s =
lemma_tl (head s) tl
false